summaryrefslogtreecommitdiff
path: root/lib/libcurses/tty
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcurses/tty')
-rw-r--r--lib/libcurses/tty/MKexpanded.sh16
-rw-r--r--lib/libcurses/tty/hardscroll.c73
-rw-r--r--lib/libcurses/tty/hashmap.c258
-rw-r--r--lib/libcurses/tty/lib_mvcur.c51
-rw-r--r--lib/libcurses/tty/lib_tstp.c6
-rw-r--r--lib/libcurses/tty/lib_twait.c9
-rw-r--r--lib/libcurses/tty/lib_vidattr.c23
-rw-r--r--lib/libcurses/tty/tty_display.h32
-rw-r--r--lib/libcurses/tty/tty_input.h20
-rw-r--r--lib/libcurses/tty/tty_update.c31
10 files changed, 251 insertions, 268 deletions
diff --git a/lib/libcurses/tty/MKexpanded.sh b/lib/libcurses/tty/MKexpanded.sh
index 2c4ef80d427..c9de5292ec3 100644
--- a/lib/libcurses/tty/MKexpanded.sh
+++ b/lib/libcurses/tty/MKexpanded.sh
@@ -29,8 +29,8 @@
#
# Author: Thomas E. Dickey <dickey@clark.net> 1997
#
-# $OpenBSD: MKexpanded.sh,v 1.2 2000/10/08 22:47:04 millert Exp $
-# $From: MKexpanded.sh,v 1.9 2000/09/02 22:55:21 tom Exp $
+# $OpenBSD: MKexpanded.sh,v 1.3 2001/01/22 18:01:59 millert Exp $
+# $From: MKexpanded.sh,v 1.10 2000/12/10 00:24:33 tom Exp $
#
# Script to generate 'expanded.c', a dummy source that contains functions
# corresponding to complex macros used in this library. By making functions,
@@ -69,23 +69,23 @@ cat >$TMP <<EOF
#undef FALSE
/* this is a marker */
IGNORE
-void _nc_toggle_attr_on(attr_t *S, attr_t at)
+NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *S, attr_t at)
{
toggle_attr_on(*S,at);
}
-void _nc_toggle_attr_off(attr_t *S, attr_t at)
+NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *S, attr_t at)
{
toggle_attr_off(*S,at);
}
-int _nc_DelCharCost(int count)
+NCURSES_EXPORT(int) _nc_DelCharCost (int count)
{
return DelCharCost(count);
}
-int _nc_InsCharCost(int count)
+NCURSES_EXPORT(int) _nc_InsCharCost (int count)
{
return InsCharCost(count);
}
-void _nc_UpdateAttrs(chtype c)
+NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype c)
{
UpdateAttrs(c);
}
@@ -95,6 +95,6 @@ $preprocessor $TMP 2>/dev/null | sed -e '1,/^IGNORE$/d'
cat <<EOF
#else /* ! NCURSES_EXPANDED */
-void _nc_expanded(void) { }
+NCURSES_EXPORT(void) _nc_expanded (void) { }
#endif /* NCURSES_EXPANDED */
EOF
diff --git a/lib/libcurses/tty/hardscroll.c b/lib/libcurses/tty/hardscroll.c
index 2c88ed1f829..7673cffa9c3 100644
--- a/lib/libcurses/tty/hardscroll.c
+++ b/lib/libcurses/tty/hardscroll.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: hardscroll.c,v 1.2 1999/03/02 06:23:30 millert Exp $ */
+/* $OpenBSD: hardscroll.c,v 1.3 2001/01/22 18:01:59 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> *
****************************************************************************/
-
/******************************************************************************
NAME
@@ -148,13 +147,14 @@ AUTHOR
#include <curses.priv.h>
-MODULE_ID("$From: hardscroll.c,v 1.33 1999/02/27 20:01:29 tom Exp $")
+MODULE_ID("$From: hardscroll.c,v 1.36 2001/01/14 00:17:28 tom Exp $")
#if defined(SCROLLDEBUG) || defined(HASHDEBUG)
# undef screen_lines
# define screen_lines MAXLINES
-int oldnums[MAXLINES];
+NCURSES_EXPORT_VAR(int)
+oldnums[MAXLINES];
# define OLDNUM(n) oldnums[n]
# define _tracef printf
# undef TR
@@ -165,19 +165,21 @@ int oldnums[MAXLINES];
/* OLDNUM(n) indicates which line will be shifted to the position n.
if OLDNUM(n) == _NEWINDEX, then the line n in new, not shifted from
somewhere. */
+NCURSES_EXPORT_VAR(int *)
+_nc_oldnums = 0;
+
# if USE_HASHMAP
-int *_nc_oldnums = 0;
-static int oldnums_allocated = 0;
+ static int oldnums_allocated = 0;
# define oldnums _nc_oldnums
# define OLDNUM(n) oldnums[n]
-# else /* !USE_HASHMAP */
+# else /* !USE_HASHMAP */
# define OLDNUM(n) newscr->_line[n].oldindex
-# endif /* !USE_HASHMAP */
+# endif /* !USE_HASHMAP */
#endif /* defined(SCROLLDEBUG) || defined(HASHDEBUG) */
-
-void _nc_scroll_optimize(void)
+NCURSES_EXPORT(void)
+_nc_scroll_optimize(void)
/* scroll optimization to transform curscr to newscr */
{
int i;
@@ -188,8 +190,7 @@ void _nc_scroll_optimize(void)
#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
#if USE_HASHMAP
/* get enough storage */
- if (oldnums_allocated < screen_lines)
- {
+ if (oldnums_allocated < screen_lines) {
int *new_oldnums = typeRealloc(int, screen_lines, oldnums);
if (!new_oldnums)
return;
@@ -207,25 +208,24 @@ void _nc_scroll_optimize(void)
#endif /* TRACE */
/* pass 1 - from top to bottom scrolling up */
- for (i = 0; i < screen_lines; )
- {
+ for (i = 0; i < screen_lines;) {
while (i < screen_lines && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) <= i))
i++;
if (i >= screen_lines)
break;
- shift = OLDNUM(i) - i; /* shift > 0 */
+ shift = OLDNUM(i) - i; /* shift > 0 */
start = i;
i++;
- while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift)
+ while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
+ == shift)
i++;
- end = i-1 + shift;
+ end = i - 1 + shift;
TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
- if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR)
- {
+ if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
continue;
}
@@ -233,25 +233,23 @@ void _nc_scroll_optimize(void)
}
/* pass 2 - from bottom to top scrolling down */
- for (i = screen_lines-1; i >= 0; )
- {
+ for (i = screen_lines - 1; i >= 0;) {
while (i >= 0 && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) >= i))
i--;
if (i < 0)
break;
- shift = OLDNUM(i) - i; /* shift < 0 */
+ shift = OLDNUM(i) - i; /* shift < 0 */
end = i;
i--;
while (i >= 0 && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift)
i--;
- start = i+1 - (-shift);
+ start = i + 1 - (-shift);
TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
- if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR)
- {
+ if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
continue;
}
@@ -260,14 +258,15 @@ void _nc_scroll_optimize(void)
}
#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
-void _nc_linedump(void)
+NCURSES_EXPORT(void)
+_nc_linedump(void)
/* dump the state of the real and virtual oldnum fields */
{
static size_t have;
static char *buf;
- int n;
- size_t want = (screen_lines + 1) * 4;
+ int n;
+ size_t want = (screen_lines + 1) * 4;
if (have < want)
buf = typeMalloc(char, have = want);
@@ -286,28 +285,26 @@ void _nc_linedump(void)
#ifdef SCROLLDEBUG
int
-main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
- char line[BUFSIZ], *st;
+ char line[BUFSIZ], *st;
#ifdef TRACE
_nc_tracing = TRACE_MOVE;
#endif
- for (;;)
- {
- int n;
+ for (;;) {
+ int n;
for (n = 0; n < screen_lines; n++)
oldnums[n] = _NEWINDEX;
/* grab the test vector */
- if (fgets(line, sizeof(line), stdin) == (char *)NULL)
+ if (fgets(line, sizeof(line), stdin) == (char *) NULL)
exit(EXIT_SUCCESS);
/* parse it */
n = 0;
- if (line[0] == '#')
- {
+ if (line[0] == '#') {
(void) fputs(line, stderr);
continue;
}
@@ -315,7 +312,7 @@ main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
do {
oldnums[n++] = atoi(st);
} while
- ((st = strtok((char *)NULL, " ")) != 0);
+ ((st = strtok((char *) NULL, " ")) != 0);
/* display it */
(void) fputs("Initial input:\n", stderr);
diff --git a/lib/libcurses/tty/hashmap.c b/lib/libcurses/tty/hashmap.c
index a2442f97c1a..c57e36527cd 100644
--- a/lib/libcurses/tty/hashmap.c
+++ b/lib/libcurses/tty/hashmap.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: hashmap.c,v 1.5 1999/11/28 17:49:54 millert Exp $ */
+/* $OpenBSD: hashmap.c,v 1.6 2001/01/22 18:01:59 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 *
@@ -70,9 +70,9 @@ AUTHOR
*****************************************************************************/
#include <curses.priv.h>
-#include <term.h> /* for back_color_erase */
+#include <term.h> /* for back_color_erase */
-MODULE_ID("$From: hashmap.c,v 1.34 1999/11/28 00:10:57 tom Exp $")
+MODULE_ID("$From: hashmap.c,v 1.36 2000/12/10 03:04:30 tom Exp $")
#ifdef HASHDEBUG
@@ -102,41 +102,43 @@ static chtype oldtext[MAXLINES][TEXTWIDTH], newtext[MAXLINES][TEXTWIDTH];
#define oldhash (SP->oldhash)
#define newhash (SP->newhash)
-static inline unsigned long hash(chtype *text)
+static inline unsigned long
+hash(chtype * text)
{
int i;
chtype ch;
unsigned long result = 0;
- for (i = TEXTWIDTH; i>0; i--)
- {
+ for (i = TEXTWIDTH; i > 0; i--) {
ch = *text++;
- result += (result<<5) + ch;
+ result += (result << 5) + ch;
}
return result;
}
/* approximate update cost */
-static int update_cost(chtype *from,chtype *to)
+static int
+update_cost(chtype * from, chtype * to)
{
- int cost=0;
+ int cost = 0;
int i;
- for (i=TEXTWIDTH; i>0; i--)
+ for (i = TEXTWIDTH; i > 0; i--)
if (*from++ != *to++)
cost++;
return cost;
}
-static int update_cost_from_blank(chtype *to)
+static int
+update_cost_from_blank(chtype * to)
{
- int cost=0;
+ int cost = 0;
int i;
chtype blank = BLANK;
if (back_color_erase)
blank |= (stdscr->_bkgd & A_COLOR);
- for (i=TEXTWIDTH; i>0; i--)
+ for (i = TEXTWIDTH; i > 0; i--)
if (blank != *to++)
cost++;
@@ -147,7 +149,8 @@ static int update_cost_from_blank(chtype *to)
* Returns true when moving line 'from' to line 'to' seems to be cost
* effective. 'blank' indicates whether the line 'to' would become blank.
*/
-static inline bool cost_effective(const int from, const int to, const bool blank)
+static inline bool
+cost_effective(const int from, const int to, const bool blank)
{
int new_from;
@@ -163,30 +166,28 @@ static inline bool cost_effective(const int from, const int to, const bool blank
* on the right side -- cost after moving.
*/
return (((blank ? update_cost_from_blank(NEWTEXT(to))
- : update_cost(OLDTEXT(to),NEWTEXT(to)))
- + update_cost(OLDTEXT(new_from),NEWTEXT(from)))
- >= ((new_from==from ? update_cost_from_blank(NEWTEXT(from))
- : update_cost(OLDTEXT(new_from),NEWTEXT(from)))
- + update_cost(OLDTEXT(from),NEWTEXT(to)))) ? TRUE : FALSE;
+ : update_cost(OLDTEXT(to), NEWTEXT(to)))
+ + update_cost(OLDTEXT(new_from), NEWTEXT(from)))
+ >= ((new_from == from ? update_cost_from_blank(NEWTEXT(from))
+ : update_cost(OLDTEXT(new_from), NEWTEXT(from)))
+ + update_cost(OLDTEXT(from), NEWTEXT(to)))) ? TRUE : FALSE;
}
+typedef struct {
+ unsigned long hashval;
+ int oldcount, newcount;
+ int oldindex, newindex;
+} sym;
-typedef struct
-{
- unsigned long hashval;
- int oldcount, newcount;
- int oldindex, newindex;
-}
- sym;
-
-static sym *hashtab=0;
-static int lines_alloc=0;
+static sym *hashtab = 0;
+static int lines_alloc = 0;
-static void grow_hunks(void)
+static void
+grow_hunks(void)
{
int start, end, shift;
- int back_limit, forward_limit; /* limits for cells to fill */
- int back_ref_limit, forward_ref_limit; /* limits for refrences */
+ int back_limit, forward_limit; /* limits for cells to fill */
+ int back_ref_limit, forward_ref_limit; /* limits for refrences */
int i;
int next_hunk;
@@ -200,14 +201,14 @@ static void grow_hunks(void)
i = 0;
while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
i++;
- for ( ; i < screen_lines; i=next_hunk)
- {
+ for (; i < screen_lines; i = next_hunk) {
start = i;
shift = OLDNUM(i) - i;
/* get forward limit */
- i = start+1;
- while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift)
+ i = start + 1;
+ while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
+ == shift)
i++;
end = i;
while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
@@ -219,25 +220,21 @@ static void grow_hunks(void)
else
forward_ref_limit = OLDNUM(i);
- i = start-1;
+ i = start - 1;
/* grow back */
if (shift < 0)
back_limit = back_ref_limit + (-shift);
- while (i >= back_limit)
- {
- if(newhash[i] == oldhash[i+shift]
- || cost_effective(i+shift, i, shift<0))
- {
- OLDNUM(i) = i+shift;
+ while (i >= back_limit) {
+ if (newhash[i] == oldhash[i + shift]
+ || cost_effective(i + shift, i, shift < 0)) {
+ OLDNUM(i) = i + shift;
TR(TRACE_UPDATE | TRACE_MOVE,
("connected new line %d to old line %d (backward continuation)",
- i, i+shift));
- }
- else
- {
+ i, i + shift));
+ } else {
TR(TRACE_UPDATE | TRACE_MOVE,
("not connecting new line %d to old line %d (backward continuation)",
- i, i+shift));
+ i, i + shift));
break;
}
i--;
@@ -247,21 +244,17 @@ static void grow_hunks(void)
/* grow forward */
if (shift > 0)
forward_limit = forward_ref_limit - shift;
- while (i < forward_limit)
- {
- if(newhash[i] == oldhash[i+shift]
- || cost_effective(i+shift, i, shift>0))
- {
- OLDNUM(i) = i+shift;
+ while (i < forward_limit) {
+ if (newhash[i] == oldhash[i + shift]
+ || cost_effective(i + shift, i, shift > 0)) {
+ OLDNUM(i) = i + shift;
TR(TRACE_UPDATE | TRACE_MOVE,
("connected new line %d to old line %d (forward continuation)",
- i, i+shift));
- }
- else
- {
+ i, i + shift));
+ } else {
TR(TRACE_UPDATE | TRACE_MOVE,
("not connecting new line %d to old line %d (forward continuation)",
- i, i+shift));
+ i, i + shift));
break;
}
i++;
@@ -273,22 +266,19 @@ static void grow_hunks(void)
}
}
-void _nc_hash_map(void)
+NCURSES_EXPORT(void)
+_nc_hash_map(void)
{
sym *sp;
register int i;
int start, shift, size;
-
- if (screen_lines > lines_alloc)
- {
+ if (screen_lines > lines_alloc) {
if (hashtab)
- free (hashtab);
- hashtab = typeMalloc(sym, (screen_lines+1)*2);
- if (!hashtab)
- {
- if (oldhash)
- {
+ free(hashtab);
+ hashtab = typeMalloc(sym, (screen_lines + 1) * 2);
+ if (!hashtab) {
+ if (oldhash) {
FreeAndNull(oldhash);
}
lines_alloc = 0;
@@ -297,47 +287,40 @@ void _nc_hash_map(void)
lines_alloc = screen_lines;
}
- if (oldhash && newhash)
- {
+ if (oldhash && newhash) {
/* re-hash only changed lines */
- for (i = 0; i < screen_lines; i++)
- {
+ for (i = 0; i < screen_lines; i++) {
if (PENDING(i))
newhash[i] = hash(NEWTEXT(i));
}
- }
- else
- {
+ } else {
/* re-hash all */
if (oldhash == 0)
- oldhash = typeCalloc (unsigned long, screen_lines);
+ oldhash = typeCalloc(unsigned long, screen_lines);
if (newhash == 0)
- newhash = typeCalloc (unsigned long, screen_lines);
+ newhash = typeCalloc(unsigned long, screen_lines);
if (!oldhash || !newhash)
- return; /* malloc failure */
- for (i = 0; i < screen_lines; i++)
- {
+ return; /* malloc failure */
+ for (i = 0; i < screen_lines; i++) {
newhash[i] = hash(NEWTEXT(i));
oldhash[i] = hash(OLDTEXT(i));
}
}
#ifdef HASH_VERIFY
- for (i = 0; i < screen_lines; i++)
- {
- if(newhash[i] != hash(NEWTEXT(i)))
- fprintf(stderr,"error in newhash[%d]\n",i);
- if(oldhash[i] != hash(OLDTEXT(i)))
- fprintf(stderr,"error in oldhash[%d]\n",i);
+ for (i = 0; i < screen_lines; i++) {
+ if (newhash[i] != hash(NEWTEXT(i)))
+ fprintf(stderr, "error in newhash[%d]\n", i);
+ if (oldhash[i] != hash(OLDTEXT(i)))
+ fprintf(stderr, "error in oldhash[%d]\n", i);
}
#endif
/*
* Set up and count line-hash values.
*/
- memset(hashtab, '\0', sizeof(*hashtab)*(screen_lines+1)*2);
- for (i = 0; i < screen_lines; i++)
- {
+ memset(hashtab, '\0', sizeof(*hashtab) * (screen_lines + 1) * 2);
+ for (i = 0; i < screen_lines; i++) {
unsigned long hashval = oldhash[i];
for (sp = hashtab; sp->hashval; sp++)
@@ -347,8 +330,7 @@ void _nc_hash_map(void)
sp->oldcount++;
sp->oldindex = i;
}
- for (i = 0; i < screen_lines; i++)
- {
+ for (i = 0; i < screen_lines; i++) {
unsigned long hashval = newhash[i];
for (sp = hashtab; sp->hashval; sp++)
@@ -370,11 +352,10 @@ void _nc_hash_map(void)
*/
for (sp = hashtab; sp->hashval; sp++)
if (sp->oldcount == 1 && sp->newcount == 1
- && sp->oldindex != sp->newindex)
- {
+ && sp->oldindex != sp->newindex) {
TR(TRACE_UPDATE | TRACE_MOVE,
("new line %d is hash-identical to old line %d (unique)",
- sp->newindex, sp->oldindex));
+ sp->newindex, sp->oldindex));
OLDNUM(sp->newindex) = sp->oldindex;
}
@@ -386,8 +367,7 @@ void _nc_hash_map(void)
* those which are to be moved too far, they are likely to destroy
* more than carry.
*/
- for (i = 0; i < screen_lines; )
- {
+ for (i = 0; i < screen_lines;) {
while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
i++;
if (i >= screen_lines)
@@ -395,13 +375,12 @@ void _nc_hash_map(void)
start = i;
shift = OLDNUM(i) - i;
i++;
- while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift)
+ while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
+ == shift)
i++;
size = i - start;
- if (size < 3 || size+min(size/8,2) < abs(shift))
- {
- while (start < i)
- {
+ if (size < 3 || size + min(size / 8, 2) < abs(shift)) {
+ while (start < i) {
OLDNUM(start) = _NEWINDEX;
start++;
}
@@ -417,13 +396,15 @@ void _nc_hash_map(void)
#endif
}
-void _nc_make_oldhash(int i)
+NCURSES_EXPORT(void)
+_nc_make_oldhash(int i)
{
if (oldhash)
oldhash[i] = hash(OLDTEXT(i));
}
-void _nc_scroll_oldhash(int n, int top, int bot)
+NCURSES_EXPORT(void)
+_nc_scroll_oldhash(int n, int top, int bot)
{
int size;
int i;
@@ -431,27 +412,24 @@ void _nc_scroll_oldhash(int n, int top, int bot)
if (!oldhash)
return;
- size = sizeof(*oldhash) * (bot-top+1-abs(n));
- if (n > 0)
- {
- memmove (oldhash+top, oldhash+top+n, size);
- for (i = bot; i > bot-n; i--)
+ size = sizeof(*oldhash) * (bot - top + 1 - abs(n));
+ if (n > 0) {
+ memmove(oldhash + top, oldhash + top + n, size);
+ for (i = bot; i > bot - n; i--)
oldhash[i] = hash(OLDTEXT(i));
- }
- else
- {
- memmove (oldhash+top-n, oldhash+top, size);
- for (i = top; i < top-n; i++)
+ } else {
+ memmove(oldhash + top - n, oldhash + top, size);
+ for (i = top; i < top - n; i++)
oldhash[i] = hash(OLDTEXT(i));
}
}
-
#ifdef HASHDEBUG
static void
usage(void)
{
- static const char *table[] = {
+ static const char *table[] =
+ {
"hashmap test-driver",
"",
"# comment",
@@ -463,19 +441,18 @@ usage(void)
"? this message"
};
size_t n;
- for (n = 0; n < sizeof(table)/sizeof(table[0]); n++)
+ for (n = 0; n < sizeof(table) / sizeof(table[0]); n++)
fprintf(stderr, "%s\n", table[n]);
}
int
-main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
- char line[BUFSIZ], *st;
- int n;
+ char line[BUFSIZ], *st;
+ int n;
- SP = typeCalloc(SCREEN,1);
- for (n = 0; n < screen_lines; n++)
- {
+ SP = typeCalloc(SCREEN, 1);
+ for (n = 0; n < screen_lines; n++) {
reallines[n] = n;
oldnums[n] = _NEWINDEX;
oldtext[n][0] = newtext[n][0] = '.';
@@ -487,21 +464,18 @@ main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
#ifdef TRACE
_nc_tracing = TRACE_MOVE;
#endif
- for (;;)
- {
+ for (;;) {
/* grab a test command */
- if (fgets(line, sizeof(line), stdin) == (char *)NULL)
+ if (fgets(line, sizeof(line), stdin) == (char *) NULL)
exit(EXIT_SUCCESS);
- switch(line[0])
- {
- case '#': /* comment */
+ switch (line[0]) {
+ case '#': /* comment */
(void) fputs(line, stderr);
break;
- case 'l': /* get initial line number vector */
- for (n = 0; n < screen_lines; n++)
- {
+ case 'l': /* get initial line number vector */
+ for (n = 0; n < screen_lines; n++) {
reallines[n] = n;
oldnums[n] = _NEWINDEX;
}
@@ -510,30 +484,30 @@ main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
do {
oldnums[n++] = atoi(st);
} while
- ((st = strtok((char *)NULL, " ")) != 0);
+ ((st = strtok((char *) NULL, " ")) != 0);
break;
- case 'n': /* use following letters as text of new lines */
+ case 'n': /* use following letters as text of new lines */
for (n = 0; n < screen_lines; n++)
newtext[n][0] = '.';
for (n = 0; n < screen_lines; n++)
- if (line[n+1] == '\n')
+ if (line[n + 1] == '\n')
break;
else
- newtext[n][0] = line[n+1];
+ newtext[n][0] = line[n + 1];
break;
- case 'o': /* use following letters as text of old lines */
+ case 'o': /* use following letters as text of old lines */
for (n = 0; n < screen_lines; n++)
oldtext[n][0] = '.';
for (n = 0; n < screen_lines; n++)
- if (line[n+1] == '\n')
+ if (line[n + 1] == '\n')
break;
else
- oldtext[n][0] = line[n+1];
+ oldtext[n][0] = line[n + 1];
break;
- case 'd': /* dump state of test arrays */
+ case 'd': /* dump state of test arrays */
#ifdef TRACE
_nc_linedump();
#endif
@@ -549,7 +523,7 @@ main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
putchar('\n');
break;
- case 'h': /* apply hash mapper and see scroll optimization */
+ case 'h': /* apply hash mapper and see scroll optimization */
_nc_hash_map();
(void) fputs("Result:\n", stderr);
#ifdef TRACE
diff --git a/lib/libcurses/tty/lib_mvcur.c b/lib/libcurses/tty/lib_mvcur.c
index 0c72f2b5c96..45b0a2b7178 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.9 2000/10/08 22:47:04 millert Exp $ */
+/* $OpenBSD: lib_mvcur.c,v 1.10 2001/01/22 18:02:00 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.72 2000/10/08 00:58:25 tom Exp $")
+MODULE_ID("$From: lib_mvcur.c,v 1.77 2000/12/10 03:04:30 tom Exp $")
#define CURRENT_ROW SP->_cursrow /* phys cursor row */
#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
@@ -208,8 +208,9 @@ trace_normalized_cost(const char *capname, const char *cap, int affcnt)
#endif
-int
-_nc_msec_cost(const char *const cap, int affcnt)
+NCURSES_EXPORT(int)
+_nc_msec_cost
+(const char *const cap, int affcnt)
/* compute the cost of a given operation */
{
if (cap == 0)
@@ -224,11 +225,11 @@ _nc_msec_cost(const char *const cap, int affcnt)
float number = 0.0;
for (cp += 2; *cp != '>'; cp++) {
- if (isdigit(*cp))
+ if (isdigit(CharOf(*cp)))
number = number * 10 + (*cp - '0');
else if (*cp == '*')
number *= affcnt;
- else if (*cp == '.' && (*++cp != '>') && isdigit(*cp))
+ else if (*cp == '.' && (*++cp != '>') && isdigit(CharOf(*cp)))
number += (*cp - '0') / 10.0;
}
@@ -264,7 +265,7 @@ reset_scroll_region(void)
}
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_resume(void)
/* what to do at initialization time and after each shellout */
{
@@ -294,7 +295,7 @@ _nc_mvcur_resume(void)
}
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_init(void)
/* initialize the cost structure */
{
@@ -408,7 +409,7 @@ _nc_mvcur_init(void)
_nc_mvcur_resume();
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_wrap(void)
/* wrap up cursor-addressing mode */
{
@@ -571,6 +572,8 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
#endif /* USE_HARD_TABS */
#if defined(REAL_ATTR) && defined(WANT_CHAR)
+ if (n <= 0 || n >= (int) check.s_size)
+ ovw = FALSE;
#if BSD_TPUTS
/*
* If we're allowing BSD-style padding in tputs, don't generate
@@ -828,8 +831,9 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
return (ERR);
}
-int
-mvcur(int yold, int xold, int ynew, int xnew)
+NCURSES_EXPORT(int)
+mvcur
+(int yold, int xold, int ynew, int xnew)
/* optimized cursor move from (yold, xold) to (ynew, xnew) */
{
TR(TRACE_MOVE, ("mvcur(%d,%d,%d,%d) called", yold, xold, ynew, xnew));
@@ -883,7 +887,7 @@ mvcur(int yold, int xold, int ynew, int xnew)
}
#if defined(TRACE) || defined(NCURSES_TEST)
-int _nc_optimize_enable = OPTIMIZE_ALL;
+NCURSES_EXPORT_VAR(int) _nc_optimize_enable = OPTIMIZE_ALL;
#endif
#if defined(MAIN) || defined(NCURSES_TEST)
@@ -896,13 +900,15 @@ int _nc_optimize_enable = OPTIMIZE_ALL;
#include <tic.h>
#include <dump_entry.h>
-const char *_nc_progname = "mvcur";
+NCURSES_EXPORT_VAR(const char *)
+_nc_progname = "mvcur";
-static unsigned long xmits;
+ static unsigned long xmits;
/* these override lib_tputs.c */
-int
-tputs(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
+NCURSES_EXPORT(int)
+tputs
+(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
/* stub tputs() that dumps sequences in a visible form */
{
if (profiling)
@@ -912,24 +918,25 @@ tputs(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
return (OK);
}
-int
+NCURSES_EXPORT(int)
putp(const char *string)
{
return (tputs(string, 1, _nc_outch));
}
-int
+NCURSES_EXPORT(int)
_nc_outch(int ch)
{
putc(ch, stdout);
return OK;
}
-char PC = 0; /* used by termcap library */
-short ospeed = 0; /* used by termcap library */
-int _nc_nulls_sent = 0; /* used by 'tack' program */
+NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */
+NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
+NCURSES_EXPORT_VAR(int)
+_nc_nulls_sent = 0; /* used by 'tack' program */
-int
+NCURSES_EXPORT(int)
delay_output(int ms GCC_UNUSED)
{
return OK;
diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c
index e3f0e36e372..23e99cf453e 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.7 2000/10/08 22:47:05 millert Exp $ */
+/* $OpenBSD: lib_tstp.c,v 1.8 2001/01/22 18:02:00 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -49,7 +49,7 @@
#define _POSIX_SOURCE
#endif
-MODULE_ID("$From: lib_tstp.c,v 1.22 2000/09/02 18:33:17 tom Exp $")
+MODULE_ID("$From: lib_tstp.c,v 1.24 2000/12/10 03:04:30 tom Exp $")
#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
#define USE_SIGTSTP 1
@@ -306,7 +306,7 @@ CatchIfDefault(int sig, RETSIGTYPE(*handler) (int))
* The XSI document implies that we shouldn't keep the SIGTSTP handler if
* the caller later changes its mind, but that doesn't seem correct.
*/
-void
+NCURSES_EXPORT(void)
_nc_signal_handler(bool enable)
{
#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */
diff --git a/lib/libcurses/tty/lib_twait.c b/lib/libcurses/tty/lib_twait.c
index f882f915b71..0b7c4d2949b 100644
--- a/lib/libcurses/tty/lib_twait.c
+++ b/lib/libcurses/tty/lib_twait.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_twait.c,v 1.7 2000/10/10 15:10:32 millert Exp $ */
+/* $OpenBSD: lib_twait.c,v 1.8 2001/01/22 18:02:00 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -61,7 +61,7 @@
# endif
#endif
-MODULE_ID("$From: lib_twait.c,v 1.39 2000/08/26 19:34:15 tom Exp $")
+MODULE_ID("$From: lib_twait.c,v 1.41 2000/12/10 03:04:30 tom Exp $")
static long
_nc_gettime(bool first)
@@ -104,8 +104,9 @@ _nc_gettime(bool first)
* If the milliseconds given are -1, the wait blocks until activity on the
* descriptors.
*/
-int
-_nc_timed_wait(int mode, int milliseconds, int *timeleft)
+NCURSES_EXPORT(int)
+_nc_timed_wait
+(int mode, int milliseconds, int *timeleft)
{
int fd;
int count;
diff --git a/lib/libcurses/tty/lib_vidattr.c b/lib/libcurses/tty/lib_vidattr.c
index e9639a730c6..4a5c9354b72 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.7 2000/10/22 18:27:24 millert Exp $ */
+/* $OpenBSD: lib_vidattr.c,v 1.8 2001/01/22 18:02:00 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.33 2000/10/09 22:45:29 tom Exp $")
+MODULE_ID("$From: lib_vidattr.c,v 1.36 2000/12/10 03:05:48 tom Exp $")
#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
@@ -88,8 +88,9 @@ MODULE_ID("$From: lib_vidattr.c,v 1.33 2000/10/09 22:45:29 tom Exp $")
} \
}
-int
-vidputs(attr_t newmode, int (*outc) (int))
+NCURSES_EXPORT(int)
+vidputs
+(attr_t newmode, int (*outc) (int))
{
static attr_t previous_attr = A_NORMAL;
attr_t turn_on, turn_off;
@@ -136,11 +137,13 @@ vidputs(attr_t newmode, int (*outc) (int))
* A_ALTCHARSET (256) down 2 to line up. We use the NCURSES_BITS
* macro so this will work properly for the wide-character layout.
*/
- attr_t mask = NCURSES_BITS((no_color_video & 63)
- | ((no_color_video & 192) << 1)
- | ((no_color_video & 256) >> 2), 8);
+ unsigned value = no_color_video;
+ attr_t mask = NCURSES_BITS((value & 63)
+ | ((value & 192) << 1)
+ | ((value & 256) >> 2), 8);
- if (mask & A_REVERSE && newmode & A_REVERSE) {
+ if ((mask & A_REVERSE) != 0
+ && (newmode & A_REVERSE) != 0) {
reverse = TRUE;
mask &= ~A_REVERSE;
}
@@ -250,7 +253,7 @@ vidputs(attr_t newmode, int (*outc) (int))
returnCode(OK);
}
-int
+NCURSES_EXPORT(int)
vidattr(attr_t newmode)
{
T((T_CALLED("vidattr(%s)"), _traceattr(newmode)));
@@ -258,7 +261,7 @@ vidattr(attr_t newmode)
returnCode(vidputs(newmode, _nc_outch));
}
-chtype
+NCURSES_EXPORT(chtype)
termattrs(void)
{
chtype attrs = A_NORMAL;
diff --git a/lib/libcurses/tty/tty_display.h b/lib/libcurses/tty/tty_display.h
index 198843f51e6..f1e0f47e1d1 100644
--- a/lib/libcurses/tty/tty_display.h
+++ b/lib/libcurses/tty/tty_display.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: tty_display.h,v 1.2 2000/03/10 01:35:05 millert Exp $ */
+/* $OpenBSD: tty_display.h,v 1.3 2001/01/22 18:02:00 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 *
@@ -31,20 +31,20 @@
#ifndef TTY_DISPLAY_H
#define TTY_DISPLAY_H 1
-extern bool _nc_tty_beep(void);
-extern bool _nc_tty_check_resize(void);
-extern bool _nc_tty_cursor(int);
-extern bool _nc_tty_flash(void);
-extern bool _nc_tty_init_color(int,int,int,int);
-extern bool _nc_tty_init_pair(int,int,int);
-extern bool _nc_tty_slk_hide(bool);
-extern bool _nc_tty_slk_update(int,const char *);
-extern bool _nc_tty_start_color(void);
-extern void _nc_tty_display_resume(void);
-extern void _nc_tty_display_suspend(void);
-extern void _nc_tty_dispose(void); /* frees SP->_term */
-extern void _nc_tty_switch_to(void);
-extern void _nc_tty_update(void);
+extern NCURSES_EXPORT(bool) _nc_tty_beep (void);
+extern NCURSES_EXPORT(bool) _nc_tty_check_resize (void);
+extern NCURSES_EXPORT(bool) _nc_tty_cursor (int);
+extern NCURSES_EXPORT(bool) _nc_tty_flash (void);
+extern NCURSES_EXPORT(bool) _nc_tty_init_color (int,int,int,int);
+extern NCURSES_EXPORT(bool) _nc_tty_init_pair (int,int,int);
+extern NCURSES_EXPORT(bool) _nc_tty_slk_hide (bool);
+extern NCURSES_EXPORT(bool) _nc_tty_slk_update (int,const char *);
+extern NCURSES_EXPORT(bool) _nc_tty_start_color (void);
+extern NCURSES_EXPORT(void) _nc_tty_display_resume (void);
+extern NCURSES_EXPORT(void) _nc_tty_display_suspend (void);
+extern NCURSES_EXPORT(void) _nc_tty_dispose (void); /* frees SP->_term */
+extern NCURSES_EXPORT(void) _nc_tty_switch_to (void);
+extern NCURSES_EXPORT(void) _nc_tty_update (void);
struct tty_display_data {
int _fifohold; /* set if breakout marked */
diff --git a/lib/libcurses/tty/tty_input.h b/lib/libcurses/tty/tty_input.h
index c42774be14b..21f551a49a2 100644
--- a/lib/libcurses/tty/tty_input.h
+++ b/lib/libcurses/tty/tty_input.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: tty_input.h,v 1.1 1999/01/18 19:10:27 millert Exp $ */
+/* $OpenBSD: tty_input.h,v 1.2 2001/01/22 18:02:00 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,19 +29,19 @@
****************************************************************************/
/*
- * $From: tty_input.h,v 1.1 1998/12/19 22:42:57 tom Exp $
+ * $From: tty_input.h,v 1.2 2000/12/10 02:26:51 tom Exp $
*/
#ifndef TTY_INPUT_H
#define TTY_INPUT_H 1
-extern bool _nc_tty_mouse_mask(mmask_t);
-extern bool _nc_tty_pending(void);
-extern int _nc_tty_next_event(int);
-extern void _nc_tty_flags_changed(void);
-extern void _nc_tty_flush(void);
-extern void _nc_tty_input_resume(void);
-extern void _nc_tty_input_suspend(void);
+extern NCURSES_EXPORT(bool) _nc_tty_mouse_mask (mmask_t);
+extern NCURSES_EXPORT(bool) _nc_tty_pending (void);
+extern NCURSES_EXPORT(int) _nc_tty_next_event (int);
+extern NCURSES_EXPORT(void) _nc_tty_flags_changed (void);
+extern NCURSES_EXPORT(void) _nc_tty_flush (void);
+extern NCURSES_EXPORT(void) _nc_tty_input_resume (void);
+extern NCURSES_EXPORT(void) _nc_tty_input_suspend (void);
struct tty_input_data {
int _ifd; /* input file ptr for screen */
diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c
index 25f04b0339e..194bc4343d9 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.13 2000/10/10 15:10:32 millert Exp $ */
+/* $OpenBSD: tty_update.c,v 1.14 2001/01/22 18:02:01 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.146 2000/10/07 01:11:44 tom Exp $")
+MODULE_ID("$From: tty_update.c,v 1.150 2001/01/14 00:16:22 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -527,7 +527,7 @@ callPutChar(chtype const ch)
win->_line[row].lastchar = _NOCHANGE; \
if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
-int
+NCURSES_EXPORT(int)
doupdate(void)
{
int i;
@@ -769,20 +769,20 @@ doupdate(void)
/* mark line changed successfully */
if (i <= newscr->_maxy) {
- MARK_NOCHANGE(newscr, i)
+ MARK_NOCHANGE(newscr, i);
}
if (i <= curscr->_maxy) {
- MARK_NOCHANGE(curscr, i)
+ MARK_NOCHANGE(curscr, i);
}
}
}
/* put everything back in sync */
for (i = nonempty; i <= newscr->_maxy; i++) {
- MARK_NOCHANGE(newscr, i)
+ MARK_NOCHANGE(newscr, i);
}
for (i = nonempty; i <= curscr->_maxy; i++) {
- MARK_NOCHANGE(curscr, i)
+ MARK_NOCHANGE(curscr, i);
}
if (!newscr->_leaveok) {
@@ -1284,7 +1284,7 @@ ClearScreen(chtype blank)
#if NCURSES_EXT_FUNCS
if (SP->_coloron
&& !SP->_default_color) {
- _nc_do_color(COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
+ _nc_do_color((int) COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
if (!back_color_erase) {
fast_clear = FALSE;
}
@@ -1419,7 +1419,7 @@ DelChar(int count)
** Emit a string without waiting for update.
*/
-void
+NCURSES_EXPORT(void)
_nc_outstr(const char *str)
{
(void) putp(str);
@@ -1612,8 +1612,9 @@ scroll_idl(int n, int del, int ins, chtype blank)
return OK;
}
-int
-_nc_scrolln(int n, int top, int bot, int maxy)
+NCURSES_EXPORT(int)
+_nc_scrolln
+(int n, int top, int bot, int maxy)
/* scroll region from top to bot by n lines */
{
chtype blank = ClrBlank(stdscr);
@@ -1734,7 +1735,7 @@ _nc_scrolln(int n, int top, int bot, int maxy)
return (OK);
}
-void
+NCURSES_EXPORT(void)
_nc_screen_resume(void)
{
/* make sure terminal is in a sane known state */
@@ -1760,14 +1761,14 @@ _nc_screen_resume(void)
putp(auto_right_margin ? enter_am_mode : exit_am_mode);
}
-void
+NCURSES_EXPORT(void)
_nc_screen_init(void)
{
_nc_screen_resume();
}
/* wrap up screen handling */
-void
+NCURSES_EXPORT(void)
_nc_screen_wrap(void)
{
UpdateAttrs(A_NORMAL);
@@ -1788,7 +1789,7 @@ _nc_screen_wrap(void)
}
#if USE_XMC_SUPPORT
-void
+NCURSES_EXPORT(void)
_nc_do_xmc_glitch(attr_t previous)
{
attr_t chg = XMC_CHANGES(previous ^ SP->_current_attr);