aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/tty
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/tty')
-rwxr-xr-xcontrib/ncurses/ncurses/tty/MKexpanded.sh14
-rw-r--r--contrib/ncurses/ncurses/tty/hardscroll.c71
-rw-r--r--contrib/ncurses/ncurses/tty/hashmap.c256
-rw-r--r--contrib/ncurses/ncurses/tty/lib_mvcur.c62
-rw-r--r--contrib/ncurses/ncurses/tty/lib_tstp.c4
-rw-r--r--contrib/ncurses/ncurses/tty/lib_twait.c7
-rw-r--r--contrib/ncurses/ncurses/tty/lib_vidattr.c21
-rw-r--r--contrib/ncurses/ncurses/tty/tty_display.h30
-rw-r--r--contrib/ncurses/ncurses/tty/tty_input.h18
-rw-r--r--contrib/ncurses/ncurses/tty/tty_update.c53
10 files changed, 253 insertions, 283 deletions
diff --git a/contrib/ncurses/ncurses/tty/MKexpanded.sh b/contrib/ncurses/ncurses/tty/MKexpanded.sh
index e44f58343a5d..8e4a6c6c5f03 100755
--- a/contrib/ncurses/ncurses/tty/MKexpanded.sh
+++ b/contrib/ncurses/ncurses/tty/MKexpanded.sh
@@ -29,7 +29,7 @@
#
# Author: Thomas E. Dickey <dickey@clark.net> 1997
#
-# $Id: MKexpanded.sh,v 1.9 2000/09/02 22:55:21 tom Exp $
+# $Id: 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,
@@ -68,23 +68,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);
}
@@ -94,6 +94,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/contrib/ncurses/ncurses/tty/hardscroll.c b/contrib/ncurses/ncurses/tty/hardscroll.c
index b80d08aa5467..7815db75ae37 100644
--- a/contrib/ncurses/ncurses/tty/hardscroll.c
+++ b/contrib/ncurses/ncurses/tty/hardscroll.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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,7 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/******************************************************************************
NAME
@@ -146,13 +145,14 @@ AUTHOR
#include <curses.priv.h>
-MODULE_ID("$Id: hardscroll.c,v 1.33 1999/02/27 20:01:29 tom Exp $")
+MODULE_ID("$Id: 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
@@ -163,19 +163,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;
@@ -186,8 +188,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;
@@ -205,25 +206,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;
}
@@ -231,25 +231,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;
}
@@ -258,14 +256,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);
@@ -284,28 +283,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;
}
@@ -313,7 +310,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/contrib/ncurses/ncurses/tty/hashmap.c b/contrib/ncurses/ncurses/tty/hashmap.c
index 300ac9a3232a..6d3d61d1f290 100644
--- a/contrib/ncurses/ncurses/tty/hashmap.c
+++ b/contrib/ncurses/ncurses/tty/hashmap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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 *
@@ -68,9 +68,9 @@ AUTHOR
*****************************************************************************/
#include <curses.priv.h>
-#include <term.h> /* for back_color_erase */
+#include <term.h> /* for back_color_erase */
-MODULE_ID("$Id: hashmap.c,v 1.34 1999/11/28 00:10:57 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.36 2000/12/10 03:04:30 tom Exp $")
#ifdef HASHDEBUG
@@ -100,41 +100,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++;
@@ -145,7 +147,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;
@@ -161,30 +164,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;
@@ -198,14 +199,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)
@@ -217,25 +218,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--;
@@ -245,21 +242,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++;
@@ -271,22 +264,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;
@@ -295,47 +285,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++)
@@ -345,8 +328,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++)
@@ -368,11 +350,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;
}
@@ -384,8 +365,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)
@@ -393,13 +373,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++;
}
@@ -415,13 +394,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;
@@ -429,27 +410,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",
@@ -461,19 +439,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] = '.';
@@ -485,21 +462,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;
}
@@ -508,30 +482,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
@@ -547,7 +521,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/contrib/ncurses/ncurses/tty/lib_mvcur.c b/contrib/ncurses/ncurses/tty/lib_mvcur.c
index 03abaffb4d84..cb7a5cec60f7 100644
--- a/contrib/ncurses/ncurses/tty/lib_mvcur.c
+++ b/contrib/ncurses/ncurses/tty/lib_mvcur.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 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 *
@@ -152,7 +152,7 @@
#include <term.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_mvcur.c,v 1.72 2000/10/08 00:58:25 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.78 2001/04/14 22:26:14 tom Exp $")
#define CURRENT_ROW SP->_cursrow /* phys cursor row */
#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
@@ -206,8 +206,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)
@@ -222,11 +223,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;
}
@@ -262,7 +263,7 @@ reset_scroll_region(void)
}
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_resume(void)
/* what to do at initialization time and after each shellout */
{
@@ -292,7 +293,7 @@ _nc_mvcur_resume(void)
}
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_init(void)
/* initialize the cost structure */
{
@@ -406,7 +407,7 @@ _nc_mvcur_init(void)
_nc_mvcur_resume();
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_wrap(void)
/* wrap up cursor-addressing mode */
{
@@ -569,6 +570,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
@@ -595,11 +598,18 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
if (ovw) {
int i;
- for (i = 0; i < n; i++)
- if ((WANT_CHAR(to_y, from_x + i) & A_ATTRIBUTES) != CURRENT_ATTR) {
+ for (i = 0; i < n; i++) {
+ chtype ch = WANT_CHAR(to_y, from_x + i);
+ if ((ch & A_ATTRIBUTES) != CURRENT_ATTR
+#if USE_WIDEC_SUPPORT
+ || (TextOf(ch) >= 0x80
+ && SP->_outch == _nc_utf8_outch)
+#endif
+ ) {
ovw = FALSE;
break;
}
+ }
}
if (ovw) {
int i;
@@ -826,8 +836,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));
@@ -881,7 +892,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)
@@ -894,13 +905,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)
@@ -910,24 +923,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/contrib/ncurses/ncurses/tty/lib_tstp.c b/contrib/ncurses/ncurses/tty/lib_tstp.c
index 512de68dc5ff..ba146a01aa69 100644
--- a/contrib/ncurses/ncurses/tty/lib_tstp.c
+++ b/contrib/ncurses/ncurses/tty/lib_tstp.c
@@ -47,7 +47,7 @@
#define _POSIX_SOURCE
#endif
-MODULE_ID("$Id: lib_tstp.c,v 1.22 2000/09/02 18:33:17 tom Exp $")
+MODULE_ID("$Id: 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
@@ -304,7 +304,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/contrib/ncurses/ncurses/tty/lib_twait.c b/contrib/ncurses/ncurses/tty/lib_twait.c
index 6d24d8ddc6cb..2dfcb103237e 100644
--- a/contrib/ncurses/ncurses/tty/lib_twait.c
+++ b/contrib/ncurses/ncurses/tty/lib_twait.c
@@ -59,7 +59,7 @@
# endif
#endif
-MODULE_ID("$Id: lib_twait.c,v 1.39 2000/08/26 19:34:15 tom Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.41 2000/12/10 03:04:30 tom Exp $")
static long
_nc_gettime(bool first)
@@ -102,8 +102,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/contrib/ncurses/ncurses/tty/lib_vidattr.c b/contrib/ncurses/ncurses/tty/lib_vidattr.c
index 5022cbdde78a..464973de32c3 100644
--- a/contrib/ncurses/ncurses/tty/lib_vidattr.c
+++ b/contrib/ncurses/ncurses/tty/lib_vidattr.c
@@ -64,7 +64,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_vidattr.c,v 1.33 2000/10/09 22:45:29 tom Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.36 2000/12/10 03:05:48 tom Exp $")
#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
@@ -86,8 +86,9 @@ MODULE_ID("$Id: 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;
@@ -134,11 +135,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;
}
@@ -248,7 +251,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)));
@@ -256,7 +259,7 @@ vidattr(attr_t newmode)
returnCode(vidputs(newmode, _nc_outch));
}
-chtype
+NCURSES_EXPORT(chtype)
termattrs(void)
{
chtype attrs = A_NORMAL;
diff --git a/contrib/ncurses/ncurses/tty/tty_display.h b/contrib/ncurses/ncurses/tty/tty_display.h
index e7b447d8045d..8382c823f06a 100644
--- a/contrib/ncurses/ncurses/tty/tty_display.h
+++ b/contrib/ncurses/ncurses/tty/tty_display.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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,20 +29,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/contrib/ncurses/ncurses/tty/tty_input.h b/contrib/ncurses/ncurses/tty/tty_input.h
index 41c228338990..e520793eea64 100644
--- a/contrib/ncurses/ncurses/tty/tty_input.h
+++ b/contrib/ncurses/ncurses/tty/tty_input.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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 *
@@ -27,19 +27,19 @@
****************************************************************************/
/*
- * $Id: tty_input.h,v 1.1 1998/12/19 22:42:57 tom Exp $
+ * $Id: 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/contrib/ncurses/ncurses/tty/tty_update.c b/contrib/ncurses/ncurses/tty/tty_update.c
index 298c11ed0a21..d292ad35b975 100644
--- a/contrib/ncurses/ncurses/tty/tty_update.c
+++ b/contrib/ncurses/ncurses/tty/tty_update.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 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,7 +70,7 @@
#include <term.h>
-MODULE_ID("$Id: tty_update.c,v 1.146 2000/10/07 01:11:44 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.151 2001/02/03 23:41:55 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -274,18 +274,6 @@ check_pending(void)
return FALSE;
}
-/*
- * No one supports recursive inline functions. However, gcc is quieter if we
- * instantiate the recursive part separately.
- */
-#if CC_HAS_INLINE_FUNCS
-static void callPutChar(chtype const);
-#else
-#define callPutChar(ch) PutChar(ch)
-#endif
-
-static inline void PutChar(chtype const ch); /* forward declaration */
-
/* put char at lower right corner */
static void
PutCharLR(chtype const ch)
@@ -307,7 +295,7 @@ PutCharLR(chtype const ch)
} else if ((enter_insert_mode && exit_insert_mode)
|| insert_character || parm_ich) {
GoTo(screen_lines - 1, screen_columns - 2);
- callPutChar(ch);
+ PutAttrChar(ch);
GoTo(screen_lines - 1, screen_columns - 2);
InsStr(newscr->_line[screen_lines - 1].text + screen_columns - 2, 1);
}
@@ -508,21 +496,13 @@ PutRange(
return EmitRange(ntext + first, last - first + 1);
}
-#if CC_HAS_INLINE_FUNCS
-static void
-callPutChar(chtype const ch)
-{
- PutChar(ch);
-}
-#endif
-
/* leave unbracketed here so 'indent' works */
#define MARK_NOCHANGE(win,row) \
win->_line[row].firstchar = _NOCHANGE; \
win->_line[row].lastchar = _NOCHANGE; \
if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
-int
+NCURSES_EXPORT(int)
doupdate(void)
{
int i;
@@ -764,20 +744,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) {
@@ -1279,7 +1259,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;
}
@@ -1414,7 +1394,7 @@ DelChar(int count)
** Emit a string without waiting for update.
*/
-void
+NCURSES_EXPORT(void)
_nc_outstr(const char *str)
{
(void) putp(str);
@@ -1607,8 +1587,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);
@@ -1729,7 +1710,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 */
@@ -1755,14 +1736,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);
@@ -1783,7 +1764,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);