diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-06-19 03:54:00 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-06-19 03:54:00 +0000 |
commit | d6e8f609245bfd13a1aee14a2347d3a3a6125319 (patch) | |
tree | 5633e2c339f330e0db835a1a8834519826c9f921 | |
parent | e11e5df3fd5c0ef8be778b1ae185ee1842790d3e (diff) |
ncurses-5.0-20000617
41 files changed, 1578 insertions, 1346 deletions
diff --git a/lib/libcurses/base/lib_addch.c b/lib/libcurses/base/lib_addch.c index 5238783668e..43dc5aca13b 100644 --- a/lib/libcurses/base/lib_addch.c +++ b/lib/libcurses/base/lib_addch.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_addch.c,v 1.2 1999/08/15 11:40:55 millert Exp $ */ +/* $OpenBSD: lib_addch.c,v 1.3 2000/06/19 03:53:38 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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 * @@ -43,7 +43,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$From: lib_addch.c,v 1.42 1999/07/24 20:01:05 tom Exp $") +MODULE_ID("$From: lib_addch.c,v 1.44 2000/05/20 21:13:11 tom Exp $") /* * Ugly microtweaking alert. Everything from here to end of module is @@ -58,40 +58,40 @@ MODULE_ID("$From: lib_addch.c,v 1.42 1999/07/24 20:01:05 tom Exp $") /* Return bit mask for clearing color pair number if given ch has color */ #define COLOR_MASK(ch) (~(chtype)((ch)&A_COLOR?A_COLOR:0)) -static inline chtype render_char(WINDOW *win, chtype ch) +static inline chtype +render_char(WINDOW *win, chtype ch) /* compute a rendition of the given char correct for the current context */ { - chtype a = win->_attrs; - - if (ch == ' ') - { - /* color in attrs has precedence over bkgd */ - ch = a | (win->_bkgd & COLOR_MASK(a)); - } - else - { - /* color in attrs has precedence over bkgd */ - a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a); - /* color in ch has precedence */ - ch |= (a & COLOR_MASK(ch)); - } - - TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd, - win->_attrs, ch)); - - return(ch); + chtype a = win->_attrs; + + if (ch == ' ') { + /* color in attrs has precedence over bkgd */ + ch = a | (win->_bkgd & COLOR_MASK(a)); + } else { + /* color in attrs has precedence over bkgd */ + a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a); + /* color in ch has precedence */ + ch |= (a & COLOR_MASK(ch)); + } + + TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd, + win->_attrs, ch)); + + return (ch); } -chtype _nc_background(WINDOW *win) +chtype +_nc_background(WINDOW *win) /* make render_char() visible while still allowing us to inline it below */ { - return (win->_bkgd); + return (win->_bkgd); } -chtype _nc_render(WINDOW *win, chtype ch) +chtype +_nc_render(WINDOW *win, chtype ch) /* make render_char() visible while still allowing us to inline it below */ { - return render_char(win, ch); + return render_char(win, ch); } /* check if position is legal; if not, return error */ @@ -107,149 +107,152 @@ chtype _nc_render(WINDOW *win, chtype ch) return(ERR); \ } #else -#define CHECK_POSITION(win, x, y) /* nothing */ +#define CHECK_POSITION(win, x, y) /* nothing */ #endif -static inline -int waddch_literal(WINDOW *win, chtype ch) +static inline int +waddch_literal(WINDOW *win, chtype ch) { - int x; - struct ldat *line; + int x; + struct ldat *line; + + x = win->_curx; + + CHECK_POSITION(win, x, win->_cury); + + /* + * If we're trying to add a character at the lower-right corner more + * than once, fail. (Moving the cursor will clear the flag). + */ +#if 0 /* Solaris 2.6 allows updating the corner more than once */ + if (win->_flags & _WRAPPED) { + if (x >= win->_maxx) + return (ERR); + win->_flags &= ~_WRAPPED; + } +#endif + + ch = render_char(win, ch); + TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs))); - x = win->_curx; + line = win->_line + win->_cury; - CHECK_POSITION(win, x, win->_cury); + CHANGED_CELL(line, x); + line->text[x++] = ch; + + TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch))); + if (x > win->_maxx) { /* - * If we're trying to add a character at the lower-right corner more - * than once, fail. (Moving the cursor will clear the flag). + * The _WRAPPED flag is useful only for telling an application that + * we've just wrapped the cursor. We don't do anything with this flag + * except set it when wrapping, and clear it whenever we move the + * cursor. If we try to wrap at the lower-right corner of a window, we + * cannot move the cursor (since that wouldn't be legal). So we return + * an error (which is what SVr4 does). Unlike SVr4, we can + * successfully add a character to the lower-right corner (Solaris 2.6 + * does this also, however). */ - if (win->_flags & _WRAPPED) { - if (x >= win->_maxx) - return (ERR); - win->_flags &= ~_WRAPPED; - } - - ch = render_char(win, ch); - TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs))); - - line = win->_line+win->_cury; - - CHANGED_CELL(line,x); - - line->text[x++] = ch; - - TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch))); - if (x > win->_maxx) { - /* - * The _WRAPPED flag is useful only for telling an application - * that we've just wrapped the cursor. We don't do anything - * with this flag except set it when wrapping, and clear it - * whenever we move the cursor. If we try to wrap at the - * lower-right corner of a window, we cannot move the cursor - * (since that wouldn't be legal). So we return an error - * (which is what SVr4 does). Unlike SVr4, we can successfully - * add a character to the lower-right corner. - */ - win->_flags |= _WRAPPED; - if (++win->_cury > win->_regbottom) { - win->_cury = win->_regbottom; - win->_curx = win->_maxx; - if (!win->_scroll) - return (ERR); - scroll(win); - } - win->_curx = 0; - return (OK); + win->_flags |= _WRAPPED; + if (++win->_cury > win->_regbottom) { + win->_cury = win->_regbottom; + win->_curx = win->_maxx; + if (!win->_scroll) + return (ERR); + scroll(win); } - win->_curx = x; - return OK; + win->_curx = 0; + return (OK); + } + win->_curx = x; + return OK; } -static inline -int waddch_nosync(WINDOW *win, const chtype ch) +static inline int +waddch_nosync(WINDOW *win, const chtype ch) /* the workhorse function -- add a character to the given window */ { - int x, y; - int t = 0; - const char *s = 0; - - if ((ch & A_ALTCHARSET) - || ((t = TextOf(ch)) > 127) - || ((s = unctrl(t))[1] == 0)) - return waddch_literal(win, ch); - - x = win->_curx; - y = win->_cury; - - switch (t) { - case '\t': - x += (TABSIZE-(x%TABSIZE)); - - /* - * Space-fill the tab on the bottom line so that we'll get the - * "correct" cursor position. - */ - if ((! win->_scroll && (y == win->_regbottom)) - || (x <= win->_maxx)) { - chtype blank = (' ' | AttrOf(ch)); - while (win->_curx < x) { - if (waddch_literal(win, blank) == ERR) - return(ERR); - } - break; - } else { - wclrtoeol(win); - win->_flags |= _WRAPPED; - if (++y > win->_regbottom) { - x = win->_maxx; - y--; - if (win->_scroll) { - scroll(win); - x = 0; - } - } else { - x = 0; - } - } - break; - case '\n': - wclrtoeol(win); - if (++y > win->_regbottom) { - y--; - if (win->_scroll) - scroll(win); - else - return (ERR); + int x, y; + int t = 0; + const char *s = 0; + + if ((ch & A_ALTCHARSET) + || ((t = TextOf(ch)) > 127) + || ((s = unctrl(t))[1] == 0)) + return waddch_literal(win, ch); + + x = win->_curx; + y = win->_cury; + + switch (t) { + case '\t': + x += (TABSIZE - (x % TABSIZE)); + + /* + * Space-fill the tab on the bottom line so that we'll get the + * "correct" cursor position. + */ + if ((!win->_scroll && (y == win->_regbottom)) + || (x <= win->_maxx)) { + chtype blank = (' ' | AttrOf(ch)); + while (win->_curx < x) { + if (waddch_literal(win, blank) == ERR) + return (ERR); + } + break; + } else { + wclrtoeol(win); + win->_flags |= _WRAPPED; + if (++y > win->_regbottom) { + x = win->_maxx; + y--; + if (win->_scroll) { + scroll(win); + x = 0; } - /* FALLTHRU */ - case '\r': + } else { x = 0; - win->_flags &= ~_WRAPPED; - break; - case '\b': - if (x == 0) - return (OK); - x--; - win->_flags &= ~_WRAPPED; - break; - default: - while (*s) - if (waddch_literal(win, (*s++)|AttrOf(ch)) == ERR) - return ERR; - return(OK); + } } - - win->_curx = x; - win->_cury = y; - - return(OK); + break; + case '\n': + wclrtoeol(win); + if (++y > win->_regbottom) { + y--; + if (win->_scroll) + scroll(win); + else + return (ERR); + } + /* FALLTHRU */ + case '\r': + x = 0; + win->_flags &= ~_WRAPPED; + break; + case '\b': + if (x == 0) + return (OK); + x--; + win->_flags &= ~_WRAPPED; + break; + default: + while (*s) + if (waddch_literal(win, (*s++) | AttrOf(ch)) == ERR) + return ERR; + return (OK); + } + + win->_curx = x; + win->_cury = y; + + return (OK); } -int _nc_waddch_nosync(WINDOW *win, const chtype c) +int +_nc_waddch_nosync(WINDOW *win, const chtype c) /* export copy of waddch_nosync() so the string-put functions can use it */ { - return(waddch_nosync(win, c)); + return (waddch_nosync(win, c)); } /* @@ -260,36 +263,38 @@ int _nc_waddch_nosync(WINDOW *win, const chtype c) /* These are actual entry points */ -int waddch(WINDOW *win, const chtype ch) +int +waddch(WINDOW *win, const chtype ch) { - int code = ERR; + int code = ERR; - TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, _tracechtype(ch))); + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, + _tracechtype(ch))); - if (win && (waddch_nosync(win, ch) != ERR)) - { - _nc_synchook(win); - code = OK; - } + if (win && (waddch_nosync(win, ch) != ERR)) { + _nc_synchook(win); + code = OK; + } - TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code)); - return(code); + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); } -int wechochar(WINDOW *win, const chtype ch) +int +wechochar(WINDOW *win, const chtype ch) { - int code = ERR; - - TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, _tracechtype(ch))); - - if (win && (waddch_nosync(win, ch) != ERR)) - { - bool save_immed = win->_immed; - win->_immed = TRUE; - _nc_synchook(win); - win->_immed = save_immed; - code = OK; - } - TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code)); - return(code); + int code = ERR; + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, + _tracechtype(ch))); + + if (win && (waddch_nosync(win, ch) != ERR)) { + bool save_immed = win->_immed; + win->_immed = TRUE; + _nc_synchook(win); + win->_immed = save_immed; + code = OK; + } + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); } diff --git a/lib/libcurses/base/lib_addstr.c b/lib/libcurses/base/lib_addstr.c index 2514981ce62..32d5fbb116f 100644 --- a/lib/libcurses/base/lib_addstr.c +++ b/lib/libcurses/base/lib_addstr.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_addstr.c,v 1.1 1999/01/18 19:09:35 millert Exp $ */ +/* $OpenBSD: lib_addstr.c,v 1.2 2000/06/19 03:53:38 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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 * @@ -42,64 +42,64 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_addstr.c,v 1.16 1998/06/28 00:38:29 tom Exp $") +MODULE_ID("$From: lib_addstr.c,v 1.17 2000/04/29 21:15:55 tom Exp $") int waddnstr(WINDOW *win, const char *const astr, int n) { -unsigned const char *str = (unsigned const char *)astr; -int code = ERR; + unsigned const char *str = (unsigned const char *) astr; + int code = ERR; - T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n)); - - if (win && (str != 0)) { - T(("... current %s", _traceattr(win->_attrs))); - TR(TRACE_VIRTPUT, ("str is not null")); - code = OK; - if (n < 0) - n = (int)strlen(astr); - - while((n-- > 0) && (*str != '\0')) { + T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n)); + + if (win && (str != 0)) { + T(("... current %s", _traceattr(win->_attrs))); + TR(TRACE_VIRTPUT, ("str is not null")); + code = OK; + if (n < 0) + n = (int) strlen(astr); + + while ((n-- > 0) && (*str != '\0')) { TR(TRACE_VIRTPUT, ("*str = %#x", *str)); - if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) { - code = ERR; - break; + if (_nc_waddch_nosync(win, (chtype) * str++) == ERR) { + code = ERR; + break; } - } - _nc_synchook(win); } - TR(TRACE_VIRTPUT, ("waddnstr returns %d", code)); - returnCode(code); + _nc_synchook(win); + } + TR(TRACE_VIRTPUT, ("waddnstr returns %d", code)); + returnCode(code); } int -waddchnstr(WINDOW *win, const chtype *const astr, int n) +waddchnstr(WINDOW *win, const chtype * const astr, int n) { -short y = win->_cury; -short x = win->_curx; -int code = OK; -struct ldat *line; + NCURSES_SIZE_T y = win->_cury; + NCURSES_SIZE_T x = win->_curx; + int code = OK; + struct ldat *line; - T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n)); + T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n)); - if (!win) - returnCode(ERR); + if (!win) + returnCode(ERR); - if (n < 0) { - const chtype *str; - n = 0; - for (str=(const chtype *)astr; *str!=0; str++) - n++; - } - if (n > win->_maxx - x + 1) - n = win->_maxx - x + 1; - if (n == 0) - returnCode(code); + if (n < 0) { + const chtype *str; + n = 0; + for (str = (const chtype *) astr; *str != 0; str++) + n++; + } + if (n > win->_maxx - x + 1) + n = win->_maxx - x + 1; + if (n == 0) + returnCode(code); - line = &(win->_line[y]); - memcpy(line->text+x, astr, n*sizeof(*astr)); - CHANGED_RANGE(line, x, x+n-1); + line = &(win->_line[y]); + memcpy(line->text + x, astr, n * sizeof(*astr)); + CHANGED_RANGE(line, x, x + n - 1); - _nc_synchook(win); - returnCode(code); + _nc_synchook(win); + returnCode(code); } diff --git a/lib/libcurses/base/lib_box.c b/lib/libcurses/base/lib_box.c index 29918f229bc..0593b769e4e 100644 --- a/lib/libcurses/base/lib_box.c +++ b/lib/libcurses/base/lib_box.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_box.c,v 1.1 1999/01/18 19:09:37 millert Exp $ */ +/* $OpenBSD: lib_box.c,v 1.2 2000/06/19 03:53:39 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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* ** lib_box.c ** @@ -44,69 +42,80 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_box.c,v 1.10 1998/02/11 12:13:56 tom Exp $") +MODULE_ID("$From: lib_box.c,v 1.11 2000/04/29 21:12:37 tom Exp $") -int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, - chtype bs, chtype tl, chtype tr, chtype bl, chtype br) +int +wborder(WINDOW *win, + chtype ls, chtype rs, chtype ts, chtype bs, + chtype tl, chtype tr, chtype bl, chtype br) { -short i; -short endx, endy; + NCURSES_SIZE_T i; + NCURSES_SIZE_T endx, endy; T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), - win, - _tracechtype2(1,ls), - _tracechtype2(2,rs), - _tracechtype2(3,ts), - _tracechtype2(4,bs), - _tracechtype2(5,tl), - _tracechtype2(6,tr), - _tracechtype2(7,bl), - _tracechtype2(8,br))); - - if (!win) - returnCode(ERR); - - if (ls == 0) ls = ACS_VLINE; - if (rs == 0) rs = ACS_VLINE; - if (ts == 0) ts = ACS_HLINE; - if (bs == 0) bs = ACS_HLINE; - if (tl == 0) tl = ACS_ULCORNER; - if (tr == 0) tr = ACS_URCORNER; - if (bl == 0) bl = ACS_LLCORNER; - if (br == 0) br = ACS_LRCORNER; - - ls = _nc_render(win, ls); - rs = _nc_render(win, rs); - ts = _nc_render(win, ts); - bs = _nc_render(win, bs); - tl = _nc_render(win, tl); - tr = _nc_render(win, tr); - bl = _nc_render(win, bl); - br = _nc_render(win, br); - - T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", ls, rs, ts, bs, tl, tr, bl, br)); - - endx = win->_maxx; - endy = win->_maxy; - - for (i = 0; i <= endx; i++) { - win->_line[0].text[i] = ts; - win->_line[endy].text[i] = bs; - } - win->_line[endy].firstchar = win->_line[0].firstchar = 0; - win->_line[endy].lastchar = win->_line[0].lastchar = endx; - - for (i = 0; i <= endy; i++) { - win->_line[i].text[0] = ls; - win->_line[i].text[endx] = rs; - win->_line[i].firstchar = 0; - win->_line[i].lastchar = endx; - } - win->_line[0].text[0] = tl; - win->_line[0].text[endx] = tr; - win->_line[endy].text[0] = bl; - win->_line[endy].text[endx] = br; - - _nc_synchook(win); - returnCode(OK); + win, + _tracechtype2(1, ls), + _tracechtype2(2, rs), + _tracechtype2(3, ts), + _tracechtype2(4, bs), + _tracechtype2(5, tl), + _tracechtype2(6, tr), + _tracechtype2(7, bl), + _tracechtype2(8, br))); + + if (!win) + returnCode(ERR); + + if (ls == 0) + ls = ACS_VLINE; + if (rs == 0) + rs = ACS_VLINE; + if (ts == 0) + ts = ACS_HLINE; + if (bs == 0) + bs = ACS_HLINE; + if (tl == 0) + tl = ACS_ULCORNER; + if (tr == 0) + tr = ACS_URCORNER; + if (bl == 0) + bl = ACS_LLCORNER; + if (br == 0) + br = ACS_LRCORNER; + + ls = _nc_render(win, ls); + rs = _nc_render(win, rs); + ts = _nc_render(win, ts); + bs = _nc_render(win, bs); + tl = _nc_render(win, tl); + tr = _nc_render(win, tr); + bl = _nc_render(win, bl); + br = _nc_render(win, br); + + T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", + ls, rs, ts, bs, tl, tr, bl, br)); + + endx = win->_maxx; + endy = win->_maxy; + + for (i = 0; i <= endx; i++) { + win->_line[0].text[i] = ts; + win->_line[endy].text[i] = bs; + } + win->_line[endy].firstchar = win->_line[0].firstchar = 0; + win->_line[endy].lastchar = win->_line[0].lastchar = endx; + + for (i = 0; i <= endy; i++) { + win->_line[i].text[0] = ls; + win->_line[i].text[endx] = rs; + win->_line[i].firstchar = 0; + win->_line[i].lastchar = endx; + } + win->_line[0].text[0] = tl; + win->_line[0].text[endx] = tr; + win->_line[endy].text[0] = bl; + win->_line[endy].text[endx] = br; + + _nc_synchook(win); + returnCode(OK); } diff --git a/lib/libcurses/base/lib_clrbot.c b/lib/libcurses/base/lib_clrbot.c index ba68bd574e7..683b4f923d6 100644 --- a/lib/libcurses/base/lib_clrbot.c +++ b/lib/libcurses/base/lib_clrbot.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_clrbot.c,v 1.1 1999/01/18 19:09:38 millert Exp $ */ +/* $OpenBSD: lib_clrbot.c,v 1.2 2000/06/19 03:53:39 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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 * @@ -42,36 +42,37 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_clrbot.c,v 1.14 1998/06/28 00:36:26 tom Exp $") +MODULE_ID("$From: lib_clrbot.c,v 1.15 2000/04/29 21:15:26 tom Exp $") -int wclrtobot(WINDOW *win) +int +wclrtobot(WINDOW *win) { -int code = ERR; + int code = ERR; - T((T_CALLED("wclrtobot(%p)"), win)); + T((T_CALLED("wclrtobot(%p)"), win)); - if (win) { - short y; - short startx = win->_curx; - chtype blank = _nc_background(win); + if (win) { + NCURSES_SIZE_T y; + NCURSES_SIZE_T startx = win->_curx; + chtype blank = _nc_background(win); - T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx)); + T(("clearing from y = %d to y = %d with maxx = %d", + win->_cury, win->_maxy, win->_maxx)); - for (y = win->_cury; y <= win->_maxy; y++) { - struct ldat *line = &(win->_line[y]); - chtype *ptr = &(line->text[startx]); - chtype *end = &(line->text[win->_maxx]); + for (y = win->_cury; y <= win->_maxy; y++) { + struct ldat *line = &(win->_line[y]); + chtype *ptr = &(line->text[startx]); + chtype *end = &(line->text[win->_maxx]); - CHANGED_TO_EOL(line, startx, win->_maxx); + CHANGED_TO_EOL(line, startx, win->_maxx); - while (ptr <= end) - *ptr++ = blank; + while (ptr <= end) + *ptr++ = blank; - startx = 0; - } - _nc_synchook(win); - code = OK; + startx = 0; } - returnCode(code); + _nc_synchook(win); + code = OK; + } + returnCode(code); } - diff --git a/lib/libcurses/base/lib_clreol.c b/lib/libcurses/base/lib_clreol.c index 163bd2d06ff..29c417f5ed3 100644 --- a/lib/libcurses/base/lib_clreol.c +++ b/lib/libcurses/base/lib_clreol.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_clreol.c,v 1.1 1999/01/18 19:09:39 millert Exp $ */ +/* $OpenBSD: lib_clreol.c,v 1.2 2000/06/19 03:53:40 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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_clreol.c ** @@ -43,51 +42,52 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_clreol.c,v 1.15 1998/06/28 00:32:20 tom Exp $") +MODULE_ID("$From: lib_clreol.c,v 1.16 2000/04/29 21:14:54 tom Exp $") -int wclrtoeol(WINDOW *win) +int +wclrtoeol(WINDOW *win) { -int code = ERR; + int code = ERR; - T((T_CALLED("wclrtoeol(%p)"), win)); + T((T_CALLED("wclrtoeol(%p)"), win)); - if (win) { - chtype blank; - chtype *ptr, *end; - struct ldat *line; - short y = win->_cury; - short x = win->_curx; + if (win) { + chtype blank; + chtype *ptr, *end; + struct ldat *line; + NCURSES_SIZE_T y = win->_cury; + NCURSES_SIZE_T x = win->_curx; - /* - * If we have just wrapped the cursor, the clear applies to the - * new line, unless we are at the lower right corner. - */ - if (win->_flags & _WRAPPED - && y < win->_maxy) { - win->_flags &= ~_WRAPPED; - } + /* + * If we have just wrapped the cursor, the clear applies to the + * new line, unless we are at the lower right corner. + */ + if (win->_flags & _WRAPPED + && y < win->_maxy) { + win->_flags &= ~_WRAPPED; + } - /* - * There's no point in clearing if we're not on a legal - * position, either. - */ - if (win->_flags & _WRAPPED - || y > win->_maxy - || x > win->_maxx) - returnCode(ERR); + /* + * There's no point in clearing if we're not on a legal + * position, either. + */ + if (win->_flags & _WRAPPED + || y > win->_maxy + || x > win->_maxx) + returnCode(ERR); - blank = _nc_background(win); - line = &win->_line[y]; - CHANGED_TO_EOL(line, x, win->_maxx); + blank = _nc_background(win); + line = &win->_line[y]; + CHANGED_TO_EOL(line, x, win->_maxx); - ptr = &(line->text[x]); - end = &(line->text[win->_maxx]); + ptr = &(line->text[x]); + end = &(line->text[win->_maxx]); - while (ptr <= end) - *ptr++ = blank; + while (ptr <= end) + *ptr++ = blank; - _nc_synchook(win); - code = OK; - } - returnCode(code); + _nc_synchook(win); + code = OK; + } + returnCode(code); } diff --git a/lib/libcurses/base/lib_color.c b/lib/libcurses/base/lib_color.c index 7d246bd05ee..a1a195453c4 100644 --- a/lib/libcurses/base/lib_color.c +++ b/lib/libcurses/base/lib_color.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_color.c,v 1.7 2000/03/26 16:45:03 millert Exp $ */ +/* $OpenBSD: lib_color.c,v 1.8 2000/06/19 03:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -43,7 +43,7 @@ #include <term.h> #include <tic.h> -MODULE_ID("$From: lib_color.c,v 1.49 2000/03/26 03:12:12 tom Exp $") +MODULE_ID("$From: lib_color.c,v 1.51 2000/05/20 20:09:22 tom Exp $") /* * These should be screen structure members. They need to be globals for @@ -314,7 +314,7 @@ init_pair(short pair, short f, short b) } } SP->_color_pairs[pair] = result; - if ((int)(SP->_current_attr & A_COLOR) == COLOR_PAIR(pair)) + if ((int) (SP->_current_attr & A_COLOR) == COLOR_PAIR(pair)) SP->_current_attr |= A_COLOR; /* force attribute update */ if (initialize_pair) { @@ -421,10 +421,12 @@ pair_content(short pair, short *f, short *b) void _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int)) { - short fg = C_MASK, bg = C_MASK; - short old_fg, old_bg; + NCURSES_COLOR_T fg = C_MASK, bg = C_MASK; + NCURSES_COLOR_T old_fg, old_bg; - if (pair != 0) { + if (pair < 0 || pair >= COLOR_PAIRS) { + return; + } else if (pair != 0) { if (set_color_pair) { TPUTS_TRACE("set_color_pair"); tputs(tparm(set_color_pair, pair), 1, outc); @@ -466,7 +468,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int)) #endif if (reverse) { - short xx = fg; + NCURSES_COLOR_T xx = fg; fg = bg; bg = xx; } diff --git a/lib/libcurses/base/lib_dft_fgbg.c b/lib/libcurses/base/lib_dft_fgbg.c index b695b6d7f1e..bad566299e4 100644 --- a/lib/libcurses/base/lib_dft_fgbg.c +++ b/lib/libcurses/base/lib_dft_fgbg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_dft_fgbg.c,v 1.4 2000/03/26 16:45:03 millert Exp $ */ +/* $OpenBSD: lib_dft_fgbg.c,v 1.5 2000/06/19 03:53:41 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -35,7 +35,7 @@ #include <curses.priv.h> #include <term.h> -MODULE_ID("$From: lib_dft_fgbg.c,v 1.10 2000/03/26 03:08:53 Alexander.V.Lukyanov Exp $") +MODULE_ID("$From: lib_dft_fgbg.c,v 1.11 2000/05/07 01:26:06 tom Exp $") /* * Modify the behavior of color-pair 0 so that the library doesn't assume that @@ -64,7 +64,7 @@ assume_default_colors(int fg, int bg) returnCode(ERR); SP->_default_color = (fg != COLOR_WHITE) || (bg != COLOR_BLACK); - SP->_has_sgr_39_49 = tigetflag("AX"); + SP->_has_sgr_39_49 = (tigetflag("AX") == TRUE); SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK; SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK; if (SP->_color_pairs != 0) diff --git a/lib/libcurses/base/lib_getch.c b/lib/libcurses/base/lib_getch.c index 3057117c347..f7b6de9490f 100644 --- a/lib/libcurses/base/lib_getch.c +++ b/lib/libcurses/base/lib_getch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_getch.c,v 1.4 2000/03/10 01:35:02 millert Exp $ */ +/* $OpenBSD: lib_getch.c,v 1.5 2000/06/19 03:53:41 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -42,7 +42,7 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_getch.c,v 1.46 2000/02/20 01:21:33 tom Exp $") +MODULE_ID("$From: lib_getch.c,v 1.47 2000/05/28 01:12:51 tom Exp $") #include <fifo_defs.h> @@ -310,6 +310,30 @@ wgetch(WINDOW *win) } /* + * If echo() is in effect, display the printable version of the + * key on the screen. Carriage return and backspace are treated + * specially by Solaris curses: + * + * If carriage return is defined as a function key in the + * terminfo, e.g., kent, then Solaris may return either ^J (or ^M + * if nonl() is set) or KEY_ENTER depending on the echo() mode. + * We echo before translating carriage return based on nonl(), + * since the visual result simply moves the cursor to column 0. + * + * Backspace is a different matter. Solaris curses does not + * translate it to KEY_BACKSPACE if kbs=^H. This does not depend + * on the stty modes, but appears to be a hardcoded special case. + * This is a difference from ncurses, which uses the terminfo entry. + * However, we provide the same visual result as Solaris, moving the + * cursor to the left. + */ + if (SP->_echo && !(win->_flags & _ISPAD)) { + chtype backup = (ch == KEY_BACKSPACE) ? '\b' : ch; + if (backup < KEY_MIN) + wechochar(win, backup); + } + + /* * Simulate ICRNL mode */ if ((ch == '\r') && SP->_nl) @@ -324,9 +348,6 @@ wgetch(WINDOW *win) if (!SP->_use_meta) ch &= 0x7f; - if (SP->_echo && ch < KEY_MIN && !(win->_flags & _ISPAD)) - wechochar(win, (chtype) ch); - T(("wgetch returning : %#x = %s", ch, _trace_key(ch))); returnCode(ch); diff --git a/lib/libcurses/base/lib_hline.c b/lib/libcurses/base/lib_hline.c index a9c7d8d2d13..9fec35b52df 100644 --- a/lib/libcurses/base/lib_hline.c +++ b/lib/libcurses/base/lib_hline.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_hline.c,v 1.1 1999/01/18 19:09:46 millert Exp $ */ +/* $OpenBSD: lib_hline.c,v 1.2 2000/06/19 03:53:42 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* ** lib_hline.c ** @@ -44,35 +42,36 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_hline.c,v 1.4 1998/06/28 00:11:01 tom Exp $") +MODULE_ID("$From: lib_hline.c,v 1.5 2000/04/29 21:14:30 tom Exp $") -int whline(WINDOW *win, chtype ch, int n) +int +whline(WINDOW *win, chtype ch, int n) { -int code = ERR; -short start; -short end; + int code = ERR; + NCURSES_SIZE_T start; + NCURSES_SIZE_T end; - T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n)); + T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n)); - if (win) { - struct ldat *line = &(win->_line[win->_cury]); + if (win) { + struct ldat *line = &(win->_line[win->_cury]); - start = win->_curx; - end = start + n - 1; - if (end > win->_maxx) - end = win->_maxx; + start = win->_curx; + end = start + n - 1; + if (end > win->_maxx) + end = win->_maxx; - CHANGED_RANGE(line, start, end); + CHANGED_RANGE(line, start, end); - if (ch == 0) - ch = ACS_HLINE; - ch = _nc_render(win, ch); + if (ch == 0) + ch = ACS_HLINE; + ch = _nc_render(win, ch); - while ( end >= start) { - line->text[end] = ch; - end--; - } - code = OK; + while (end >= start) { + line->text[end] = ch; + end--; } - returnCode(code); + code = OK; + } + returnCode(code); } diff --git a/lib/libcurses/base/lib_insstr.c b/lib/libcurses/base/lib_insstr.c index db41e072158..69b1777f172 100644 --- a/lib/libcurses/base/lib_insstr.c +++ b/lib/libcurses/base/lib_insstr.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_insstr.c,v 1.2 1999/03/14 03:10:32 millert Exp $ */ +/* $OpenBSD: lib_insstr.c,v 1.3 2000/06/19 03:53:42 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* ** lib_insstr.c ** @@ -45,39 +43,41 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$From: lib_insstr.c,v 1.13 1999/03/14 00:27:21 tom Exp $") +MODULE_ID("$From: lib_insstr.c,v 1.14 2000/04/29 21:16:41 tom Exp $") -int winsnstr(WINDOW *win, const char *s, int n) +int +winsnstr(WINDOW *win, const char *s, int n) { -int code = ERR; -short oy; -short ox ; -const unsigned char *str = (const unsigned char *)s; -const unsigned char *cp; + int code = ERR; + NCURSES_SIZE_T oy; + NCURSES_SIZE_T ox; + const unsigned char *str = (const unsigned char *) s; + const unsigned char *cp; - T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n)); + T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n)); - if (win && str) { - oy = win->_cury; ox = win->_curx; - for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { + if (win && str) { + oy = win->_cury; + ox = win->_curx; + for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') - _nc_waddch_nosync(win, (chtype)(*cp)); + _nc_waddch_nosync(win, (chtype) (*cp)); else if (is7bits(*cp) && iscntrl(*cp)) { - winsch(win, ' ' + (chtype)(*cp)); - winsch(win, '^'); - win->_curx += 2; + winsch(win, ' ' + (chtype) (*cp)); + winsch(win, '^'); + win->_curx += 2; } else { - winsch(win, (chtype)(*cp)); - win->_curx++; + winsch(win, (chtype) (*cp)); + win->_curx++; } if (win->_curx > win->_maxx) - win->_curx = win->_maxx; - } - - win->_curx = ox; - win->_cury = oy; - _nc_synchook(win); - code = OK; + win->_curx = win->_maxx; } - returnCode(code); + + win->_curx = ox; + win->_cury = oy; + _nc_synchook(win); + code = OK; + } + returnCode(code); } diff --git a/lib/libcurses/base/lib_move.c b/lib/libcurses/base/lib_move.c index 96b93998838..ce700863e59 100644 --- a/lib/libcurses/base/lib_move.c +++ b/lib/libcurses/base/lib_move.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_move.c,v 1.1 1999/01/18 19:09:52 millert Exp $ */ +/* $OpenBSD: lib_move.c,v 1.2 2000/06/19 03:53:43 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_move.c ** @@ -43,23 +42,22 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_move.c,v 1.8 1998/02/11 12:13:53 tom Exp $") +MODULE_ID("$From: lib_move.c,v 1.9 2000/04/29 21:11:19 tom Exp $") int wmove(WINDOW *win, int y, int x) { - T((T_CALLED("wmove(%p,%d,%d)"), win, y, x)); - - if (win && - x >= 0 && x <= win->_maxx && - y >= 0 && y <= win->_maxy) - { - win->_curx = (short)x; - win->_cury = (short)y; - - win->_flags &= ~_WRAPPED; - win->_flags |= _HASMOVED; - returnCode(OK); - } else - returnCode(ERR); + T((T_CALLED("wmove(%p,%d,%d)"), win, y, x)); + + if (win && + x >= 0 && x <= win->_maxx && + y >= 0 && y <= win->_maxy) { + win->_curx = (NCURSES_SIZE_T) x; + win->_cury = (NCURSES_SIZE_T) y; + + win->_flags &= ~_WRAPPED; + win->_flags |= _HASMOVED; + returnCode(OK); + } else + returnCode(ERR); } diff --git a/lib/libcurses/base/lib_newterm.c b/lib/libcurses/base/lib_newterm.c index 73899d4ecc8..b9f274bf7d3 100644 --- a/lib/libcurses/base/lib_newterm.c +++ b/lib/libcurses/base/lib_newterm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_newterm.c,v 1.7 2000/03/10 01:35:02 millert Exp $ */ +/* $OpenBSD: lib_newterm.c,v 1.8 2000/06/19 03:53:43 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -49,7 +49,7 @@ #include <term.h> /* clear_screen, cup & friends, cur_term */ #include <tic.h> -MODULE_ID("$From: lib_newterm.c,v 1.44 2000/02/13 00:59:39 tom Exp $") +MODULE_ID("$From: lib_newterm.c,v 1.45 2000/05/20 23:45:57 tom Exp $"); #ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */ #define ONLCR 0 @@ -193,6 +193,22 @@ newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp) SP->_use_rmso = SGR0_TEST(exit_standout_mode); SP->_use_rmul = SGR0_TEST(exit_underline_mode); +#ifdef USE_WIDEC_SUPPORT + /* + * XFree86 xterm can be configured to support UTF-8 based on environment + * variable settings. + */ + { + char *s; + if (((s = getenv("LC_ALL")) != 0 + || (s = getenv("LC_CTYPE")) != 0 + || (s = getenv("LANG")) != 0) + && strstr(s, "UTF-8") != 0) { + SP->_outch = _nc_utf8_outch; + } + } +#endif + /* compute movement costs so we can do better move optimization */ _nc_mvcur_init(); diff --git a/lib/libcurses/base/lib_newwin.c b/lib/libcurses/base/lib_newwin.c index 66f2facd537..e7d2def4ebf 100644 --- a/lib/libcurses/base/lib_newwin.c +++ b/lib/libcurses/base/lib_newwin.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_newwin.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */ +/* $OpenBSD: lib_newwin.c,v 1.3 2000/06/19 03:53:43 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* ** lib_newwin.c ** @@ -44,230 +42,247 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_newwin.c,v 1.22 1999/11/25 13:48:24 juergen Exp $") +MODULE_ID("$From: lib_newwin.c,v 1.24 2000/04/29 18:49:51 tom Exp $") -void _nc_freewin(WINDOW *win) +void +_nc_freewin(WINDOW *win) { -WINDOWLIST *p, *q; -int i; - - if (win != 0) { - for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) { - if (p->win == win) { - if (q == 0) - _nc_windows = p->next; - else - q->next = p->next; - free(p); - - if (! (win->_flags & _SUBWIN)) { - for (i = 0; i <= win->_maxy; i++) - FreeIfNeeded(win->_line[i].text); - } - free(win->_line); - free(win); - - if (win == curscr) curscr = 0; - if (win == stdscr) stdscr = 0; - if (win == newscr) newscr = 0; - - T(("...deleted win=%p", win)); - break; - } + WINDOWLIST *p, *q; + int i; + + if (win != 0) { + for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) { + if (p->win == win) { + if (q == 0) + _nc_windows = p->next; + else + q->next = p->next; + free(p); + + if (!(win->_flags & _SUBWIN)) { + for (i = 0; i <= win->_maxy; i++) + FreeIfNeeded(win->_line[i].text); } + free(win->_line); + free(win); + + if (win == curscr) + curscr = 0; + if (win == stdscr) + stdscr = 0; + if (win == newscr) + newscr = 0; + + T(("...deleted win=%p", win)); + break; + } } + } } -WINDOW * newwin(int num_lines, int num_columns, int begy, int begx) +WINDOW * +newwin(int num_lines, int num_columns, int begy, int begx) { -WINDOW *win; -chtype *ptr; -int i; + WINDOW *win; + chtype *ptr; + int i; - T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx)); + T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx)); - if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0) - returnWin(0); + if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0) + returnWin(0); - if (num_lines == 0) - num_lines = SP->_lines_avail - begy; - if (num_columns == 0) - num_columns = screen_columns - begx; + if (num_lines == 0) + num_lines = SP->_lines_avail - begy; + if (num_columns == 0) + num_columns = screen_columns - begx; - if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail) - returnWin(0); + if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail) + returnWin(0); - if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0) - returnWin(0); + if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0) + returnWin(0); - for (i = 0; i < num_lines; i++) { - if ((win->_line[i].text = typeCalloc(chtype, (unsigned)num_columns)) == 0) { - _nc_freewin(win); - returnWin(0); - } - for (ptr = win->_line[i].text; ptr < win->_line[i].text + num_columns; ) - *ptr++ = ' '; + for (i = 0; i < num_lines; i++) { + win->_line[i].text = typeCalloc(chtype, (unsigned) num_columns); + if (win->_line[i].text == 0) { + _nc_freewin(win); + returnWin(0); } + for (ptr = win->_line[i].text; ptr < win->_line[i].text + + num_columns;) + *ptr++ = ' '; + } - T(("newwin: returned window is %p", win)); + T(("newwin: returned window is %p", win)); - returnWin(win); + returnWin(win); } -WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) +WINDOW * +derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) { -WINDOW *win; -int i; -int flags = _SUBWIN; + WINDOW *win; + int i; + int flags = _SUBWIN; - T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns, begy, begx)); + T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns, + begy, begx)); - /* - ** make sure window fits inside the original one - */ - if ( begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0) - returnWin(0); - if ( begy + num_lines > orig->_maxy + 1 - || begx + num_columns > orig->_maxx + 1) - returnWin(0); + /* + ** make sure window fits inside the original one + */ + if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0) + returnWin(0); + if (begy + num_lines > orig->_maxy + 1 + || begx + num_columns > orig->_maxx + 1) + returnWin(0); - if (num_lines == 0) - num_lines = orig->_maxy + 1 - begy; + if (num_lines == 0) + num_lines = orig->_maxy + 1 - begy; - if (num_columns == 0) - num_columns = orig->_maxx + 1 - begx; + if (num_columns == 0) + num_columns = orig->_maxx + 1 - begx; - if (orig->_flags & _ISPAD) - flags |= _ISPAD; + if (orig->_flags & _ISPAD) + flags |= _ISPAD; - if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx, flags)) == 0) - returnWin(0); + if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, + orig->_begx + begx, flags)) == 0) + returnWin(0); - win->_pary = begy; - win->_parx = begx; - win->_attrs = orig->_attrs; - win->_bkgd = orig->_bkgd; + win->_pary = begy; + win->_parx = begx; + win->_attrs = orig->_attrs; + win->_bkgd = orig->_bkgd; - for (i = 0; i < num_lines; i++) - win->_line[i].text = &orig->_line[begy++].text[begx]; + for (i = 0; i < num_lines; i++) + win->_line[i].text = &orig->_line[begy++].text[begx]; - win->_parent = orig; + win->_parent = orig; - T(("derwin: returned window is %p", win)); + T(("derwin: returned window is %p", win)); - returnWin(win); + returnWin(win); } - -WINDOW *subwin(WINDOW *w, int l, int c, int y, int x) +WINDOW * +subwin(WINDOW *w, int l, int c, int y, int x) { - T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x)); - T(("parent has begy = %d, begx = %d", w->_begy, w->_begx)); + T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x)); + T(("parent has begy = %d, begx = %d", w->_begy, w->_begx)); + + returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx)); +} - returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx)); +static bool +dimension_limit(int value) +{ + NCURSES_SIZE_T test = value; + return (test == value && value > 0); } WINDOW * _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) { -int i; -WINDOWLIST *wp; -WINDOW *win; -bool is_pad = (flags & _ISPAD); - - T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx)); - - if (num_lines <= 0 || num_columns <= 0) - return 0; - - if ((wp = typeCalloc(WINDOWLIST, 1)) == 0) - return 0; - - if ((win = typeCalloc(WINDOW, 1)) == 0) - return 0; - - if ((win->_line = typeCalloc(struct ldat, ((unsigned)num_lines))) == 0) { - free(win); - return 0; - } - - win->_curx = 0; - win->_cury = 0; - win->_maxy = num_lines - 1; - win->_maxx = num_columns - 1; - win->_begy = begy; - win->_begx = begx; - win->_yoffset = SP->_topstolen; - - win->_flags = flags; - win->_attrs = A_NORMAL; - win->_bkgd = BLANK; - - win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns == screen_columns); - win->_idlok = FALSE; - win->_idcok = TRUE; - win->_scroll = FALSE; - win->_leaveok = FALSE; - win->_use_keypad = FALSE; - win->_delay = -1; - win->_immed = FALSE; - win->_sync = 0; - win->_parx = -1; - win->_pary = -1; - win->_parent = 0; - - win->_regtop = 0; - win->_regbottom = num_lines - 1; - - win->_pad._pad_y = -1; - win->_pad._pad_x = -1; - win->_pad._pad_top = -1; - win->_pad._pad_bottom = -1; - win->_pad._pad_left = -1; - win->_pad._pad_right = -1; - - for (i = 0; i < num_lines; i++) - { - /* - * This used to do - * - * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE; - * - * which marks the whole window unchanged. That's how - * SVr1 curses did it, but SVr4 curses marks the whole new - * window changed. - * - * With the old SVr1-like code, say you have stdscr full of - * characters, then create a new window with newwin(), - * then do a printw(win, "foo ");, the trailing spaces are - * completely ignored by the following refreshes. So, you - * get "foojunkjunk" on the screen instead of "foo " as - * you actually intended. - * - * SVr4 doesn't do this. Instead the spaces are actually written. - * So that's how we want ncurses to behave. - */ - win->_line[i].firstchar = 0; - win->_line[i].lastchar = num_columns-1; - - if_USE_SCROLL_HINTS(win->_line[i].oldindex = i); - } - - if (!is_pad && (begx + num_columns == screen_columns)) { - win->_flags |= _ENDLINE; - - if (begx == 0 && num_lines == screen_lines && begy == 0) - win->_flags |= _FULLWIN; - - if (begy + num_lines == screen_lines) - win->_flags |= _SCROLLWIN; - } - - wp->next = _nc_windows; - wp->win = win; - _nc_windows = wp; - - T((T_CREATE("window %p"), win)); - - return(win); + int i; + WINDOWLIST *wp; + WINDOW *win; + bool is_pad = (flags & _ISPAD); + + T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx)); + + if (!dimension_limit(num_lines) || !dimension_limit(num_columns)) + return 0; + + if ((wp = typeCalloc(WINDOWLIST, 1)) == 0) + return 0; + + if ((win = typeCalloc(WINDOW, 1)) == 0) + return 0; + + if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) { + free(win); + return 0; + } + + win->_curx = 0; + win->_cury = 0; + win->_maxy = num_lines - 1; + win->_maxx = num_columns - 1; + win->_begy = begy; + win->_begx = begx; + win->_yoffset = SP->_topstolen; + + win->_flags = flags; + win->_attrs = A_NORMAL; + win->_bkgd = BLANK; + + win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns + == screen_columns); + win->_idlok = FALSE; + win->_idcok = TRUE; + win->_scroll = FALSE; + win->_leaveok = FALSE; + win->_use_keypad = FALSE; + win->_delay = -1; + win->_immed = FALSE; + win->_sync = 0; + win->_parx = -1; + win->_pary = -1; + win->_parent = 0; + + win->_regtop = 0; + win->_regbottom = num_lines - 1; + + win->_pad._pad_y = -1; + win->_pad._pad_x = -1; + win->_pad._pad_top = -1; + win->_pad._pad_bottom = -1; + win->_pad._pad_left = -1; + win->_pad._pad_right = -1; + + for (i = 0; i < num_lines; i++) { + /* + * This used to do + * + * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE; + * + * which marks the whole window unchanged. That's how + * SVr1 curses did it, but SVr4 curses marks the whole new + * window changed. + * + * With the old SVr1-like code, say you have stdscr full of + * characters, then create a new window with newwin(), + * then do a printw(win, "foo ");, the trailing spaces are + * completely ignored by the following refreshes. So, you + * get "foojunkjunk" on the screen instead of "foo " as + * you actually intended. + * + * SVr4 doesn't do this. Instead the spaces are actually written. + * So that's how we want ncurses to behave. + */ + win->_line[i].firstchar = 0; + win->_line[i].lastchar = num_columns - 1; + + if_USE_SCROLL_HINTS(win->_line[i].oldindex = i); + } + + if (!is_pad && (begx + num_columns == screen_columns)) { + win->_flags |= _ENDLINE; + + if (begx == 0 && num_lines == screen_lines && begy == 0) + win->_flags |= _FULLWIN; + + if (begy + num_lines == screen_lines) + win->_flags |= _SCROLLWIN; + } + + wp->next = _nc_windows; + wp->win = win; + _nc_windows = wp; + + T((T_CREATE("window %p"), win)); + + return (win); } diff --git a/lib/libcurses/base/lib_pad.c b/lib/libcurses/base/lib_pad.c index 4f2ed3e58be..5289ef67cc5 100644 --- a/lib/libcurses/base/lib_pad.c +++ b/lib/libcurses/base/lib_pad.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_pad.c,v 1.2 2000/03/10 01:35:02 millert Exp $ */ +/* $OpenBSD: lib_pad.c,v 1.3 2000/06/19 03:53:44 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_pad.c * newpad -- create a new pad @@ -43,241 +42,253 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_pad.c,v 1.28 2000/03/05 00:21:55 David.Mosberger Exp $") +MODULE_ID("$From: lib_pad.c,v 1.29 2000/04/29 21:19:44 tom Exp $") -WINDOW *newpad(int l, int c) +WINDOW * +newpad(int l, int c) { -WINDOW *win; -chtype *ptr; -int i; + WINDOW *win; + chtype *ptr; + int i; - T((T_CALLED("newpad(%d, %d)"), l, c)); + T((T_CALLED("newpad(%d, %d)"), l, c)); - if (l <= 0 || c <= 0) - returnWin(0); + if (l <= 0 || c <= 0) + returnWin(0); - if ((win = _nc_makenew(l,c,0,0,_ISPAD)) == NULL) - returnWin(0); + if ((win = _nc_makenew(l, c, 0, 0, _ISPAD)) == NULL) + returnWin(0); - for (i = 0; i < l; i++) { - if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX); - if ((win->_line[i].text = typeCalloc(chtype, ((size_t)c))) == 0) { - _nc_freewin(win); - returnWin(0); - } - for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; ) - *ptr++ = ' '; + for (i = 0; i < l; i++) { + if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX); + if ((win->_line[i].text = typeCalloc(chtype, ((size_t) c))) == 0) { + _nc_freewin(win); + returnWin(0); } + for (ptr = win->_line[i].text; ptr < win->_line[i].text + c;) + *ptr++ = ' '; + } - returnWin(win); + returnWin(win); } -WINDOW *subpad(WINDOW *orig, int l, int c, int begy, int begx) +WINDOW * +subpad(WINDOW *orig, int l, int c, int begy, int begx) { -WINDOW *win = (WINDOW *)0; + WINDOW *win = (WINDOW *) 0; - T((T_CALLED("subpad(%d, %d)"), l, c)); + T((T_CALLED("subpad(%d, %d)"), l, c)); - if (orig) { - if (!(orig->_flags & _ISPAD) || ((win = derwin(orig, l, c, begy, begx)) == NULL)) + if (orig) { + if (!(orig->_flags & _ISPAD) + || ((win = derwin(orig, l, c, begy, begx)) == NULL)) returnWin(0); - } - returnWin(win); + } + returnWin(win); } -int prefresh(WINDOW *win, int pminrow, int pmincol, - int sminrow, int smincol, int smaxrow, int smaxcol) +int +prefresh(WINDOW *win, int pminrow, int pmincol, + int sminrow, int smincol, int smaxrow, int smaxcol) { - T((T_CALLED("prefresh()"))); - if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) != ERR - && doupdate() != ERR) { - returnCode(OK); - } - returnCode(ERR); + T((T_CALLED("prefresh()"))); + if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow, + smaxcol) != ERR + && doupdate() != ERR) { + returnCode(OK); + } + returnCode(ERR); } -int pnoutrefresh(WINDOW *win, int pminrow, int pmincol, - int sminrow, int smincol, int smaxrow, int smaxcol) +int +pnoutrefresh(WINDOW *win, int pminrow, int pmincol, + int sminrow, int smincol, int smaxrow, int smaxcol) { -const int my_len = 2; /* parameterize the threshold for hardscroll */ -short i, j; -short m, n; -short pmaxrow; -short pmaxcol; -short displaced; -bool wide; - - T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"), - win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol)); - - if (win == 0) - returnCode(ERR); - - if (!(win->_flags & _ISPAD)) - returnCode(ERR); + const int my_len = 2; /* parameterize the threshold for hardscroll */ + NCURSES_SIZE_T i, j; + NCURSES_SIZE_T m, n; + NCURSES_SIZE_T pmaxrow; + NCURSES_SIZE_T pmaxcol; + NCURSES_SIZE_T displaced; + bool wide; + + T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"), + win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol)); + + if (win == 0) + returnCode(ERR); - /* negative values are interpreted as zero */ - if (pminrow < 0) pminrow = 0; - if (pmincol < 0) pmincol = 0; - if (sminrow < 0) sminrow = 0; - if (smincol < 0) smincol = 0; + if (!(win->_flags & _ISPAD)) + returnCode(ERR); + /* negative values are interpreted as zero */ + if (pminrow < 0) + pminrow = 0; + if (pmincol < 0) + pmincol = 0; + if (sminrow < 0) + sminrow = 0; + if (smincol < 0) + smincol = 0; + + pmaxrow = pminrow + smaxrow - sminrow; + pmaxcol = pmincol + smaxcol - smincol; + + T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy)); + T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx)); + + /* + * Trim the caller's screen size back to the actual limits. + */ + if (pmaxrow > win->_maxy) { + smaxrow -= (pmaxrow - win->_maxy); pmaxrow = pminrow + smaxrow - sminrow; + } + if (pmaxcol > win->_maxx) { + smaxcol -= (pmaxcol - win->_maxx); pmaxcol = pmincol + smaxcol - smincol; + } - T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy)); - T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx)); + if (smaxrow > screen_lines + || smaxcol > screen_columns + || sminrow > smaxrow + || smincol > smaxcol) + returnCode(ERR); - /* - * Trim the caller's screen size back to the actual limits. - */ - if (pmaxrow > win->_maxy) { - smaxrow -= (pmaxrow - win->_maxy); - pmaxrow = pminrow + smaxrow - sminrow; - } - if (pmaxcol > win->_maxx) { - smaxcol -= (pmaxcol - win->_maxx); - pmaxcol = pmincol + smaxcol - smincol; + T(("pad being refreshed")); + + if (win->_pad._pad_y >= 0) { + displaced = pminrow - win->_pad._pad_y + - (sminrow - win->_pad._pad_top); + T(("pad being shifted by %d line(s)", displaced)); + } else + displaced = 0; + + /* + * For pure efficiency, we'd want to transfer scrolling information + * from the pad to newscr whenever the window is wide enough that + * its update will dominate the cost of the update for the horizontal + * band of newscr that it occupies. Unfortunately, this threshold + * tends to be complex to estimate, and in any case scrolling the + * whole band and rewriting the parts outside win's image would look + * really ugly. So. What we do is consider the pad "wide" if it + * either (a) occupies the whole width of newscr, or (b) occupies + * all but at most one column on either vertical edge of the screen + * (this caters to fussy people who put boxes around full-screen + * windows). Note that changing this formula will not break any code, + * merely change the costs of various update cases. + */ + wide = (smincol < my_len && smaxcol > (newscr->_maxx - my_len)); + + for (i = pminrow, m = sminrow + win->_yoffset; + i <= pmaxrow && m <= newscr->_maxy; + i++, m++) { + register struct ldat *nline = &newscr->_line[m]; + register struct ldat *oline = &win->_line[i]; + + for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) { + if (oline->text[j] != nline->text[n]) { + nline->text[n] = oline->text[j]; + CHANGED_CELL(nline, n); + } } - if (smaxrow > screen_lines - || smaxcol > screen_columns - || sminrow > smaxrow - || smincol > smaxcol) - returnCode(ERR); - - T(("pad being refreshed")); - - if (win->_pad._pad_y >= 0) { - displaced = pminrow - win->_pad._pad_y - -(sminrow - win->_pad._pad_top); - T(("pad being shifted by %d line(s)", displaced)); - } else - displaced = 0; - - /* - * For pure efficiency, we'd want to transfer scrolling information - * from the pad to newscr whenever the window is wide enough that - * its update will dominate the cost of the update for the horizontal - * band of newscr that it occupies. Unfortunately, this threshold - * tends to be complex to estimate, and in any case scrolling the - * whole band and rewriting the parts outside win's image would look - * really ugly. So. What we do is consider the pad "wide" if it - * either (a) occupies the whole width of newscr, or (b) occupies - * all but at most one column on either vertical edge of the screen - * (this caters to fussy people who put boxes around full-screen - * windows). Note that changing this formula will not break any code, - * merely change the costs of various update cases. - */ - wide = (smincol < my_len && smaxcol > (newscr->_maxx - my_len)); - - for (i = pminrow, m = sminrow + win->_yoffset; - i <= pmaxrow && m <= newscr->_maxy; - i++, m++) { - register struct ldat *nline = &newscr->_line[m]; - register struct ldat *oline = &win->_line[i]; - - for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) { - if (oline->text[j] != nline->text[n]) { - nline->text[n] = oline->text[j]; - CHANGED_CELL(nline,n); - } - } - #if USE_SCROLL_HINTS - if (wide) { - int nind = m + displaced; - if (oline->oldindex < 0 - || nind < sminrow - || nind > smaxrow) { + if (wide) { + int nind = m + displaced; + if (oline->oldindex < 0 + || nind < sminrow + || nind > smaxrow) { + nind = _NEWINDEX; + } else if (displaced) { + register struct ldat *pline = &curscr->_line[nind]; + for (j = 0; j <= my_len; j++) { + int k = newscr->_maxx - j; + if (pline->text[j] != nline->text[j] + || pline->text[k] != nline->text[k]) { nind = _NEWINDEX; - } else if (displaced) { - register struct ldat *pline = &curscr->_line[nind]; - for (j = 0; j <= my_len; j++) { - int k = newscr->_maxx - j; - if (pline->text[j] != nline->text[j] - || pline->text[k] != nline->text[k]) { - nind = _NEWINDEX; - break; - } - } + break; } - - nline->oldindex = nind; } -#endif /* USE_SCROLL_HINTS */ - oline->firstchar = oline->lastchar = _NOCHANGE; - if_USE_SCROLL_HINTS(oline->oldindex = i); - } + } - /* - * Clean up debris from scrolling or resizing the pad, so we do not - * accidentally pick up the index value during the next call to this - * procedure. The only rows that should have an index value are those - * that are displayed during this cycle. - */ + nline->oldindex = nind; + } +#endif /* USE_SCROLL_HINTS */ + oline->firstchar = oline->lastchar = _NOCHANGE; + if_USE_SCROLL_HINTS(oline->oldindex = i); + } + + /* + * Clean up debris from scrolling or resizing the pad, so we do not + * accidentally pick up the index value during the next call to this + * procedure. The only rows that should have an index value are those + * that are displayed during this cycle. + */ #if USE_SCROLL_HINTS - for (i = pminrow-1; (i >= 0) && (win->_line[i].oldindex >= 0); i--) - win->_line[i].oldindex = _NEWINDEX; - for (i = pmaxrow+1; (i <= win->_maxy) && (win->_line[i].oldindex >= 0); i++) - win->_line[i].oldindex = _NEWINDEX; + for (i = pminrow - 1; (i >= 0) && (win->_line[i].oldindex >= 0); i--) + win->_line[i].oldindex = _NEWINDEX; + for (i = pmaxrow + 1; (i <= win->_maxy) + && (win->_line[i].oldindex >= 0); i++) + win->_line[i].oldindex = _NEWINDEX; #endif - win->_begx = smincol; - win->_begy = sminrow; + win->_begx = smincol; + win->_begy = sminrow; + + if (win->_clear) { + win->_clear = FALSE; + newscr->_clear = TRUE; + } + + /* + * Use the pad's current position, if it will be visible. + * If not, don't do anything; it's not an error. + */ + if (win->_leaveok == FALSE + && win->_cury >= pminrow + && win->_curx >= pmincol + && win->_cury <= pmaxrow + && win->_curx <= pmaxcol) { + newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset; + newscr->_curx = win->_curx - pmincol + win->_begx; + } + newscr->_leaveok = win->_leaveok; + win->_flags &= ~_HASMOVED; + + /* + * Update our cache of the line-numbers that we displayed from the pad. + * We will use this on subsequent calls to this function to derive + * values to stuff into 'oldindex[]' -- for scrolling optimization. + */ + win->_pad._pad_y = pminrow; + win->_pad._pad_x = pmincol; + win->_pad._pad_top = sminrow; + win->_pad._pad_left = smincol; + win->_pad._pad_bottom = smaxrow; + win->_pad._pad_right = smaxcol; + + returnCode(OK); +} - if (win->_clear) { - win->_clear = FALSE; - newscr->_clear = TRUE; - } +int +pechochar(WINDOW *pad, const chtype ch) +{ + T((T_CALLED("pechochar(%p, %s)"), pad, _tracechtype(ch))); - /* - * Use the pad's current position, if it will be visible. - * If not, don't do anything; it's not an error. - */ - if (win->_leaveok == FALSE - && win->_cury >= pminrow - && win->_curx >= pmincol - && win->_cury <= pmaxrow - && win->_curx <= pmaxcol) { - newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset; - newscr->_curx = win->_curx - pmincol + win->_begx; - } - newscr->_leaveok = win->_leaveok; - win->_flags &= ~_HASMOVED; - - /* - * Update our cache of the line-numbers that we displayed from the pad. - * We will use this on subsequent calls to this function to derive - * values to stuff into 'oldindex[]' -- for scrolling optimization. - */ - win->_pad._pad_y = pminrow; - win->_pad._pad_x = pmincol; - win->_pad._pad_top = sminrow; - win->_pad._pad_left = smincol; - win->_pad._pad_bottom = smaxrow; - win->_pad._pad_right = smaxcol; + if (pad == 0) + returnCode(ERR); - returnCode(OK); -} + if (!(pad->_flags & _ISPAD)) + returnCode(wechochar(pad, ch)); -int pechochar(WINDOW *pad, const chtype ch) -{ - T((T_CALLED("pechochar(%p, %s)"), pad, _tracechtype(ch))); - - if (pad == 0) - returnCode(ERR); - - if (!(pad->_flags & _ISPAD)) - returnCode(wechochar(pad,ch)); - - waddch(pad, ch); - prefresh(pad, pad->_pad._pad_y, - pad->_pad._pad_x, - pad->_pad._pad_top, - pad->_pad._pad_left, - pad->_pad._pad_bottom, - pad->_pad._pad_right); - - returnCode(OK); + waddch(pad, ch); + prefresh(pad, pad->_pad._pad_y, + pad->_pad._pad_x, + pad->_pad._pad_top, + pad->_pad._pad_left, + pad->_pad._pad_bottom, + pad->_pad._pad_right); + + returnCode(OK); } diff --git a/lib/libcurses/base/lib_refresh.c b/lib/libcurses/base/lib_refresh.c index 4d1b98cb968..4ae172db5f7 100644 --- a/lib/libcurses/base/lib_refresh.c +++ b/lib/libcurses/base/lib_refresh.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_refresh.c,v 1.2 1999/08/15 11:40:55 millert Exp $ */ +/* $OpenBSD: lib_refresh.c,v 1.3 2000/06/19 03:53:44 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* * lib_refresh.c * @@ -44,142 +42,144 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_refresh.c,v 1.24 1999/07/31 11:36:37 juergen Exp $") +MODULE_ID("$From: lib_refresh.c,v 1.25 2000/04/29 21:17:08 tom Exp $") -int wrefresh(WINDOW *win) +int +wrefresh(WINDOW *win) { -int code; - - T((T_CALLED("wrefresh(%p)"), win)); - - if (win == curscr) { - curscr->_clear = TRUE; - code = doupdate(); - } else if ((code = wnoutrefresh(win)) == OK) { - if (win->_clear) - newscr->_clear = TRUE; - code = doupdate(); - /* - * Reset the clearok() flag in case it was set for the special - * case in hardscroll.c (if we don't reset it here, we'll get 2 - * refreshes because the flag is copied from stdscr to newscr). - * Resetting the flag shouldn't do any harm, anyway. - */ - win->_clear = FALSE; - } - returnCode(code); -} - -int wnoutrefresh(WINDOW *win) -{ -short limit_x; -short i, j; -short begx; -short begy; -short m, n; -bool wide; - - T((T_CALLED("wnoutrefresh(%p)"), win)); -#ifdef TRACE - if (_nc_tracing & TRACE_UPDATE) - _tracedump("...win", win); -#endif /* TRACE */ - - /* - * This function will break badly if we try to refresh a pad. - */ - if ((win == 0) - || (win->_flags & _ISPAD)) - returnCode(ERR); + int code; - /* put them here so "win == 0" won't break our code */ - begx = win->_begx; - begy = win->_begy; - - newscr->_bkgd = win->_bkgd; - newscr->_attrs = win->_attrs; - - /* merge in change information from all subwindows of this window */ - wsyncdown(win); + T((T_CALLED("wrefresh(%p)"), win)); + if (win == curscr) { + curscr->_clear = TRUE; + code = doupdate(); + } else if ((code = wnoutrefresh(win)) == OK) { + if (win->_clear) + newscr->_clear = TRUE; + code = doupdate(); /* - * For pure efficiency, we'd want to transfer scrolling information - * from the window to newscr whenever the window is wide enough that - * its update will dominate the cost of the update for the horizontal - * band of newscr that it occupies. Unfortunately, this threshold - * tends to be complex to estimate, and in any case scrolling the - * whole band and rewriting the parts outside win's image would look - * really ugly. So. What we do is consider the window "wide" if it - * either (a) occupies the whole width of newscr, or (b) occupies - * all but at most one column on either vertical edge of the screen - * (this caters to fussy people who put boxes around full-screen - * windows). Note that changing this formula will not break any code, - * merely change the costs of various update cases. + * Reset the clearok() flag in case it was set for the special + * case in hardscroll.c (if we don't reset it here, we'll get 2 + * refreshes because the flag is copied from stdscr to newscr). + * Resetting the flag shouldn't do any harm, anyway. */ - wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1)); - - win->_flags &= ~_HASMOVED; + win->_clear = FALSE; + } + returnCode(code); +} - /* - * Microtweaking alert! This double loop is one of the genuine - * hot spots in the code. Even gcc doesn't seem to do enough - * common-subexpression chunking to make it really tense, - * so we'll force the issue. - */ +int +wnoutrefresh(WINDOW *win) +{ + NCURSES_SIZE_T limit_x; + NCURSES_SIZE_T i, j; + NCURSES_SIZE_T begx; + NCURSES_SIZE_T begy; + NCURSES_SIZE_T m, n; + bool wide; + + T((T_CALLED("wnoutrefresh(%p)"), win)); +#ifdef TRACE + if (_nc_tracing & TRACE_UPDATE) + _tracedump("...win", win); +#endif /* TRACE */ - /* limit(n) */ + /* + * This function will break badly if we try to refresh a pad. + */ + if ((win == 0) + || (win->_flags & _ISPAD)) + returnCode(ERR); + + /* put them here so "win == 0" won't break our code */ + begx = win->_begx; + begy = win->_begy; + + newscr->_bkgd = win->_bkgd; + newscr->_attrs = win->_attrs; + + /* merge in change information from all subwindows of this window */ + wsyncdown(win); + + /* + * For pure efficiency, we'd want to transfer scrolling information + * from the window to newscr whenever the window is wide enough that + * its update will dominate the cost of the update for the horizontal + * band of newscr that it occupies. Unfortunately, this threshold + * tends to be complex to estimate, and in any case scrolling the + * whole band and rewriting the parts outside win's image would look + * really ugly. So. What we do is consider the window "wide" if it + * either (a) occupies the whole width of newscr, or (b) occupies + * all but at most one column on either vertical edge of the screen + * (this caters to fussy people who put boxes around full-screen + * windows). Note that changing this formula will not break any code, + * merely change the costs of various update cases. + */ + wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1)); + + win->_flags &= ~_HASMOVED; + + /* + * Microtweaking alert! This double loop is one of the genuine + * hot spots in the code. Even gcc doesn't seem to do enough + * common-subexpression chunking to make it really tense, + * so we'll force the issue. + */ + + /* limit(n) */ + limit_x = win->_maxx; + /* limit(j) */ + if (limit_x > win->_maxx) limit_x = win->_maxx; - /* limit(j) */ - if (limit_x > win->_maxx) - limit_x = win->_maxx; - - for (i = 0, m = begy + win->_yoffset; - i <= win->_maxy && m <= newscr->_maxy; - i++, m++) { - register struct ldat *nline = &newscr->_line[m]; - register struct ldat *oline = &win->_line[i]; - if (oline->firstchar != _NOCHANGE) { - int last = oline->lastchar; + for (i = 0, m = begy + win->_yoffset; + i <= win->_maxy && m <= newscr->_maxy; + i++, m++) { + register struct ldat *nline = &newscr->_line[m]; + register struct ldat *oline = &win->_line[i]; - if (last > limit_x) - last = limit_x; + if (oline->firstchar != _NOCHANGE) { + int last = oline->lastchar; - for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) { - if (oline->text[j] != nline->text[n]) { - nline->text[n] = oline->text[j]; - CHANGED_CELL(nline, n); - } - } + if (last > limit_x) + last = limit_x; + for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) { + if (oline->text[j] != nline->text[n]) { + nline->text[n] = oline->text[j]; + CHANGED_CELL(nline, n); } + } + } #if USE_SCROLL_HINTS - if (wide) { - int oind = oline->oldindex; + if (wide) { + int oind = oline->oldindex; - nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind + win->_yoffset; - } + nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind + + win->_yoffset; + } #endif /* USE_SCROLL_HINTS */ - oline->firstchar = oline->lastchar = _NOCHANGE; - if_USE_SCROLL_HINTS(oline->oldindex = i); - } + oline->firstchar = oline->lastchar = _NOCHANGE; + if_USE_SCROLL_HINTS(oline->oldindex = i); + } - if (win->_clear) { - win->_clear = FALSE; - newscr->_clear = TRUE; - } + if (win->_clear) { + win->_clear = FALSE; + newscr->_clear = TRUE; + } + + if (!win->_leaveok) { + newscr->_cury = win->_cury + win->_begy + win->_yoffset; + newscr->_curx = win->_curx + win->_begx; + } + newscr->_leaveok = win->_leaveok; - if (! win->_leaveok) { - newscr->_cury = win->_cury + win->_begy + win->_yoffset; - newscr->_curx = win->_curx + win->_begx; - } - newscr->_leaveok = win->_leaveok; - #ifdef TRACE - if (_nc_tracing & TRACE_UPDATE) - _tracedump("newscr", newscr); + if (_nc_tracing & TRACE_UPDATE) + _tracedump("newscr", newscr); #endif /* TRACE */ - returnCode(OK); + returnCode(OK); } diff --git a/lib/libcurses/base/lib_scroll.c b/lib/libcurses/base/lib_scroll.c index 2742c911734..511ca93850a 100644 --- a/lib/libcurses/base/lib_scroll.c +++ b/lib/libcurses/base/lib_scroll.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_scroll.c,v 1.1 1999/01/18 19:09:58 millert Exp $ */ +/* $OpenBSD: lib_scroll.c,v 1.2 2000/06/19 03:53:45 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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* ** lib_scroll.c ** @@ -46,75 +44,79 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_scroll.c,v 1.16 1998/02/11 12:13:55 tom Exp $") +MODULE_ID("$From: lib_scroll.c,v 1.17 2000/04/29 21:10:51 tom Exp $") -void _nc_scroll_window(WINDOW *win, int const n, short const top, short const bottom, chtype blank) +void +_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top, + NCURSES_SIZE_T const bottom, chtype blank) { -int line, j; -size_t to_copy = (size_t)(sizeof(chtype) * (win->_maxx + 1)); - - TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top,bottom)); - - /* - * This used to do a line-text pointer-shuffle instead of text copies. - * That (a) doesn't work when the window is derived and doesn't have - * its own storage, (b) doesn't save you a lot on modern machines - * anyway. Your typical memcpy implementations are coded in - * assembler using a tight BLT loop; for the size of copies we're - * talking here, the total execution time is dominated by the one-time - * setup cost. So there is no point in trying to be excessively - * clever -- esr. - */ - - /* shift n lines downwards */ - if (n < 0) { - for (line = bottom; line >= top-n; line--) { - memcpy(win->_line[line].text, - win->_line[line+n].text, - to_copy); - if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex); - } - for (line = top; line < top-n; line++) { - for (j = 0; j <= win->_maxx; j ++) - win->_line[line].text[j] = blank; - if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); - } - } - - /* shift n lines upwards */ - if (n > 0) { - for (line = top; line <= bottom-n; line++) { - memcpy(win->_line[line].text, - win->_line[line+n].text, - to_copy); - if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex); - } - for (line = bottom; line > bottom-n; line--) { - for (j = 0; j <= win->_maxx; j ++) - win->_line[line].text[j] = blank; - if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); - } + int line, j; + size_t to_copy = (size_t) (sizeof(chtype) * (win->_maxx + 1)); + + TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top, bottom)); + + /* + * This used to do a line-text pointer-shuffle instead of text copies. + * That (a) doesn't work when the window is derived and doesn't have + * its own storage, (b) doesn't save you a lot on modern machines + * anyway. Your typical memcpy implementations are coded in + * assembler using a tight BLT loop; for the size of copies we're + * talking here, the total execution time is dominated by the one-time + * setup cost. So there is no point in trying to be excessively + * clever -- esr. + */ + + /* shift n lines downwards */ + if (n < 0) { + for (line = bottom; line >= top - n; line--) { + memcpy(win->_line[line].text, + win->_line[line + n].text, + to_copy); + if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line + + n].oldindex); + } + for (line = top; line < top - n; line++) { + for (j = 0; j <= win->_maxx; j++) + win->_line[line].text[j] = blank; + if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); + } + } + + /* shift n lines upwards */ + if (n > 0) { + for (line = top; line <= bottom - n; line++) { + memcpy(win->_line[line].text, + win->_line[line + n].text, + to_copy); + if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line + + n].oldindex); + } + for (line = bottom; line > bottom - n; line--) { + for (j = 0; j <= win->_maxx; j++) + win->_line[line].text[j] = blank; + if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX); } - touchline(win, top, bottom-top+1); + } + touchline(win, top, bottom - top + 1); } int wscrl(WINDOW *win, int n) { - T((T_CALLED("wscrl(%p,%d)"), win, n)); + T((T_CALLED("wscrl(%p,%d)"), win, n)); - if (!win || !win->_scroll) - returnCode(ERR); + if (!win || !win->_scroll) + returnCode(ERR); - if (n == 0) - returnCode(OK); + if (n == 0) + returnCode(OK); - if ((n > (win->_regbottom - win->_regtop)) || - (-n > (win->_regbottom - win->_regtop))) - returnCode(ERR); + if ((n > (win->_regbottom - win->_regtop)) || + (-n > (win->_regbottom - win->_regtop))) + returnCode(ERR); - _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win)); + _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win)); - _nc_synchook(win); - returnCode(OK); + _nc_synchook(win); + returnCode(OK); } diff --git a/lib/libcurses/base/lib_scrreg.c b/lib/libcurses/base/lib_scrreg.c index 42a822b5a0d..0ee5b425137 100644 --- a/lib/libcurses/base/lib_scrreg.c +++ b/lib/libcurses/base/lib_scrreg.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_scrreg.c,v 1.1 1999/01/18 19:09:58 millert Exp $ */ +/* $OpenBSD: lib_scrreg.c,v 1.2 2000/06/19 03:53:45 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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* ** lib_scrreg.c ** @@ -44,21 +42,21 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_scrreg.c,v 1.7 1998/02/11 12:13:53 tom Exp $") +MODULE_ID("$From: lib_scrreg.c,v 1.8 2000/04/29 21:13:04 tom Exp $") -int wsetscrreg(WINDOW *win, int top, int bottom) +int +wsetscrreg(WINDOW *win, int top, int bottom) { - T((T_CALLED("wsetscrreg(%p,%d,%d)"), win, top, bottom)); - - if (win && - top >= 0 && top <= win->_maxy && - bottom >= 0 && bottom <= win->_maxy && - bottom > top) - { - win->_regtop = (short)top; - win->_regbottom = (short)bottom; - - returnCode(OK); - } else - returnCode(ERR); + T((T_CALLED("wsetscrreg(%p,%d,%d)"), win, top, bottom)); + + if (win && + top >= 0 && top <= win->_maxy && + bottom >= 0 && bottom <= win->_maxy && + bottom > top) { + win->_regtop = (NCURSES_SIZE_T) top; + win->_regbottom = (NCURSES_SIZE_T) bottom; + + returnCode(OK); + } else + returnCode(ERR); } diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c index 014e43a85f3..1faa7d53fd1 100644 --- a/lib/libcurses/base/lib_set_term.c +++ b/lib/libcurses/base/lib_set_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_set_term.c,v 1.8 2000/03/26 16:45:03 millert Exp $ */ +/* $OpenBSD: lib_set_term.c,v 1.9 2000/06/19 03:53:46 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -45,7 +45,7 @@ #include <term.h> /* cur_term */ #include <tic.h> -MODULE_ID("$From: lib_set_term.c,v 1.51 2000/03/26 01:03:36 tom Exp $") +MODULE_ID("$From: lib_set_term.c,v 1.52 2000/05/27 23:22:36 tom Exp $"); SCREEN * set_term(SCREEN * screenp) @@ -111,6 +111,18 @@ delscreen(SCREEN * sp) 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 + * for other reasons than trying to operate upon a closed stream. + */ + if (sp->_ofp != 0 + && sp->_setbuf != 0 + && fflush(sp->_ofp) != 0 + && errno == EBADF) { + free(sp->_setbuf); + } + free(sp); /* diff --git a/lib/libcurses/base/lib_vline.c b/lib/libcurses/base/lib_vline.c index a36969418d0..7f1a9a09bb2 100644 --- a/lib/libcurses/base/lib_vline.c +++ b/lib/libcurses/base/lib_vline.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_vline.c,v 1.1 1999/01/18 19:10:05 millert Exp $ */ +/* $OpenBSD: lib_vline.c,v 1.2 2000/06/19 03:53:46 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,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,8 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - - /* ** lib_vline.c ** @@ -44,36 +42,37 @@ #include <curses.priv.h> -MODULE_ID("$From: lib_vline.c,v 1.4 1998/06/28 00:10:12 tom Exp $") +MODULE_ID("$From: lib_vline.c,v 1.5 2000/04/29 21:14:11 tom Exp $") -int wvline(WINDOW *win, chtype ch, int n) +int +wvline(WINDOW *win, chtype ch, int n) { -int code = ERR; -short row, col; -short end; + int code = ERR; + NCURSES_SIZE_T row, col; + NCURSES_SIZE_T end; - T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n)); + T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n)); - if (win) { - row = win->_cury; - col = win->_curx; - end = row + n - 1; - if (end > win->_maxy) - end = win->_maxy; + if (win) { + row = win->_cury; + col = win->_curx; + end = row + n - 1; + if (end > win->_maxy) + end = win->_maxy; - if (ch == 0) - ch = ACS_VLINE; - ch = _nc_render(win, ch); + if (ch == 0) + ch = ACS_VLINE; + ch = _nc_render(win, ch); - while(end >= row) { - struct ldat *line = &(win->_line[end]); - line->text[col] = ch; - CHANGED_CELL(line, col); - end--; - } - - _nc_synchook(win); - code = OK; + while (end >= row) { + struct ldat *line = &(win->_line[end]); + line->text[col] = ch; + CHANGED_CELL(line, col); + end--; } - returnCode(code); + + _nc_synchook(win); + code = OK; + } + returnCode(code); } diff --git a/lib/libcurses/curs_getch.3tbl b/lib/libcurses/curs_getch.3tbl index 5fda56239ab..01ba828fc1e 100644 --- a/lib/libcurses/curs_getch.3tbl +++ b/lib/libcurses/curs_getch.3tbl @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: curs_getch.3tbl,v 1.7 1999/01/18 19:07:12 millert Exp $ +.\" $OpenBSD: curs_getch.3tbl,v 1.8 2000/06/19 03:53:34 millert Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998 Free Software Foundation, Inc. * @@ -29,7 +29,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $From: curs_getch.3x,v 1.15 1998/11/29 01:04:26 Rick.Ohnemus Exp $ +.\" $From: curs_getch.3x,v 1.16 2000/05/27 22:48:05 tom Exp $ .TH curs_getch 3 "" .SH NAME \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR, @@ -59,7 +59,7 @@ this is after one character (cbreak mode), or after the first newline (nocbreak mode). In half-delay mode, the program waits until a character is typed or the specified timeout has been reached. -If \fBnoecho\fR has been set, then the character will also be echoed into the +Unless \fBnoecho\fR has been set, then the character will also be echoed into the designated window according to the following rules: If the character is the current erase character, left arrow, or backspace, the cursor is moved one space to the left and that screen position is erased diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index 9b009f27796..6fae487222c 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.h,v 1.50 2000/04/04 16:49:58 millert Exp $ */ +/* $OpenBSD: curses.h,v 1.51 2000/06/19 03:53:35 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -33,7 +33,7 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ -/* $From: curses.h.in,v 1.90 2000/02/19 22:15:43 tom Exp $ */ +/* $From: curses.h.in,v 1.92 2000/04/29 18:52:53 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H @@ -50,7 +50,7 @@ /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 5 #define NCURSES_VERSION_MINOR 0 -#define NCURSES_VERSION_PATCH 20000401 +#define NCURSES_VERSION_PATCH 20000617 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION @@ -67,6 +67,12 @@ #undef NCURSES_CONST #define NCURSES_CONST +#undef NCURSES_COLOR_T +#define NCURSES_COLOR_T short + +#undef NCURSES_SIZE_T +#define NCURSES_SIZE_T short + typedef unsigned long chtype; #include <stdio.h> @@ -247,18 +253,18 @@ cchar_t; struct ldat { chtype *text; /* text of the line */ - short firstchar; /* first changed character in the line */ - short lastchar; /* last changed character in the line */ - short oldindex; /* index of the line at last update */ + NCURSES_SIZE_T firstchar; /* first changed character in the line */ + NCURSES_SIZE_T lastchar; /* last changed character in the line */ + NCURSES_SIZE_T oldindex; /* index of the line at last update */ }; struct _win_st { - short _cury, _curx; /* current cursor position */ + NCURSES_SIZE_T _cury, _curx; /* current cursor position */ /* window location and size */ - short _maxy, _maxx; /* maximums of x and y, NOT window size */ - short _begy, _begx; /* screen coords of upper-left-hand corner */ + NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ + NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ short _flags; /* window state flags */ @@ -281,8 +287,8 @@ struct _win_st struct ldat *_line; /* the actual line data */ /* global screen state */ - short _regtop; /* top line of scrolling region */ - short _regbottom; /* bottom line of scrolling region */ + NCURSES_SIZE_T _regtop; /* top line of scrolling region */ + NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ /* these are used only if this is a sub-window */ int _parx; /* x coordinate of this window in parent */ @@ -292,12 +298,12 @@ struct _win_st /* these are used only if this is a pad */ struct pdat { - short _pad_y, _pad_x; - short _pad_top, _pad_left; - short _pad_bottom, _pad_right; + NCURSES_SIZE_T _pad_y, _pad_x; + NCURSES_SIZE_T _pad_top, _pad_left; + NCURSES_SIZE_T _pad_bottom, _pad_right; } _pad; - short _yoffset; /* real begy is _begy + _yoffset */ + NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ }; extern WINDOW *stdscr; @@ -952,7 +958,7 @@ extern bool mouse_trafo(int*, int*, bool); /* generated */ #define winchstr(w, s) winchnstr(w, s, -1) #define winsstr(w, s) winsnstr(w, s, -1) -#define redrawwin(w) wredrawln(w, 0, w->_maxy+1) +#define redrawwin(win) wredrawln(win, 0, (win)->_maxy+1) #define waddstr(win,str) waddnstr(win,str,-1) #define waddchstr(win,str) waddchnstr(win,str,-1) diff --git a/lib/libcurses/curses.priv.h b/lib/libcurses/curses.priv.h index 595591c027f..1fcb7103d8f 100644 --- a/lib/libcurses/curses.priv.h +++ b/lib/libcurses/curses.priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.priv.h,v 1.26 2000/03/26 16:45:03 millert Exp $ */ +/* $OpenBSD: curses.priv.h,v 1.27 2000/06/19 03:53:35 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -35,7 +35,7 @@ /* - * $From: curses.priv.h,v 1.157 2000/03/26 01:01:14 tom Exp $ + * $From: curses.priv.h,v 1.161 2000/05/27 23:10:03 tom Exp $ * * curses.priv.h * @@ -402,6 +402,7 @@ struct screen { unsigned long *oldhash, *newhash; bool _cleanup; /* cleanup after int/quit signal */ + int (*_outch)(int); /* output handler if not putc */ }; extern SCREEN *_nc_screen_chain; @@ -505,10 +506,6 @@ typedef struct { #define SIZEOF(v) (sizeof(v)/sizeof(v[0])) -#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type)) -#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type)) -#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type)) - #define FreeIfNeeded(p) if ((p) != 0) free(p) /* FreeAndNull() is not a comma-separated expression because some compilers @@ -654,13 +651,6 @@ extern void _nc_expanded(void); #define getcwd(buf,len) getwd(buf) #endif -/* doalloc.c */ -extern void *_nc_doalloc(void *, size_t); -#if !HAVE_STRDUP -#define strdup _nc_strdup -extern char *_nc_strdup(const char *); -#endif - /* doupdate.c */ #if USE_XMC_SUPPORT extern void _nc_do_xmc_glitch(attr_t); @@ -727,11 +717,12 @@ extern void _nc_hash_map(void); extern void _nc_init_keytry(void); extern void _nc_keep_tic_dir(const char *); extern void _nc_make_oldhash(int i); +extern void _nc_flush(void); extern void _nc_outstr(const char *str); extern void _nc_scroll_oldhash(int n, int top, int bot); extern void _nc_scroll_optimize(void); extern void _nc_scroll_window(WINDOW *, int const, short const, short const, chtype); -extern void _nc_set_buffer(FILE *ofp, bool buffered); +extern void _nc_set_buffer(FILE *, bool); extern void _nc_signal_handler(bool); extern void _nc_synchook(WINDOW *win); extern void _nc_trace_tries(struct tries *tree); @@ -740,6 +731,10 @@ extern void _nc_trace_tries(struct tries *tree); extern void _nc_update_screensize(void); #endif +#ifdef USE_WIDEC_SUPPORT +extern int _nc_utf8_outch(int); +#endif + /* scroll indices */ extern int *_nc_oldnums; @@ -750,7 +745,6 @@ extern int *_nc_oldnums; _nc_set_buffer(SP->_ofp, flag) #define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout) -#define _nc_flush() (void)fflush(NC_OUTPUT) /* * On systems with a broken linker, define 'SP' as a function to force the diff --git a/lib/libcurses/doc/ncurses-intro.html b/lib/libcurses/doc/ncurses-intro.html index 12975986fc4..c16ecdd19bc 100644 --- a/lib/libcurses/doc/ncurses-intro.html +++ b/lib/libcurses/doc/ncurses-intro.html @@ -1,6 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN"> <!-- - $From: ncurses-intro.html,v 1.33 2000/03/05 01:06:43 tom Exp $ + $From: ncurses-intro.html,v 1.34 2000/06/11 00:03:55 tom Exp $ --> <HTML> <HEAD> @@ -225,7 +225,7 @@ and wrote most of this introduction. wrote all of the menu and forms code as well as the <A HREF="http://www.adahome.com">Ada95</A> binding. Ongoing work is being done by -<A HREF="mailto:dickey@clark.net">Thomas Dickey</A> +<A HREF="mailto:dickey@herndon4.his.com">Thomas Dickey</A> and <A HREF="mailto:juergen.pfeifer@gmx.net">Jürgen Pfeifer</A>. <A HREF="mailto:florian@gnu.org">Florian La Roche</A> diff --git a/lib/libcurses/nc_alloc.h b/lib/libcurses/nc_alloc.h index f9b6c1e970a..525a0850e0d 100644 --- a/lib/libcurses/nc_alloc.h +++ b/lib/libcurses/nc_alloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nc_alloc.h,v 1.5 1999/05/08 20:28:58 millert Exp $ */ +/* $OpenBSD: nc_alloc.h,v 1.6 2000/06/19 03:53:36 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -31,7 +31,7 @@ /**************************************************************************** * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 * ****************************************************************************/ -/* $From: nc_alloc.h,v 1.7 1999/04/03 23:15:13 tom Exp $ */ +/* $From: nc_alloc.h,v 1.8 2000/04/08 23:42:57 tom Exp $ */ #ifndef NC_ALLOC_included #define NC_ALLOC_included 1 @@ -71,4 +71,15 @@ extern void _nc_leaks_dump_entry(void); #define ExitProgram(code) return code #endif +/* doalloc.c */ +extern void *_nc_doalloc(void *, size_t); +#if !HAVE_STRDUP +#define strdup _nc_strdup +extern char *_nc_strdup(const char *); +#endif + +#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type)) +#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type)) +#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type)) + #endif /* NC_ALLOC_included */ diff --git a/lib/libcurses/ncurses_cfg.h b/lib/libcurses/ncurses_cfg.h index 825a86ed236..9bb5eecfcd6 100644 --- a/lib/libcurses/ncurses_cfg.h +++ b/lib/libcurses/ncurses_cfg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ncurses_cfg.h,v 1.18 2000/03/10 01:35:01 millert Exp $ */ +/* $OpenBSD: ncurses_cfg.h,v 1.19 2000/06/19 03:53:36 millert Exp $ */ /* include/ncurses_cfg.h. Generated automatically by configure. */ /**************************************************************************** @@ -118,7 +118,7 @@ /* #define PURE_TERMINFO 1 */ #define RETSIGTYPE void #define STDC_HEADERS 1 -#define SYSTEM_NAME "openbsd2.6" +#define SYSTEM_NAME "openbsd2.7" #define TERMINFO_DIRS "/usr/share/terminfo" #define TYPEOF_CHTYPE long #define USE_DATABASE 1 diff --git a/lib/libcurses/terminfo.5tbl b/lib/libcurses/terminfo.5tbl index f12d171a732..b7834e70a77 100644 --- a/lib/libcurses/terminfo.5tbl +++ b/lib/libcurses/terminfo.5tbl @@ -33,7 +33,7 @@ .\"*************************************************************************** .\" .\" $From: terminfo.head,v 1.8 1998/03/11 21:12:53 juergen Exp $ -.\" $OpenBSD: terminfo.5tbl,v 1.7 2000/03/13 23:53:39 millert Exp $ +.\" $OpenBSD: terminfo.5tbl,v 1.8 2000/06/19 03:53:36 millert Exp $ .TH TERMINFO 5 "" "" "File Formats" .ds n 5 .ds d /usr/share/terminfo @@ -1623,7 +1623,7 @@ YI Set page length to #1 hundredth of an inch T} .TE .ad -.\" $From: terminfo.tail,v 1.31 2000/03/12 00:36:41 tom Exp $ +.\" $From: terminfo.tail,v 1.32 2000/04/15 20:04:58 tom Exp $ .\" Beginning of terminfo.tail file .ps +1 .PP @@ -1935,7 +1935,8 @@ The \fB%\fR encodings have the following meanings: \s-1%% outputs `%' %\fI[[\fP:\fI]flags][width[.precision]][\fPdoxXs\fI]\fP as in \fBprintf\fP, flags are [-+#] and space - %c print pop() gives %c + %c print pop() like %c in printf() + %s print pop() like %s in printf() %p[1-9] push \fIi\fP'th parm %P[a-z] set dynamic variable [a-z] to pop() @@ -1952,7 +1953,7 @@ The \fB%\fR encodings have the following meanings: %= %> %< logical operations: push(pop() op pop()) %A, %O logical and & or operations (for conditionals) %! %~ unary operations push(op pop()) - %i add 1 to first two parms (for ANSI terminals) + %i add 1 to first two parameters (for ANSI terminals) %? expr %t thenpart %e elsepart %; if-then-else, %e elsepart is optional. diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c index 9f0afdef140..731d0b5724d 100644 --- a/lib/libcurses/tinfo/comp_parse.c +++ b/lib/libcurses/tinfo/comp_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_parse.c,v 1.6 2000/03/26 16:45:03 millert Exp $ */ +/* $OpenBSD: comp_parse.c,v 1.7 2000/06/19 03:53:48 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -54,7 +54,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$From: comp_parse.c,v 1.39 2000/03/25 17:07:30 tom Exp $") +MODULE_ID("$From: comp_parse.c,v 1.40 2000/04/15 16:57:08 tom Exp $") static void sanity_check(TERMTYPE *); void (*_nc_check_termtype) (TERMTYPE *) = sanity_check; @@ -461,26 +461,26 @@ sanity_check(TERMTYPE * tp) } /* listed in structure-member order of first argument */ - PAIRED(enter_alt_charset_mode, exit_alt_charset_mode) - ANDMISSING(enter_alt_charset_mode, acs_chars) - ANDMISSING(exit_alt_charset_mode, acs_chars) - ANDMISSING(enter_blink_mode, exit_attribute_mode) - ANDMISSING(enter_bold_mode, exit_attribute_mode) - PAIRED(exit_ca_mode, enter_ca_mode) - PAIRED(enter_delete_mode, exit_delete_mode) - ANDMISSING(enter_dim_mode, exit_attribute_mode) - PAIRED(enter_insert_mode, exit_insert_mode) - ANDMISSING(enter_secure_mode, exit_attribute_mode) - ANDMISSING(enter_protected_mode, exit_attribute_mode) - ANDMISSING(enter_reverse_mode, exit_attribute_mode) - PAIRED(from_status_line, to_status_line) - PAIRED(meta_off, meta_on) - - PAIRED(prtr_on, prtr_off) - PAIRED(save_cursor, restore_cursor) - PAIRED(enter_xon_mode, exit_xon_mode) - PAIRED(enter_am_mode, exit_am_mode) - ANDMISSING(label_off, label_on) - PAIRED(display_clock, remove_clock) - ANDMISSING(set_color_pair, initialize_pair) + PAIRED(enter_alt_charset_mode, exit_alt_charset_mode); + ANDMISSING(enter_alt_charset_mode, acs_chars); + ANDMISSING(exit_alt_charset_mode, acs_chars); + ANDMISSING(enter_blink_mode, exit_attribute_mode); + ANDMISSING(enter_bold_mode, exit_attribute_mode); + PAIRED(exit_ca_mode, enter_ca_mode); + PAIRED(enter_delete_mode, exit_delete_mode); + ANDMISSING(enter_dim_mode, exit_attribute_mode); + PAIRED(enter_insert_mode, exit_insert_mode); + ANDMISSING(enter_secure_mode, exit_attribute_mode); + ANDMISSING(enter_protected_mode, exit_attribute_mode); + ANDMISSING(enter_reverse_mode, exit_attribute_mode); + PAIRED(from_status_line, to_status_line); + PAIRED(meta_off, meta_on); + + PAIRED(prtr_on, prtr_off); + PAIRED(save_cursor, restore_cursor); + PAIRED(enter_xon_mode, exit_xon_mode); + PAIRED(enter_am_mode, exit_am_mode); + ANDMISSING(label_off, label_on); + PAIRED(display_clock, remove_clock); + ANDMISSING(set_color_pair, initialize_pair); } diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c index d2b7b78ecb8..77ac5d3043c 100644 --- a/lib/libcurses/tinfo/comp_scan.c +++ b/lib/libcurses/tinfo/comp_scan.c @@ -50,7 +50,7 @@ #include <term_entry.h> #include <tic.h> -MODULE_ID("$From: comp_scan.c,v 1.42 2000/04/01 19:08:36 tom Exp $") +MODULE_ID("$From: comp_scan.c,v 1.44 2000/06/10 21:59:21 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -66,6 +66,9 @@ long _nc_comment_start = 0; /* start of comment range before name */ long _nc_comment_end = 0; /* end of comment range before name */ long _nc_start_line = 0; /* start line of current entry */ +struct token _nc_curr_token = +{0, 0, 0}; + /***************************************************************************** * * Token-grabbing machinery @@ -472,6 +475,8 @@ _nc_trans_string(char *ptr, char *last) } if (ch == '?') { *(ptr++) = '\177'; + if (_nc_tracing) + _nc_warning("Allow ^? as synonym for \\177"); } else { if ((ch &= 037) == 0) ch = 128; diff --git a/lib/libcurses/tinfo/lib_napms.c b/lib/libcurses/tinfo/lib_napms.c index 90001b03b50..de4f97efce7 100644 --- a/lib/libcurses/tinfo/lib_napms.c +++ b/lib/libcurses/tinfo/lib_napms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_napms.c,v 1.5 2000/03/10 01:35:03 millert Exp $ */ +/* $OpenBSD: lib_napms.c,v 1.6 2000/06/19 03:53:50 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -33,7 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - /* * lib_napms.c * @@ -45,6 +44,9 @@ #if HAVE_NANOSLEEP #include <time.h> +#if HAVE_SYS_TIME_H +#include <sys/time.h> /* needed for MacOS X DP3 */ +#endif #elif USE_FUNC_POLL #if HAVE_SYS_TIME_H #include <sys/time.h> @@ -58,31 +60,32 @@ #endif #endif -MODULE_ID("$From: lib_napms.c,v 1.8 2000/02/13 01:01:26 tom Exp $") +MODULE_ID("$From: lib_napms.c,v 1.9 2000/04/29 23:42:56 tom Exp $") -int napms(int ms) +int +napms(int ms) { - T((T_CALLED("napms(%d)"), ms)); + T((T_CALLED("napms(%d)"), ms)); #if HAVE_NANOSLEEP - { - struct timespec ts; - ts.tv_sec = ms / 1000; - ts.tv_nsec = (ms % 1000) * 1000000; - nanosleep(&ts, NULL); - } + { + struct timespec ts; + ts.tv_sec = ms / 1000; + ts.tv_nsec = (ms % 1000) * 1000000; + nanosleep(&ts, NULL); + } #elif USE_FUNC_POLL - { - struct pollfd fds[1]; - poll(fds, 0, ms); - } + { + struct pollfd fds[1]; + poll(fds, 0, ms); + } #elif HAVE_SELECT - { - struct timeval tval; - tval.tv_sec = ms / 1000; - tval.tv_usec = (ms % 1000) * 1000; - select(0, NULL, NULL, NULL, &tval); - } + { + struct timeval tval; + tval.tv_sec = ms / 1000; + tval.tv_usec = (ms % 1000) * 1000; + select(0, NULL, NULL, NULL, &tval); + } #endif - returnCode(OK); + returnCode(OK); } diff --git a/lib/libcurses/tinfo/lib_tputs.c b/lib/libcurses/tinfo/lib_tputs.c index 7bed4f9cdb8..4a5aa118864 100644 --- a/lib/libcurses/tinfo/lib_tputs.c +++ b/lib/libcurses/tinfo/lib_tputs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tputs.c,v 1.5 2000/03/10 01:35:04 millert Exp $ */ +/* $OpenBSD: lib_tputs.c,v 1.6 2000/06/19 03:53:50 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -47,7 +47,7 @@ #include <termcap.h> /* ospeed */ #include <tic.h> -MODULE_ID("$From: lib_tputs.c,v 1.45 2000/02/27 02:33:24 tom Exp $") +MODULE_ID("$From: lib_tputs.c,v 1.47 2000/05/27 23:08:41 tom Exp $") char PC = 0; /* used by termcap library */ speed_t ospeed = 0; /* used by termcap library */ @@ -77,6 +77,12 @@ delay_output(int ms) returnCode(OK); } +void +_nc_flush(void) +{ + (void)fflush(NC_OUTPUT); +} + int _nc_outch(int ch) { @@ -98,6 +104,66 @@ _nc_outch(int ch) return OK; } +#ifdef USE_WIDEC_SUPPORT +/* + * Reference: The Unicode Standard 2.0 + * + * No surrogates supported (we're storing only one 16-bit Unicode value per + * cell). + */ +int +_nc_utf8_outch(int ch) +{ + static const unsigned byteMask = 0xBF; + static const unsigned otherMark = 0x80; + static const unsigned firstMark[] = + {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; + + int result[7], *ptr; + int count = 0; + + if (ch < 0x80) + count = 1; + else if (ch < 0x800) + count = 2; + else if (ch < 0x10000) + count = 3; + else if (ch < 0x200000) + count = 4; + else if (ch < 0x4000000) + count = 5; + else if (ch <= 0x7FFFFFFF) + count = 6; + else { + count = 2; + ch = 0xFFFD; + } + ptr = result + count; + switch (count) { + case 6: + *--ptr = (ch | otherMark) & byteMask; + ch >>= 6; + case 5: + *--ptr = (ch | otherMark) & byteMask; + ch >>= 6; + case 4: + *--ptr = (ch | otherMark) & byteMask; + ch >>= 6; + case 3: + *--ptr = (ch | otherMark) & byteMask; + ch >>= 6; + case 2: + *--ptr = (ch | otherMark) & byteMask; + ch >>= 6; + case 1: + *--ptr = (ch | firstMark[count]); + } + while (count--) + _nc_outch(*ptr++); + return OK; +} +#endif + int putp(const char *string) { diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c index 3f03844dc48..9ee99320357 100644 --- a/lib/libcurses/tinfo/parse_entry.c +++ b/lib/libcurses/tinfo/parse_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_entry.c,v 1.6 2000/03/13 23:53:40 millert Exp $ */ +/* $OpenBSD: parse_entry.c,v 1.7 2000/06/19 03:53:51 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -49,7 +49,7 @@ #define __INTERNAL_CAPS_VISIBLE #include <term_entry.h> -MODULE_ID("$From: parse_entry.c,v 1.43 2000/03/12 00:09:06 tom Exp $") +MODULE_ID("$From: parse_entry.c,v 1.44 2000/04/30 00:17:42 tom Exp $") #ifdef LINT static short const parametrized[] = @@ -58,9 +58,6 @@ static short const parametrized[] = #include <parametrized.h> #endif -struct token _nc_curr_token = -{0, 0, 0}; - static void postprocess_termcap(TERMTYPE *, bool); static void postprocess_terminfo(TERMTYPE *); static struct name_table_entry const *lookup_fullname(const char *name); diff --git a/lib/libcurses/tinfo/read_termcap.c b/lib/libcurses/tinfo/read_termcap.c index 37fb06dc3a9..68592645c60 100644 --- a/lib/libcurses/tinfo/read_termcap.c +++ b/lib/libcurses/tinfo/read_termcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read_termcap.c,v 1.8 2000/04/14 19:14:02 millert Exp $ */ +/* $OpenBSD: read_termcap.c,v 1.9 2000/06/19 03:53:52 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -57,7 +57,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$From: read_termcap.c,v 1.46 2000/03/18 21:53:26 tom Exp $") +MODULE_ID("$From: read_termcap.c,v 1.47 2000/04/15 16:53:19 Todd.C.Miller Exp $") #ifndef PURE_TERMINFO @@ -925,9 +925,9 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp) static char *source; static int lineno; - if (!issetugid() && (p = getenv("TERMCAP")) != 0 && !is_pathname(p) && - _nc_name_match(p, tn, "|:")) { - + if (!issetugid() && (p = getenv("TERMCAP")) != 0 + && !is_pathname(p) && _nc_name_match(p, tn, "|:")) { + /* TERMCAP holds a termcap entry */ strlcpy(tc, p, sizeof(tc)); _nc_set_source("TERMCAP"); } else { diff --git a/lib/libcurses/tty/lib_mvcur.c b/lib/libcurses/tty/lib_mvcur.c index 9fbab4a5108..a24ab8ff3e4 100644 --- a/lib/libcurses/tty/lib_mvcur.c +++ b/lib/libcurses/tty/lib_mvcur.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_mvcur.c,v 1.6 2000/03/10 01:35:05 millert Exp $ */ +/* $OpenBSD: lib_mvcur.c,v 1.7 2000/06/19 03:53:53 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -154,7 +154,7 @@ #include <term.h> #include <ctype.h> -MODULE_ID("$From: lib_mvcur.c,v 1.63 2000/02/13 01:02:34 tom Exp $") +MODULE_ID("$From: lib_mvcur.c,v 1.64 2000/05/14 01:25:28 tom Exp $") #define STRLEN(s) (s != 0) ? strlen(s) : 0 @@ -774,7 +774,7 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw) /* tactic #4: use home-down + local movement */ if (cursor_to_ll && ((newcost = relative_move(NULL, screen_lines - 1, 0, ynew, xnew, - ovw)) != INFINITY) + ovw)) != INFINITY) && SP->_ll_cost + newcost < usecost) { tactic = 4; usecost = SP->_ll_cost + newcost; @@ -797,29 +797,33 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw) /* * These cases are ordered by estimated relative frequency. */ - if (tactic) { - if (tactic == 1) - (void) relative_move(use, yold, xold, ynew, xnew, ovw); - else if (tactic == 2) { - (void) strcpy(use, carriage_return); - (void) relative_move(use + SP->_carriage_return_length, - yold, 0, ynew, xnew, ovw); - } else if (tactic == 3) { - (void) strcpy(use, cursor_home); - (void) relative_move(use + SP->_cursor_home_length, - 0, 0, ynew, xnew, ovw); - } else if (tactic == 4) { - (void) strcpy(use, cursor_to_ll); - (void) relative_move(use + SP->_cursor_to_ll_length, - screen_lines - 1, 0, ynew, xnew, ovw); - } else { /* if (tactic == 5) */ - use[0] = '\0'; - if (xold > 0) - (void) strcat(use, carriage_return); - (void) strcat(use, cursor_left); - (void) relative_move(use + strlen(use), - yold - 1, screen_columns - 1, ynew, xnew, ovw); - } + switch (tactic) { + case 1: + (void) relative_move(use, yold, xold, ynew, xnew, ovw); + break; + case 2: + (void) strcpy(use, carriage_return); + (void) relative_move(use + SP->_carriage_return_length, + yold, 0, ynew, xnew, ovw); + break; + case 3: + (void) strcpy(use, cursor_home); + (void) relative_move(use + SP->_cursor_home_length, + 0, 0, ynew, xnew, ovw); + break; + case 4: + (void) strcpy(use, cursor_to_ll); + (void) relative_move(use + SP->_cursor_to_ll_length, + screen_lines - 1, 0, ynew, xnew, ovw); + break; + case 5: + use[0] = '\0'; + if (xold > 0) + (void) strcat(use, carriage_return); + (void) strcat(use, cursor_left); + (void) relative_move(use + strlen(use), + yold - 1, screen_columns - 1, ynew, xnew, ovw); + break; } #endif /* !NO_OPTIMIZE */ @@ -1020,7 +1024,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) printf("\" (%ld msec)\n", (long) (after.tv_usec - before.tv_usec + (after.tv_sec - - before.tv_sec) * 1000000)); + before.tv_sec) * 1000000)); } else if (sscanf(buf, "s %d %d %d %d", &fy, &fx, &ty, &tx) == 4) { struct timeval before, after; @@ -1032,7 +1036,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) printf("\" (%ld msec)\n", (long) (after.tv_usec - before.tv_usec + (after.tv_sec - - before.tv_sec) * 1000000)); + before.tv_sec) * 1000000)); } else if (buf[0] == 'r') { (void) strcpy(tname, termname()); load_term(); diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c index aab402f0223..08c6fec917a 100644 --- a/lib/libcurses/tty/lib_tstp.c +++ b/lib/libcurses/tty/lib_tstp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tstp.c,v 1.5 1999/11/28 17:49:54 millert Exp $ */ +/* $OpenBSD: lib_tstp.c,v 1.6 2000/06/19 03:53:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -50,7 +50,7 @@ #define _POSIX_SOURCE #endif -MODULE_ID("$From: lib_tstp.c,v 1.20 1999/10/22 23:11:09 tom Exp $") +MODULE_ID("$From: lib_tstp.c,v 1.21 2000/05/20 23:28:56 tom Exp $") #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) #define USE_SIGTSTP 1 @@ -228,6 +228,7 @@ static void cleanup(int sig) && SP->_ofp != 0 && isatty(fileno(SP->_ofp))) { SP->_cleanup = TRUE; + SP->_outch = _nc_outch; } set_term(scan); endwin(); diff --git a/lib/libcurses/tty/lib_vidattr.c b/lib/libcurses/tty/lib_vidattr.c index 9a38f0588f5..9584b26b108 100644 --- a/lib/libcurses/tty/lib_vidattr.c +++ b/lib/libcurses/tty/lib_vidattr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_vidattr.c,v 1.4 2000/03/26 16:45:04 millert Exp $ */ +/* $OpenBSD: lib_vidattr.c,v 1.5 2000/06/19 03:53:54 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -66,7 +66,7 @@ #include <curses.priv.h> #include <term.h> -MODULE_ID("$From: lib_vidattr.c,v 1.26 2000/03/26 02:56:20 tom Exp $"); +MODULE_ID("$From: lib_vidattr.c,v 1.27 2000/04/29 23:25:27 tom Exp $") #define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc) @@ -121,7 +121,8 @@ vidputs(attr_t newmode, int (*outc) (int)) * If we have a terminal that cannot combine color with video * attributes, use the colors in preference. */ - if ((newmode & A_COLOR) + if (((newmode & A_COLOR) != 0 + || fix_pair0) && (no_color_video > 0)) { /* *INDENT-OFF* */ static const struct { diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c index d0f32008f57..976f5ee8eca 100644 --- a/lib/libcurses/tty/tty_update.c +++ b/lib/libcurses/tty/tty_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_update.c,v 1.8 2000/03/26 16:45:04 millert Exp $ */ +/* $OpenBSD: tty_update.c,v 1.9 2000/06/19 03:53:55 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -72,7 +72,7 @@ #include <term.h> -MODULE_ID("$From: tty_update.c,v 1.134 2000/03/26 02:17:10 tom Exp $") +MODULE_ID("$From: tty_update.c,v 1.136 2000/05/20 23:28:00 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -183,6 +183,8 @@ GoTo(int const row, int const col) static inline void PutAttrChar(chtype ch) { + int data; + if (tilde_glitch && (TextOf(ch) == '~')) ch = ('`' | AttrOf(ch)); @@ -190,10 +192,11 @@ PutAttrChar(chtype ch) _tracechtype(ch), SP->_cursrow, SP->_curscol)); UpdateAttrs(ch); - if (SP->_cleanup) { - _nc_outch((int) TextOf(ch)); + data = TextOf(ch); + if (SP->_outch != 0) { + SP->_outch(data); } else { - putc((int) TextOf(ch), SP->_ofp); /* macro's fastest... */ + putc(data, SP->_ofp); /* macro's fastest... */ #ifdef TRACE _nc_outchars++; #endif /* TRACE */ @@ -851,18 +854,23 @@ ClrUpdate(void) */ static void -ClrToEOL(chtype blank) +ClrToEOL(chtype blank, bool needclear) { int j; - bool needclear = FALSE; - for (j = SP->_curscol; j < screen_columns; j++) { - chtype *cp = &(curscr->_line[SP->_cursrow].text[j]); + if (curscr != 0 + && SP->_cursrow >= 0 + && SP->_curscol >= 0) { + for (j = SP->_curscol; j < screen_columns; j++) { + chtype *cp = &(curscr->_line[SP->_cursrow].text[j]); - if (*cp != blank) { - *cp = blank; - needclear = TRUE; + if (*cp != blank) { + *cp = blank; + needclear = TRUE; + } } + } else { + needclear = TRUE; } if (needclear) { @@ -872,8 +880,9 @@ ClrToEOL(chtype blank) int count = (screen_columns - SP->_curscol); while (count-- > 0) PutChar(blank); - } else + } else { putp(clr_eol); + } } } @@ -1012,7 +1021,7 @@ TransformLine(int const lineno) if (attrchanged) { /* we may have to disregard the whole line */ GoTo(lineno, firstChar); - ClrToEOL(ClrBlank(curscr)); + ClrToEOL(ClrBlank(curscr), FALSE); PutRange(oldLine, newLine, lineno, 0, (screen_columns - 1)); #if USE_XMC_SUPPORT @@ -1147,7 +1156,7 @@ TransformLine(int const lineno) GoTo(lineno, firstChar); if (newLine[firstChar] != blank) PutChar(newLine[firstChar]); - ClrToEOL(blank); + ClrToEOL(blank, FALSE); } else if ((nLastChar != oLastChar) && (newLine[nLastChar] != oldLine[oLastChar] || !(_nc_idcok && has_ic()))) { @@ -1155,7 +1164,7 @@ TransformLine(int const lineno) if ((oLastChar - nLastChar) > SP->_el_cost) { if (PutRange(oldLine, newLine, lineno, firstChar, nLastChar)) GoTo(lineno, nLastChar + 1); - ClrToEOL(blank); + ClrToEOL(blank, FALSE); } else { n = max(nLastChar, oLastChar); PutRange(oldLine, newLine, lineno, firstChar, n); @@ -1197,7 +1206,7 @@ TransformLine(int const lineno) if (PutRange(oldLine, newLine, lineno, n + 1, nLastNonblank)) GoTo(lineno, nLastNonblank + 1); - ClrToEOL(blank); + ClrToEOL(blank, FALSE); } else { /* * The delete-char sequence will @@ -1458,7 +1467,7 @@ scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtype blank) #ifdef NCURSES_EXT_FUNCS if (FILL_BCE()) { for (i = 0; i < n; i++) { - GoTo(bot-i, 0); + GoTo(bot - i, 0); for (j = 0; j < screen_columns; j++) PutChar(blank); } @@ -1514,7 +1523,7 @@ scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chtype blank) #ifdef NCURSES_EXT_FUNCS if (FILL_BCE()) { for (i = 0; i < n; i++) { - GoTo(top+i, 0); + GoTo(top + i, 0); for (j = 0; j < screen_columns; j++) PutChar(blank); } @@ -1594,7 +1603,7 @@ _nc_scrolln(int n, int top, int bot, int maxy) if (non_dest_scroll_region || (memory_above && top == 0)) { for (i = 0; i < n; i++) { GoTo(i, 0); - ClrToEOL(BLANK); + ClrToEOL(BLANK, FALSE); } } @@ -1638,7 +1647,7 @@ _nc_scrolln(int n, int top, int bot, int maxy) } else if (clr_eol) { for (i = 0; i < -n; i++) { GoTo(maxy + n + i, 0); - ClrToEOL(BLANK); + ClrToEOL(BLANK, FALSE); } } } @@ -1726,6 +1735,12 @@ _nc_screen_wrap(void) SP->_default_color = TRUE; _nc_do_color(-1, 0, FALSE, _nc_outch); SP->_default_color = FALSE; + + mvcur(SP->_cursrow, SP->_curscol, screen_lines - 1, 0); + SP->_cursrow = screen_lines - 1; + SP->_curscol = 0; + + ClrToEOL(BLANK, TRUE); } #endif } diff --git a/lib/libform/form_field_info.3 b/lib/libform/form_field_info.3 index c8b6b544401..da148a01c1f 100644 --- a/lib/libform/form_field_info.3 +++ b/lib/libform/form_field_info.3 @@ -1,8 +1,8 @@ '\" t -.\" $OpenBSD: form_field_info.3,v 1.7 1999/01/22 03:30:53 millert Exp $ +.\" $OpenBSD: form_field_info.3,v 1.8 2000/06/19 03:53:56 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 * @@ -29,7 +29,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $From: form_field_info.3x,v 1.5 1998/11/29 01:06:24 Rick.Ohnemus Exp $ +.\" $From: form_field_info.3x,v 1.6 2000/04/15 22:21:31 tom Exp $ .TH form_field_info 3 "" .SH NAME \fBform_field_info\fR - retrieve field characteristics @@ -71,6 +71,10 @@ The header file \fB<form.h>\fR automatically includes the header file .SH PORTABILITY These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions. +.PP +A null (zero pointer) is accepted for any of the return values, +to ignore that value. +Not all implementations allow this, e.g., Solaris 2.7 does not. .SH AUTHORS Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. diff --git a/usr.bin/infocmp/infocmp.1tbl b/usr.bin/infocmp/infocmp.1tbl index a459e412528..ca6de4d00c4 100644 --- a/usr.bin/infocmp/infocmp.1tbl +++ b/usr.bin/infocmp/infocmp.1tbl @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: infocmp.1tbl,v 1.8 2000/03/26 16:45:04 millert Exp $ +.\" $OpenBSD: infocmp.1tbl,v 1.9 2000/06/19 03:53:57 millert Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998,2000 Free Software Foundation, Inc. * @@ -29,7 +29,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $From: infocmp.1m,v 1.24 2000/03/19 03:03:31 tom Exp $ +.\" $From: infocmp.1m,v 1.25 2000/06/11 02:08:16 tom Exp $ .TH infocmp 1 "" .ds n 5 .ds d /usr/share/terminfo @@ -367,7 +367,7 @@ Actual BSD curses versions will have a more restricted set. To see only the .SH AUTHOR Eric S. Raymond <esr@snark.thyrsus.com> and -Thomas E. Dickey <dickey@clark.net> +Thomas E. Dickey <dickey@herndon4.his.com> .\"# .\"# The following sets edit modes for GNU EMACS .\"# Local Variables: diff --git a/usr.bin/tic/dump_entry.c b/usr.bin/tic/dump_entry.c index 6282378922f..8146fc18cc7 100644 --- a/usr.bin/tic/dump_entry.c +++ b/usr.bin/tic/dump_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dump_entry.c,v 1.14 2000/03/13 23:53:41 millert Exp $ */ +/* $OpenBSD: dump_entry.c,v 1.15 2000/06/19 03:53:58 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998-2000 Free Software Foundation, Inc. * @@ -40,12 +40,18 @@ #include <termsort.c> /* this C file is generated */ #include <parametrized.h> /* so is this */ -MODULE_ID("$From: dump_entry.c,v 1.48 2000/03/12 02:33:01 tom Exp $") +MODULE_ID("$From: dump_entry.c,v 1.53 2000/04/15 21:23:30 tom Exp $") #define INDENT 8 #define DISCARD(string) string = ABSENT_STRING #define PRINTF (void) printf +typedef struct { + char *text; + size_t used; + size_t size; +} DYNBUF; + static int tversion; /* terminfo version */ static int outform; /* output format to use */ static int sortmode; /* sort mode to use */ @@ -55,9 +61,8 @@ static int oldcol; /* last value of column before wrap */ static int tracelevel; /* level of debug output */ static bool pretty; /* true if we format if-then-else strings */ -static char *outbuf; /* the output-buffer */ -static size_t out_used; /* ...its current length */ -static size_t out_size; /* ...and its allocated length */ +static DYNBUF outbuf; +static DYNBUF tmpbuf; /* indirection pointers for implementing sort and display modes */ static const int *bool_indirect, *num_indirect, *str_indirect; @@ -92,14 +97,46 @@ static const char *separator, *trailer; #define StrIndirect(j) ((sortmode == S_NOSORT) ? (j) : str_indirect[j]) #endif +static void +strncpy_DYN(DYNBUF * dst, const char *src, size_t need) +{ + size_t want = need + dst->used + 1; + if (want > dst->size) { + dst->size += (want + 1024); /* be generous */ + dst->text = typeRealloc(char, dst->size, dst->text); + } + (void) strncpy(dst->text + dst->used, src, need); + dst->used += need; + dst->text[dst->used] = 0; +} + +static void +strcpy_DYN(DYNBUF * dst, const char *src) +{ + if (src == 0) { + dst->used = 0; + strcpy_DYN(dst, ""); + } else { + strncpy_DYN(dst, src, strlen(src)); + } +} + #if NO_LEAKS +static void +free_DYN(DYNBUF * p) +{ + if (p->text != 0) + free(p->text); + p->text = 0; + p->size = 0; + p->used = 0; +} + void _nc_leaks_dump_entry(void) { - if (outbuf != 0) { - free(outbuf); - outbuf = 0; - } + free_DYN(&outbuf); + free_DYN(&tmpbuf); } #endif @@ -329,31 +366,10 @@ version_filter(int type, int idx) } static void -append_output(const char *src) -{ - if (src == 0) { - out_used = 0; - append_output(""); - } else { - size_t need = strlen(src); - size_t want = need + out_used + 1; - if (want > out_size) { - out_size += want; /* be generous */ - if (outbuf == 0) - outbuf = malloc(out_size); - else - outbuf = realloc(outbuf, out_size); - } - (void) strcpy(outbuf + out_used, src); - out_used += need; - } -} - -static void force_wrap(void) { oldcol = column; - append_output(trailer); + strcpy_DYN(&outbuf, trailer); column = INDENT; } @@ -367,8 +383,8 @@ wrap_concat(const char *src) && column + want > width) { force_wrap(); } - append_output(src); - append_output(separator); + strcpy_DYN(&outbuf, src); + strcpy_DYN(&outbuf, separator); column += need; } @@ -407,19 +423,18 @@ termcap_length(const char *src) #endif static char * -fmt_complex(char *dst, char *src, int level) +fmt_complex(char *src, int level) { int percent = 0; int n; bool if_then = strstr(src, "%?") != 0; bool params = !if_then && (strlen(src) > 50) && (strstr(src, "%p") != 0); - dst += strlen(dst); while (*src != '\0') { switch (*src) { case '\\': percent = 0; - *dst++ = *src++; + strncpy_DYN(&tmpbuf, src++, 1); break; case '%': percent = 1; @@ -429,17 +444,24 @@ fmt_complex(char *dst, char *src, int level) case 'e': /* "else" */ if (percent) { percent = 0; - dst[-1] = '\n'; - for (n = 0; n <= level; n++) - *dst++ = '\t'; - *dst++ = '%'; - *dst++ = *src; - *dst = '\0'; - if (*src++ == '?') { - src = fmt_complex(dst, src, level + 1); - dst += strlen(dst); - } else if (level == 1) { - _nc_warning("%%%c without %%?", *src); + tmpbuf.text[tmpbuf.used - 1] = '\n'; + /* treat a "%e%?" as else-if, on the same level */ + if (!strncmp(src, "e%?", 3)) { + for (n = 0; n < level; n++) + strncpy_DYN(&tmpbuf, "\t", 1); + strncpy_DYN(&tmpbuf, "%", 1); + strncpy_DYN(&tmpbuf, src, 3); + src += 3; + } else { + for (n = 0; n <= level; n++) + strncpy_DYN(&tmpbuf, "\t", 1); + strncpy_DYN(&tmpbuf, "%", 1); + strncpy_DYN(&tmpbuf, src, 1); + if (*src++ == '?') { + src = fmt_complex(src, level + 1); + } else if (level == 1) { + _nc_warning("%%%c without %%?", *src); + } } continue; } @@ -448,12 +470,11 @@ fmt_complex(char *dst, char *src, int level) if (percent) { percent = 0; if (level > 1) { - dst[-1] = '\n'; + tmpbuf.text[tmpbuf.used - 1] = '\n'; for (n = 0; n < level; n++) - *dst++ = '\t'; - *dst++ = '%'; - *dst++ = *src++; - *dst = '\0'; + strncpy_DYN(&tmpbuf, "\t", 1); + strncpy_DYN(&tmpbuf, "%", 1); + strncpy_DYN(&tmpbuf, src++, 1); return src; } _nc_warning("%%; without %%?"); @@ -461,10 +482,10 @@ fmt_complex(char *dst, char *src, int level) break; case 'p': if (percent && params) { - dst[-1] = '\n'; + tmpbuf.text[tmpbuf.used - 1] = '\n'; for (n = 0; n <= level; n++) - *dst++ = '\t'; - *dst++ = '%'; + strncpy_DYN(&tmpbuf, "\t", 1); + strncpy_DYN(&tmpbuf, "%", 1); } percent = 0; break; @@ -472,9 +493,8 @@ fmt_complex(char *dst, char *src, int level) percent = 0; break; } - *dst++ = *src++; + strncpy_DYN(&tmpbuf, src++, 1); } - *dst = '\0'; return src; } @@ -505,10 +525,10 @@ fmt_entry(TERMTYPE * tterm, pred = dump_predicate; } - append_output(0); - append_output(tterm->term_names); - append_output(separator); - column = out_used; + strcpy_DYN(&outbuf, 0); + strcpy_DYN(&outbuf, tterm->term_names); + strcpy_DYN(&outbuf, separator); + column = outbuf.used; force_wrap(); for_each_boolean(j, tterm) { @@ -565,6 +585,20 @@ fmt_entry(TERMTYPE * tterm, if (len & 1) len++; +#undef CUR +#define CUR tterm-> + if (outform == F_TERMCAP) { + if (termcap_reset != ABSENT_STRING) { + if (init_3string != ABSENT_STRING + && !strcmp(init_3string, termcap_reset)) + DISCARD(init_3string); + + if (reset_2string != ABSENT_STRING + && !strcmp(reset_2string, termcap_reset)) + DISCARD(reset_2string); + } + } + for_each_string(j, tterm) { i = StrIndirect(j); name = ExtStrname(tterm, i, str_names); @@ -580,52 +614,45 @@ fmt_entry(TERMTYPE * tterm, * them to be output as defined and empty. */ if (outform == F_TERMCAP) { -#undef CUR -#define CUR tterm-> if (insert_character || parm_ich) { if (&tterm->Strings[i] == &enter_insert_mode && enter_insert_mode == ABSENT_STRING) { (void) strcpy(buffer, "im="); - goto catenate; + WRAP_CONCAT; + continue; } if (&tterm->Strings[i] == &exit_insert_mode && exit_insert_mode == ABSENT_STRING) { (void) strcpy(buffer, "ei="); - goto catenate; + WRAP_CONCAT; + continue; } } - - if (termcap_reset != ABSENT_STRING) { - if (init_3string != ABSENT_STRING - && !strcmp(init_3string, termcap_reset)) - DISCARD(init_3string); - - if (reset_2string != ABSENT_STRING - && !strcmp(reset_2string, termcap_reset)) - DISCARD(reset_2string); - } } predval = pred(STRING, i); buffer[0] = '\0'; + if (predval != FAIL) { if (tterm->Strings[i] != ABSENT_STRING && i + 1 > num_strings) num_strings = i + 1; - if (!VALID_STRING(tterm->Strings[i])) + + if (!VALID_STRING(tterm->Strings[i])) { sprintf(buffer, "%s@", name); - else if (outform == F_TERMCAP || outform == F_TCONVERR) { + WRAP_CONCAT; + } else if (outform == F_TERMCAP || outform == F_TCONVERR) { char *srccap = _nc_tic_expand(tterm->Strings[i], TRUE, numbers); char *cv = _nc_infotocap(name, srccap, parametrized[i]); if (cv == 0) { - if (outform == F_TCONVERR) + if (outform == F_TCONVERR) { sprintf(buffer, "%s=!!! %s WILL NOT CONVERT !!!", name, srccap); - else if (suppress_untranslatable) + } else if (suppress_untranslatable) { continue; - else { + } else { char *s = srccap, *d = buffer; sprintf(d, "..%s=", name); d += strlen(d); @@ -639,24 +666,29 @@ fmt_entry(TERMTYPE * tterm, d++; } } - } else + } else { sprintf(buffer, "%s=%s", name, cv); + } len += strlen(tterm->Strings[i]) + 1; + WRAP_CONCAT; } else { char *src = _nc_tic_expand(tterm->Strings[i], outform == F_TERMINFO, numbers); - sprintf(buffer, "%s=", name); + + strcpy_DYN(&tmpbuf, 0); + strcpy_DYN(&tmpbuf, name); + strcpy_DYN(&tmpbuf, "="); if (pretty && (outform == F_TERMINFO - || outform == F_VARIABLE)) - fmt_complex(buffer + strlen(buffer), src, 1); - else - strcat(buffer, src); + || outform == F_VARIABLE)) { + fmt_complex(src, 1); + } else { + strcpy_DYN(&tmpbuf, src); + } len += strlen(tterm->Strings[i]) + 1; + wrap_concat(tmpbuf.text); + outcount = TRUE; } - - catenate: - WRAP_CONCAT; } } len += num_strings * 2; @@ -708,27 +740,32 @@ fmt_entry(TERMTYPE * tterm, * in infocmp -u output when there are no string differences */ if (outcount) { - j = out_used; + bool trimmed = FALSE; + j = outbuf.used; if (j >= 2 - && outbuf[j - 1] == '\t' - && outbuf[j - 2] == '\n') { - out_used -= 2; + && outbuf.text[j - 1] == '\t' + && outbuf.text[j - 2] == '\n') { + outbuf.used -= 2; + trimmed = TRUE; } else if (j >= 4 - && outbuf[j - 1] == ':' - && outbuf[j - 2] == '\t' - && outbuf[j - 3] == '\n' - && outbuf[j - 4] == '\\') { - out_used -= 4; + && outbuf.text[j - 1] == ':' + && outbuf.text[j - 2] == '\t' + && outbuf.text[j - 3] == '\n' + && outbuf.text[j - 4] == '\\') { + outbuf.used -= 4; + trimmed = TRUE; + } + if (trimmed) { + outbuf.text[outbuf.used] = '\0'; + column = oldcol; } - outbuf[out_used] = '\0'; - column = oldcol; } #if 0 fprintf(stderr, "num_bools = %d\n", num_bools); fprintf(stderr, "num_values = %d\n", num_values); fprintf(stderr, "num_strings = %d\n", num_strings); fprintf(stderr, "term_names=%s, len=%d, strlen(outbuf)=%d, outbuf=%s\n", - tterm->term_names, len, out_used, outbuf); + tterm->term_names, len, outbuf.used, outbuf.text); #endif /* * Here's where we use infodump to trigger a more stringent length check @@ -737,7 +774,7 @@ fmt_entry(TERMTYPE * tterm, * It gives an idea of which entries are deadly to even *scan past*, * as opposed to *use*. */ - return (infodump ? len : termcap_length(outbuf)); + return (infodump ? len : termcap_length(outbuf.text)); } int @@ -804,7 +841,7 @@ dump_entry(TERMTYPE * tterm, bool limited, int numbers, int (*pred) (int } } - (void) fputs(outbuf, stdout); + (void) fputs(outbuf.text, stdout); return len; } @@ -814,21 +851,23 @@ dump_uses(const char *name, bool infodump) { char buffer[MAX_TERMINFO_LENGTH]; - append_output(0); + strcpy_DYN(&outbuf, 0); (void) sprintf(buffer, "%s%s", infodump ? "use=" : "tc=", name); wrap_concat(buffer); - (void) fputs(outbuf, stdout); - return out_used; + (void) fputs(outbuf.text, stdout); + return outbuf.used; } void -compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_UNUSED, bool quiet) +compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp + GCC_UNUSED, bool quiet) /* compare two entries */ { int i, j; NCURSES_CONST char *name; - if (!quiet) fputs(" comparing booleans.\n", stdout); + if (!quiet) + fputs(" comparing booleans.\n", stdout); for_each_boolean(j, tp) { i = BoolIndirect(j); name = ExtBoolname(tp, i, bool_names); @@ -839,7 +878,8 @@ compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_U (*hook) (CMP_BOOLEAN, i, name); } - if (!quiet) fputs(" comparing numbers.\n", stdout); + if (!quiet) + fputs(" comparing numbers.\n", stdout); for_each_number(j, tp) { i = NumIndirect(j); name = ExtNumname(tp, i, num_names); @@ -850,7 +890,8 @@ compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_U (*hook) (CMP_NUMBER, i, name); } - if (!quiet) fputs(" comparing strings.\n", stdout); + if (!quiet) + fputs(" comparing strings.\n", stdout); for_each_string(j, tp) { i = StrIndirect(j); name = ExtStrname(tp, i, str_names); diff --git a/usr.bin/tic/progs.priv.h b/usr.bin/tic/progs.priv.h index 5520e5ba5c4..9de782bea8a 100644 --- a/usr.bin/tic/progs.priv.h +++ b/usr.bin/tic/progs.priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: progs.priv.h,v 1.5 2000/03/10 01:35:06 millert Exp $ */ +/* $OpenBSD: progs.priv.h,v 1.6 2000/06/19 03:53:59 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998-2000 Free Software Foundation, Inc. * @@ -32,7 +32,7 @@ * Author: Thomas E. Dickey <dickey@clark.net> 1997,1998 * ****************************************************************************/ /* - * $From: progs.priv.h,v 1.21 2000/03/05 04:32:47 tom Exp $ + * $From: progs.priv.h,v 1.22 2000/04/08 23:47:39 tom Exp $ * * progs.priv.h * @@ -172,8 +172,3 @@ extern int optind; # define isascii(c) 1 /* not really ascii anyway */ # endif #endif - -#if !HAVE_STRDUP -#define strdup _nc_strdup -extern char *_nc_strdup(const char *); -#endif /* not HAVE_STRDUP */ diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c index 8e926dcbfbf..e9b4c6725b7 100644 --- a/usr.bin/tic/tic.c +++ b/usr.bin/tic/tic.c @@ -42,7 +42,7 @@ #include <dump_entry.h> #include <term_entry.h> -MODULE_ID("$From: tic.c,v 1.67 2000/03/19 02:08:10 tom Exp $") +MODULE_ID("$From: tic.c,v 1.69 2000/04/08 23:53:49 tom Exp $") const char *_nc_progname = "tic"; @@ -236,8 +236,8 @@ put_translate(int c) if (in_name) { if (used + 1 >= have) { have += 132; - namebuf = (namebuf != 0) ? realloc(namebuf, have) : malloc(have); - suffix = (suffix != 0) ? realloc(suffix, have) : malloc(have); + namebuf = typeRealloc(char, have, namebuf); + suffix = typeRealloc(char, have, suffix); } if (c == '\n' || c == '@') { namebuf[used++] = '\0'; @@ -328,7 +328,7 @@ make_namelist(char *src) } } if (pass == 1) { - dst = (const char **) calloc(nn + 1, sizeof(*dst)); + dst = typeCalloc(const char *, nn + 1); rewind(fp); } } @@ -351,7 +351,7 @@ make_namelist(char *src) break; } if (pass == 1) - dst = (const char **) calloc(nn + 1, sizeof(*dst)); + dst = typeCalloc(const char *, nn + 1); } } if (showsummary) { |