summaryrefslogtreecommitdiffstats
path: root/contrib/ncurses/test
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
committerpeter <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
commit9a7523d4b2c09cefef7372e8a011b8d54fb07e5e (patch)
treebd986d58f5a6e348466b5362637ba93e6cd5bf8c /contrib/ncurses/test
parent635048e64c28721e175b82444857d679f6740aa2 (diff)
downloadFreeBSD-src-9a7523d4b2c09cefef7372e8a011b8d54fb07e5e.zip
FreeBSD-src-9a7523d4b2c09cefef7372e8a011b8d54fb07e5e.tar.gz
Import ncurses-5.2-20020518 onto the vendor branch.
Obtained from: ftp://dickey.his.com/ncurses/
Diffstat (limited to 'contrib/ncurses/test')
-rw-r--r--contrib/ncurses/test/Makefile.in6
-rw-r--r--contrib/ncurses/test/blue.c321
-rw-r--r--contrib/ncurses/test/bs.c62
-rw-r--r--contrib/ncurses/test/cardfile.c28
-rwxr-xr-xcontrib/ncurses/test/configure537
-rw-r--r--contrib/ncurses/test/configure.in142
-rw-r--r--contrib/ncurses/test/ditto.c154
-rw-r--r--contrib/ncurses/test/dots.c29
-rw-r--r--contrib/ncurses/test/filter.c11
-rw-r--r--contrib/ncurses/test/firework.c17
-rw-r--r--contrib/ncurses/test/firstlast.c149
-rw-r--r--contrib/ncurses/test/gdc.c18
-rw-r--r--contrib/ncurses/test/hanoi.c22
-rw-r--r--contrib/ncurses/test/hashtest.c14
-rw-r--r--contrib/ncurses/test/keynames.c15
-rw-r--r--contrib/ncurses/test/knight.c10
-rw-r--r--contrib/ncurses/test/lrtest.c5
-rw-r--r--contrib/ncurses/test/ncurses.c826
-rw-r--r--contrib/ncurses/test/newdemo.c14
-rw-r--r--contrib/ncurses/test/railroad.c62
-rw-r--r--contrib/ncurses/test/rain.c101
-rw-r--r--contrib/ncurses/test/tclock.c34
-rw-r--r--contrib/ncurses/test/test.priv.h108
-rw-r--r--contrib/ncurses/test/testaddch.c89
-rw-r--r--contrib/ncurses/test/testcurs.c101
-rw-r--r--contrib/ncurses/test/testscanw.c6
-rw-r--r--contrib/ncurses/test/view.c264
-rw-r--r--contrib/ncurses/test/worm.c28
-rw-r--r--contrib/ncurses/test/xmas.c13
29 files changed, 2220 insertions, 966 deletions
diff --git a/contrib/ncurses/test/Makefile.in b/contrib/ncurses/test/Makefile.in
index b99957b..833b57f 100644
--- a/contrib/ncurses/test/Makefile.in
+++ b/contrib/ncurses/test/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.61 2001/03/24 19:53:31 tom Exp $
+# $Id: Makefile.in,v 1.63 2002/02/03 00:54:10 china Exp $
##############################################################################
# Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. #
# #
@@ -69,7 +69,7 @@ LOCAL_LIBS = @TEST_DEPS@
MATH_LIB = @MATH_LIB@
LD = @LD@
-LINK = @LINK_TESTS@ $(LIBTOOL) $(CC)
+LINK = @LINK_TESTS@ $(LIBTOOL) $(CC) $(CFLAGS)
LDFLAGS = @LD_MODEL@ @TEST_ARGS@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
@@ -201,7 +201,7 @@ uninstall.libs:
uninstall.test:
mostlyclean ::
- -rm -f core tags TAGS *~ *.i *.ln *.atac trace
+ -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
clean :: mostlyclean
-rm -rf *.o screendump *.lis $(TESTS) .libs
diff --git a/contrib/ncurses/test/blue.c b/contrib/ncurses/test/blue.c
index 4f73351..5daba2e 100644
--- a/contrib/ncurses/test/blue.c
+++ b/contrib/ncurses/test/blue.c
@@ -13,16 +13,12 @@
* results, use the ncurses(3) library. On non-Intel machines, SVr4 curses is
* just as good.
*
- * $Id: blue.c,v 1.18 1999/01/17 00:11:56 tom Exp $
+ * $Id: blue.c,v 1.23 2002/04/06 23:05:16 tom Exp $
*/
-#include <test.priv.h>
-
-#include <string.h>
-#include <signal.h>
#include <time.h>
-#include <term.h>
+#include <test.priv.h>
#define NOCARD (-1)
@@ -55,7 +51,7 @@ static int deck[PACK_SIZE];
static int grid[GRID_LENGTH]; /* card layout grid */
static int freeptr[4]; /* free card space pointers */
-static int deal_number=0;
+static int deal_number = 0;
static chtype ranks[SUIT_LENGTH][2] =
{
@@ -106,75 +102,75 @@ static chtype glyphs[] =
static chtype *suits = letters; /* this may change to glyphs below */
-static RETSIGTYPE die(int onsig)
+static RETSIGTYPE
+die(int onsig)
{
(void) signal(onsig, SIG_IGN);
endwin();
- exit(EXIT_SUCCESS);
+ ExitProgram(EXIT_SUCCESS);
}
-static void init_vars(void)
+static void
+init_vars(void)
{
int i;
deck_size = PACK_SIZE;
- for (i=0; i < PACK_SIZE; i++)
- deck[i]=i;
+ for (i = 0; i < PACK_SIZE; i++)
+ deck[i] = i;
for (i = 0; i < 4; i++)
- freeptr[i]=i * GRID_WIDTH;
+ freeptr[i] = i * GRID_WIDTH;
}
-static void shuffle(int size)
+static void
+shuffle(int size)
{
- int i,j,numswaps,swapnum,temp;
+ int i, j, numswaps, swapnum, temp;
- numswaps=size*10; /* an arbitrary figure */
+ numswaps = size * 10; /* an arbitrary figure */
- for (swapnum=0;swapnum<numswaps;swapnum++)
- {
- i=rand() % size;
- j=rand() % size;
- temp=deck[i];
- deck[i]=deck[j];
- deck[j]=temp;
+ for (swapnum = 0; swapnum < numswaps; swapnum++) {
+ i = rand() % size;
+ j = rand() % size;
+ temp = deck[i];
+ deck[i] = deck[j];
+ deck[j] = temp;
}
}
-static void deal_cards(void)
+static void
+deal_cards(void)
{
- int ptr, card=0, value, csuit, crank, suit, aces[4];
-
- for (suit=HEARTS;suit<=CLUBS;suit++)
- {
- ptr=freeptr[suit];
- grid[ptr++]=NOCARD; /* 1st card space is blank */
- while ((ptr % GRID_WIDTH) != 0)
- {
- value=deck[card++];
- crank=value % SUIT_LENGTH;
- csuit=value / SUIT_LENGTH;
- if (crank==ACE)
- aces[csuit]=ptr;
- grid[ptr++]=value;
+ int ptr, card = 0, value, csuit, crank, suit, aces[4];
+
+ for (suit = HEARTS; suit <= CLUBS; suit++) {
+ ptr = freeptr[suit];
+ grid[ptr++] = NOCARD; /* 1st card space is blank */
+ while ((ptr % GRID_WIDTH) != 0) {
+ value = deck[card++];
+ crank = value % SUIT_LENGTH;
+ csuit = value / SUIT_LENGTH;
+ if (crank == ACE)
+ aces[csuit] = ptr;
+ grid[ptr++] = value;
}
}
- if (deal_number==1) /* shift the aces down to the 1st column */
- for (suit=HEARTS;suit<=CLUBS;suit++)
- {
+ if (deal_number == 1) /* shift the aces down to the 1st column */
+ for (suit = HEARTS; suit <= CLUBS; suit++) {
grid[suit * GRID_WIDTH] = suit * SUIT_LENGTH;
- grid[aces[suit]]=NOCARD;
- freeptr[suit]=aces[suit];
+ grid[aces[suit]] = NOCARD;
+ freeptr[suit] = aces[suit];
}
}
-static void printcard(int value)
+static void
+printcard(int value)
{
(void) addch(' ');
if (value == NOCARD)
(void) addstr(" ");
- else
- {
+ else {
addch(ranks[value % SUIT_LENGTH][0] | COLOR_PAIR(BLUE_ON_WHITE));
addch(ranks[value % SUIT_LENGTH][1] | COLOR_PAIR(BLUE_ON_WHITE));
addch(suits[value / SUIT_LENGTH]);
@@ -182,151 +178,144 @@ static void printcard(int value)
(void) addch(' ');
}
-static void display_cards(int deal)
+static void
+display_cards(int deal)
{
int row, card;
clear();
- (void)printw(
- "Blue Moon 2.1 - by Tim Lister & Eric Raymond - Deal %d.\n",
- deal);
- for(row=HEARTS;row<=CLUBS;row++)
- {
+ (void) printw(
+ "Blue Moon 2.1 - by Tim Lister & Eric Raymond - Deal %d.\n",
+ deal);
+ for (row = HEARTS; row <= CLUBS; row++) {
move(BASEROW + row + row + 2, 1);
- for(card=0;card<GRID_WIDTH;card++)
+ for (card = 0; card < GRID_WIDTH; card++)
printcard(grid[row * GRID_WIDTH + card]);
}
- move(PROMPTROW + 2, 0); refresh();
+ move(PROMPTROW + 2, 0);
+ refresh();
#define P(x) (void)printw("%s\n", x)
-P(" This 52-card solitaire starts with the entire deck shuffled and dealt");
-P("out in four rows. The aces are then moved to the left end of the layout,");
-P("making 4 initial free spaces. You may move to a space only the card that");
-P("matches the left neighbor in suit, and is one greater in rank. Kings are");
-P("high, so no cards may be placed to their right (they create dead spaces).");
-P(" When no moves can be made, cards still out of sequence are reshuffled");
-P("and dealt face up after the ends of the partial sequences, leaving a card");
-P("space after each sequence, so that each row looks like a partial sequence");
-P("followed by a space, followed by enough cards to make a row of 14. ");
-P(" A moment's reflection will show that this game cannot take more than 13");
-P("deals. A good score is 1-3 deals, 4-7 is average, 8 or more is poor. ");
+ P(" This 52-card solitaire starts with the entire deck shuffled and dealt");
+ P("out in four rows. The aces are then moved to the left end of the layout,");
+ P("making 4 initial free spaces. You may move to a space only the card that");
+ P("matches the left neighbor in suit, and is one greater in rank. Kings are");
+ P("high, so no cards may be placed to their right (they create dead spaces).");
+ P(" When no moves can be made, cards still out of sequence are reshuffled");
+ P("and dealt face up after the ends of the partial sequences, leaving a card");
+ P("space after each sequence, so that each row looks like a partial sequence");
+ P("followed by a space, followed by enough cards to make a row of 14. ");
+ P(" A moment's reflection will show that this game cannot take more than 13");
+ P("deals. A good score is 1-3 deals, 4-7 is average, 8 or more is poor. ");
#undef P
refresh();
}
-static int find(int card)
+static int
+find(int card)
{
int i;
- if ((card<0) || (card>=PACK_SIZE))
- return(NOCARD);
- for(i = 0; i < GRID_LENGTH; i++)
+ if ((card < 0) || (card >= PACK_SIZE))
+ return (NOCARD);
+ for (i = 0; i < GRID_LENGTH; i++)
if (grid[i] == card)
return i;
- return(NOCARD);
+ return (NOCARD);
}
-static void movecard(int src, int dst)
+static void
+movecard(int src, int dst)
{
- grid[dst]=grid[src];
- grid[src]=NOCARD;
+ grid[dst] = grid[src];
+ grid[src] = NOCARD;
- move( BASEROW + (dst / GRID_WIDTH)*2+2, (dst % GRID_WIDTH)*5 + 1);
+ move(BASEROW + (dst / GRID_WIDTH) * 2 + 2, (dst % GRID_WIDTH) * 5 + 1);
printcard(grid[dst]);
- move( BASEROW + (src / GRID_WIDTH)*2+2, (src % GRID_WIDTH)*5 + 1);
+ move(BASEROW + (src / GRID_WIDTH) * 2 + 2, (src % GRID_WIDTH) * 5 + 1);
printcard(grid[src]);
refresh();
}
-static void play_game(void)
+static void
+play_game(void)
{
- int dead=0, i, j;
+ int dead = 0, i, j;
char c;
int selection[4], card;
- while (dead<4)
- {
- dead=0;
- for (i=0;i<4;i++)
- {
- card=grid[freeptr[i]-1];
+ while (dead < 4) {
+ dead = 0;
+ for (i = 0; i < 4; i++) {
+ card = grid[freeptr[i] - 1];
- if ( ((card % SUIT_LENGTH)==KING)
+ if (((card % SUIT_LENGTH) == KING)
||
- (card==NOCARD) )
- selection[i]=NOCARD;
+ (card == NOCARD))
+ selection[i] = NOCARD;
else
- selection[i]=find(card+1);
+ selection[i] = find(card + 1);
- if (selection[i]==NOCARD)
+ if (selection[i] == NOCARD)
dead++;
};
- if (dead < 4)
- {
- char live[NSUITS+1], *lp = live;
-
- for (i=0;i<4;i++)
- {
- if (selection[i] != NOCARD)
- {
- move(BASEROW + (selection[i] / GRID_WIDTH)*2+3,
- (selection[i] % GRID_WIDTH)*5);
- (void)printw(" %c ", *lp++ = 'a' + i);
+ if (dead < 4) {
+ char live[NSUITS + 1], *lp = live;
+
+ for (i = 0; i < 4; i++) {
+ if (selection[i] != NOCARD) {
+ move(BASEROW + (selection[i] / GRID_WIDTH) * 2 + 3,
+ (selection[i] % GRID_WIDTH) * 5);
+ (void) printw(" %c ", *lp++ = 'a' + i);
}
};
*lp = '\0';
- if (strlen(live) == 1)
- {
- move(PROMPTROW,0);
- (void)printw(
- "Making forced moves... ");
+ if (strlen(live) == 1) {
+ move(PROMPTROW, 0);
+ (void) printw(
+ "Making forced moves... ");
refresh();
(void) sleep(1);
c = live[0];
- }
- else
- {
- char buf[BUFSIZ];
+ } else {
+ char buf[BUFSIZ];
- (void)sprintf(buf,
- "Type [%s] to move, r to redraw, q or INTR to quit: ",
- live);
+ (void) sprintf(buf,
+ "Type [%s] to move, r to redraw, q or INTR to quit: ",
+ live);
do {
- move(PROMPTROW,0);
+ move(PROMPTROW, 0);
(void) addstr(buf);
- move(PROMPTROW, (int)strlen(buf));
+ move(PROMPTROW, (int) strlen(buf));
clrtoeol();
(void) addch(' ');
} while
- (((c = getch())<'a' || c>'d') && (c!='r') && (c!='q'));
+ (((c = getch()) < 'a' || c > 'd') && (c != 'r') && (c != 'q'));
}
for (j = 0; j < 4; j++)
- if (selection[j]!=NOCARD)
- {
- move(BASEROW + (selection[j] / GRID_WIDTH)*2+3,
- (selection[j] % GRID_WIDTH)*5);
- (void)printw(" ");
+ if (selection[j] != NOCARD) {
+ move(BASEROW + (selection[j] / GRID_WIDTH) * 2 + 3,
+ (selection[j] % GRID_WIDTH) * 5);
+ (void) printw(" ");
}
if (c == 'r')
display_cards(deal_number);
else if (c == 'q')
die(SIGINT);
- else
- {
- i = c-'a';
+ else {
+ i = c - 'a';
if (selection[i] == NOCARD)
beep();
- else
- {
+ else {
movecard(selection[i], freeptr[i]);
- freeptr[i]=selection[i];
+ freeptr[i] = selection[i];
}
}
}
@@ -334,54 +323,54 @@ static void play_game(void)
move(PROMPTROW, 0);
standout();
- (void)printw("Finished deal %d - type any character to continue...", deal_number);
+ (void) printw("Finished deal %d - type any character to continue...", deal_number);
standend();
(void) getch();
}
-static int collect_discards(void)
+static int
+collect_discards(void)
{
- int row, col, cardno=0, finish, gridno;
-
- for (row=HEARTS;row<=CLUBS;row++)
- {
- finish=0;
- for (col=1;col<GRID_WIDTH;col++)
- {
- gridno=row * GRID_WIDTH + col;
-
- if ((grid[gridno]!=(grid[gridno-1]+1))&&(finish==0))
- {
- finish=1;
- freeptr[row]=gridno;
+ int row, col, cardno = 0, finish, gridno;
+
+ for (row = HEARTS; row <= CLUBS; row++) {
+ finish = 0;
+ for (col = 1; col < GRID_WIDTH; col++) {
+ gridno = row * GRID_WIDTH + col;
+
+ if ((grid[gridno] != (grid[gridno - 1] + 1)) && (finish == 0)) {
+ finish = 1;
+ freeptr[row] = gridno;
};
- if ((finish!=0)&&(grid[gridno]!=NOCARD))
- deck[cardno++]=grid[gridno];
+ if ((finish != 0) && (grid[gridno] != NOCARD))
+ deck[cardno++] = grid[gridno];
}
}
return cardno;
}
-static void game_finished(int deal)
+static void
+game_finished(int deal)
{
clear();
- (void)printw("You finished the game in %d deals. This is ",deal);
+ (void) printw("You finished the game in %d deals. This is ", deal);
standout();
- if (deal<2)
- (void)addstr("excellent");
- else if (deal<4)
- (void)addstr("good");
- else if (deal<8)
- (void)addstr("average");
+ if (deal < 2)
+ (void) addstr("excellent");
+ else if (deal < 4)
+ (void) addstr("good");
+ else if (deal < 8)
+ (void) addstr("average");
else
- (void)addstr("poor");
+ (void) addstr("poor");
standend();
(void) addstr(". ");
refresh();
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
(void) signal(SIGINT, die);
initscr();
@@ -390,20 +379,20 @@ int main(int argc, char *argv[])
* We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing.
*/
start_color();
- init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);
- init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE);
- init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);
+ init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);
+ init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE);
+ init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);
#ifndef COLOR_PAIR
- letters[0] = OR_COLORS('h', RED_ON_WHITE); /* hearts */
+ letters[0] = OR_COLORS('h', RED_ON_WHITE); /* hearts */
letters[1] = OR_COLORS('s', BLACK_ON_WHITE); /* spades */
- letters[2] = OR_COLORS('d', RED_ON_WHITE); /* diamonds */
+ letters[2] = OR_COLORS('d', RED_ON_WHITE); /* diamonds */
letters[3] = OR_COLORS('c', BLACK_ON_WHITE); /* clubs */
#if defined(__i386__) && defined(A_ALTCHARSET)
- glyphs[0] = PC_COLORS('\003', RED_ON_WHITE); /* hearts */
- glyphs[1] = PC_COLORS('\006', BLACK_ON_WHITE); /* spades */
- glyphs[2] = PC_COLORS('\004', RED_ON_WHITE); /* diamonds */
- glyphs[3] = PC_COLORS('\005', BLACK_ON_WHITE); /* clubs */
+ glyphs[0] = PC_COLORS('\003', RED_ON_WHITE); /* hearts */
+ glyphs[1] = PC_COLORS('\006', BLACK_ON_WHITE); /* spades */
+ glyphs[2] = PC_COLORS('\004', RED_ON_WHITE); /* diamonds */
+ glyphs[3] = PC_COLORS('\005', BLACK_ON_WHITE); /* clubs */
#endif
#endif
@@ -415,13 +404,13 @@ int main(int argc, char *argv[])
cbreak();
if (argc == 2)
- srand((unsigned)atoi(argv[1]));
+ srand((unsigned) atoi(argv[1]));
else
- srand((unsigned)time((time_t *)0));
+ srand((unsigned) time((time_t *) 0));
init_vars();
- do{
+ do {
deal_number++;
shuffle(deck_size);
deal_cards();
@@ -429,12 +418,12 @@ int main(int argc, char *argv[])
play_game();
}
while
- ((deck_size=collect_discards()) != 0);
+ ((deck_size = collect_discards()) != 0);
game_finished(deal_number);
die(SIGINT);
- /*NOTREACHED*/
+ /*NOTREACHED */
}
/* blue.c ends here */
diff --git a/contrib/ncurses/test/bs.c b/contrib/ncurses/test/bs.c
index 3a22c1d..2d3a7fb 100644
--- a/contrib/ncurses/test/bs.c
+++ b/contrib/ncurses/test/bs.c
@@ -7,30 +7,19 @@
* v2.0 featuring strict ANSI/POSIX conformance, November 1993.
* v2.1 with ncurses mouse support, September 1995
*
- * $Id: bs.c,v 1.29 2001/04/14 22:36:05 Erik.Sigra Exp $
+ * $Id: bs.c,v 1.35 2002/04/06 23:10:12 tom Exp $
*/
-#include <test.priv.h>
-
-#include <signal.h>
#include <ctype.h>
-#include <string.h>
#include <assert.h>
#include <time.h>
+#include <test.priv.h>
+
#ifndef SIGIOT
#define SIGIOT SIGABRT
#endif
-#ifndef A_UNDERLINE /* BSD curses */
-#define beep() write(1,"\007",1);
-#define cbreak crmode
-#define saveterm savetty
-#define resetterm resetty
-#define nocbreak nocrmode
-#define strchr index
-#endif /* !A_UNDERLINE */
-
static int getcoord(int);
/*
@@ -57,7 +46,7 @@ static int getcoord(int);
/* display symbols */
#define SHOWHIT '*'
#define SHOWSPLASH ' '
-#define IS_SHIP(c) (isupper(CharOf(c)) ? TRUE : FALSE)
+#define IS_SHIP(c) (isupper(UChar(c)) ? TRUE : FALSE)
/* how to position us on player board */
#define PYBASE 3
@@ -122,8 +111,8 @@ typedef struct {
int hits; /* how many times has this ship been hit? */
char symbol; /* symbol for game purposes */
int length; /* length of ship */
- char x, y; /* coordinates of ship start point */
- unsigned char dir; /* direction of `bow' */
+ int x, y; /* coordinates of ship start point */
+ int dir; /* direction of `bow' */
bool placed; /* has it been placed on the board? */
} ship_t;
@@ -160,18 +149,17 @@ static int salvo, blitz, closepack;
#define PR (void)addstr
-static RETSIGTYPE
-uninitgame(int sig) GCC_NORETURN;
+static RETSIGTYPE uninitgame(int sig) GCC_NORETURN;
- static RETSIGTYPE uninitgame(int sig GCC_UNUSED)
+static RETSIGTYPE uninitgame(int sig GCC_UNUSED)
/* end the game, either normally or due to signal */
{
clear();
(void) refresh();
- (void) resetterm();
+ (void) reset_shell_mode();
(void) echo();
(void) endwin();
- exit(EXIT_FAILURE);
+ ExitProgram(sig ? EXIT_FAILURE : EXIT_SUCCESS);
}
static void
@@ -217,10 +205,8 @@ intro(void)
(void) strcpy(name, dftname);
(void) initscr();
-#ifdef KEY_MIN
keypad(stdscr, TRUE);
-#endif /* KEY_MIN */
- (void) saveterm();
+ (void) def_prog_mode();
(void) nonl();
(void) cbreak();
(void) noecho();
@@ -549,65 +535,49 @@ getcoord(int atcpu)
switch (c = getch()) {
case 'k':
case '8':
-#ifdef KEY_MIN
case KEY_UP:
-#endif /* KEY_MIN */
ny = cury + BDEPTH - 1;
nx = curx;
break;
case 'j':
case '2':
-#ifdef KEY_MIN
case KEY_DOWN:
-#endif /* KEY_MIN */
ny = cury + 1;
nx = curx;
break;
case 'h':
case '4':
-#ifdef KEY_MIN
case KEY_LEFT:
-#endif /* KEY_MIN */
ny = cury;
nx = curx + BWIDTH - 1;
break;
case 'l':
case '6':
-#ifdef KEY_MIN
case KEY_RIGHT:
-#endif /* KEY_MIN */
ny = cury;
nx = curx + 1;
break;
case 'y':
case '7':
-#ifdef KEY_MIN
case KEY_A1:
-#endif /* KEY_MIN */
ny = cury + BDEPTH - 1;
nx = curx + BWIDTH - 1;
break;
case 'b':
case '1':
-#ifdef KEY_MIN
case KEY_C1:
-#endif /* KEY_MIN */
ny = cury + 1;
nx = curx + BWIDTH - 1;
break;
case 'u':
case '9':
-#ifdef KEY_MIN
case KEY_A3:
-#endif /* KEY_MIN */
ny = cury + BDEPTH - 1;
nx = curx + 1;
break;
case 'n':
case '3':
-#ifdef KEY_MIN
case KEY_C3:
-#endif /* KEY_MIN */
ny = cury + 1;
nx = curx + 1;
break;
@@ -943,7 +913,7 @@ randomfire(int *px, int *py)
--srchstep;
} else {
error("No moves possible?? Help!");
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
/*NOTREACHED */
}
}
@@ -1159,7 +1129,7 @@ do_options(int c, char *op[])
(void) fprintf(stderr, "\t-s : play a salvo game\n");
(void) fprintf(stderr, "\t-b : play a blitz game\n");
(void) fprintf(stderr, "\t-c : ships may be adjacent\n");
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
break;
case '-':
switch (op[i][1]) {
@@ -1168,7 +1138,7 @@ do_options(int c, char *op[])
if (salvo == 1) {
(void) fprintf(stderr,
"Bad Arg: -b and -s are mutually exclusive\n");
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
break;
case 's':
@@ -1176,7 +1146,7 @@ do_options(int c, char *op[])
if (blitz == 1) {
(void) fprintf(stderr,
"Bad Arg: -s and -b are mutually exclusive\n");
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
break;
case 'c':
@@ -1186,7 +1156,7 @@ do_options(int c, char *op[])
(void) fprintf(stderr,
"Bad arg: type \"%s ?\" for usage message\n",
op[0]);
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
}
}
diff --git a/contrib/ncurses/test/cardfile.c b/contrib/ncurses/test/cardfile.c
index a705d9d..8edbd1e 100644
--- a/contrib/ncurses/test/cardfile.c
+++ b/contrib/ncurses/test/cardfile.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2001,2002 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,17 +29,18 @@
/*
* Author: Thomas E. Dickey <dickey@clark.net> 1999
*
- * $Id: cardfile.c,v 1.6 2000/11/04 23:14:28 tom Exp $
+ * $Id: cardfile.c,v 1.11 2002/04/06 23:12:50 tom Exp $
*
* File format: text beginning in column 1 is a title; other text forms the content.
*/
#include <test.priv.h>
+#if HAVE_FORM_H && HAVE_PANEL_H && HAVE_LIBFORM && HAVE_LIBPANEL
+
#include <form.h>
#include <panel.h>
-#include <string.h>
#include <ctype.h>
#define VISIBLE_CARDS 10
@@ -75,7 +76,7 @@ strdup(char *s)
static const char *
skip(const char *buffer)
{
- while (isspace(CharOf(*buffer)))
+ while (isspace(UChar(*buffer)))
buffer++;
return buffer;
}
@@ -84,7 +85,7 @@ static void
trim(char *buffer)
{
unsigned n = strlen(buffer);
- while (n-- && isspace(CharOf(buffer[n])))
+ while (n-- && isspace(UChar(buffer[n])))
buffer[n] = 0;
}
@@ -166,7 +167,7 @@ read_data(char *fname)
if ((fp = fopen(fname, "r")) != 0) {
while (fgets(buffer, sizeof(buffer), fp)) {
trim(buffer);
- if (isspace(CharOf(*buffer))) {
+ if (isspace(UChar(*buffer))) {
if (card == 0)
card = add_title("");
add_content(card, buffer);
@@ -378,6 +379,11 @@ cardfile(char *fname)
case MAX_FORM_COMMAND + 4:
write_data(fname);
break;
+#ifdef KEY_RESIZE
+ case KEY_RESIZE:
+ flash();
+ break;
+#endif
default:
beep();
break;
@@ -416,5 +422,13 @@ main(int argc, char *argv[])
endwin();
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
+#else
+int
+main(void)
+{
+ printf("This program requires the curses form and panel libraries\n");
+ ExitProgram(EXIT_FAILURE);
+}
+#endif
diff --git a/contrib/ncurses/test/configure b/contrib/ncurses/test/configure
index de1cf77..8d44c2b 100755
--- a/contrib/ncurses/test/configure
+++ b/contrib/ncurses/test/configure
@@ -184,6 +184,7 @@ EOF
cat <<EOF
--enable and --with options recognized:
--with-5lib use SunOS sysv-libraries
+ --with-ncursesw use wide ncurses-libraries (installed)
--with-ncurses use ncurses-libraries (installed)
EOF
exit 0 ;;
@@ -528,7 +529,7 @@ fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:532: checking for $ac_word" >&5
+echo "configure:533: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -558,7 +559,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:562: checking for $ac_word" >&5
+echo "configure:563: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -609,7 +610,7 @@ fi
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:613: checking for $ac_word" >&5
+echo "configure:614: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -641,7 +642,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:645: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:646: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -652,12 +653,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 656 "configure"
+#line 657 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -683,12 +684,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:687: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:688: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:692: checking whether we are using GNU C" >&5
+echo "configure:693: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -697,7 +698,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:701: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:702: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -716,7 +717,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:720: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:721: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -784,16 +785,239 @@ fi
+
+# Check whether --with-ncursesw or --without-ncursesw was given.
+if test "${with_ncursesw+set}" = set; then
+ withval="$with_ncursesw"
+
+ cat >> confdefs.h <<\EOF
+#define _GNU_SOURCE 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define _XOPEN_SOURCE_EXTENDED 1
+EOF
+
+ echo $ac_n "checking for initscr""... $ac_c" 1>&6
+echo "configure:803: checking for initscr" >&5
+if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 808 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char initscr(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char initscr();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_initscr) || defined (__stub___initscr)
+choke me
+#else
+initscr();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_initscr=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_initscr=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'initscr`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ :
+else
+ echo "$ac_t""no" 1>&6
+
+ echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
+echo "configure:850: checking for Gpm_Open in -lgpm" >&5
+ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lgpm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 858 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char Gpm_Open();
+
+int main() {
+Gpm_Open()
+; return 0; }
+EOF
+if { (eval echo configure:869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo gpm | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lgpm $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ LIB_NAME=ncursesw
+ echo $ac_n "checking for putwc""... $ac_c" 1>&6
+echo "configure:898: checking for putwc" >&5
+if eval "test \"`echo '$''{'ac_cv_func_putwc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 903 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char putwc(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char putwc();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_putwc) || defined (__stub___putwc)
+choke me
+#else
+putwc();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_putwc=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_putwc=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'putwc`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ :
+else
+ echo "$ac_t""no" 1>&6
+
+echo $ac_n "checking for putwc in libutf8""... $ac_c" 1>&6
+echo "configure:945: checking for putwc in libutf8" >&5
+if eval "test \"`echo '$''{'cf_cv_libutf8'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ cf_save_LIBS="$LIBS"
+ LIBS="-lutf8 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 953 "configure"
+#include "confdefs.h"
+
+#include <libutf8.h>
+int main() {
+putwc(0,0);
+; return 0; }
+EOF
+if { (eval echo configure:961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ cf_cv_libutf8=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ cf_cv_libutf8=no
+fi
+rm -f conftest*
+ LIBS="$cf_save_LIBS"
+
+fi
+
+echo "$ac_t""$cf_cv_libutf8" 1>&6
+
+if test "$cf_cv_libutf8" = yes ; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_LIBUTF8_H 1
+EOF
+
+ LIBS="-lutf8 $LIBS"
+fi
+
+fi
+
+ for p in $HOME /usr/local /usr
+ do
+ if test -f $p/include/ncursesw/curses.h
+ then
+ CPPFLAGS="$CPPFLAGS -I$p/include/ncursesw"
+ test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include"
+ test $p != /usr && LIBS="-L$p/lib $LIBS"
+ break
+ elif test $p != /usr
+ then
+ if test -f $p/include/curses.h
+ then
+ CPPFLAGS="$CPPFLAGS -I$p/include"
+ LIBS="-L$p/lib $LIBS"
+ break
+ fi
+ fi
+ done
+
+fi
+
+fi
+
+
+
# Check whether --with-ncurses or --without-ncurses was given.
if test "${with_ncurses+set}" = set; then
withval="$with_ncurses"
echo $ac_n "checking for initscr""... $ac_c" 1>&6
-echo "configure:792: checking for initscr" >&5
+echo "configure:1016: checking for initscr" >&5
if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 797 "configure"
+#line 1021 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char initscr(); below. */
@@ -816,7 +1040,7 @@ initscr();
; return 0; }
EOF
-if { (eval echo configure:820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_initscr=yes"
else
@@ -835,7 +1059,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:839: checking for Gpm_Open in -lgpm" >&5
+echo "configure:1063: checking for Gpm_Open in -lgpm" >&5
ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -843,7 +1067,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lgpm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 847 "configure"
+#line 1071 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -854,7 +1078,7 @@ int main() {
Gpm_Open()
; return 0; }
EOF
-if { (eval echo configure:858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -909,12 +1133,12 @@ fi
echo $ac_n "checking for initscr""... $ac_c" 1>&6
-echo "configure:913: checking for initscr" >&5
+echo "configure:1137: checking for initscr" >&5
if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 918 "configure"
+#line 1142 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char initscr(); below. */
@@ -937,7 +1161,7 @@ initscr();
; return 0; }
EOF
-if { (eval echo configure:941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_initscr=yes"
else
@@ -956,7 +1180,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for initscr in -l$LIB_NAME""... $ac_c" 1>&6
-echo "configure:960: checking for initscr in -l$LIB_NAME" >&5
+echo "configure:1184: checking for initscr in -l$LIB_NAME" >&5
ac_lib_var=`echo $LIB_NAME'_'initscr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -964,7 +1188,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-l$LIB_NAME $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 968 "configure"
+#line 1192 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -975,7 +1199,7 @@ int main() {
initscr()
; return 0; }
EOF
-if { (eval echo configure:979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1005,7 +1229,7 @@ fi
fi
echo $ac_n "checking for form_driver in -lform""... $ac_c" 1>&6
-echo "configure:1009: checking for form_driver in -lform" >&5
+echo "configure:1233: checking for form_driver in -lform" >&5
ac_lib_var=`echo form'_'form_driver | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1013,7 +1237,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lform $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1017 "configure"
+#line 1241 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1024,7 +1248,7 @@ int main() {
form_driver()
; return 0; }
EOF
-if { (eval echo configure:1028: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1052,7 +1276,7 @@ else
fi
echo $ac_n "checking for menu_driver in -lmenu""... $ac_c" 1>&6
-echo "configure:1056: checking for menu_driver in -lmenu" >&5
+echo "configure:1280: checking for menu_driver in -lmenu" >&5
ac_lib_var=`echo menu'_'menu_driver | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1060,7 +1284,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lmenu $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1064 "configure"
+#line 1288 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1071,7 +1295,7 @@ int main() {
menu_driver()
; return 0; }
EOF
-if { (eval echo configure:1075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1299: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1099,7 +1323,7 @@ else
fi
echo $ac_n "checking for new_panel in -lpanel""... $ac_c" 1>&6
-echo "configure:1103: checking for new_panel in -lpanel" >&5
+echo "configure:1327: checking for new_panel in -lpanel" >&5
ac_lib_var=`echo panel'_'new_panel | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1107,7 +1331,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpanel $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1111 "configure"
+#line 1335 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1118,7 +1342,7 @@ int main() {
new_panel()
; return 0; }
EOF
-if { (eval echo configure:1122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1346: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1147,12 +1371,12 @@ fi
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1151: checking return type of signal handlers" >&5
+echo "configure:1375: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1156 "configure"
+#line 1380 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -1169,7 +1393,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:1173: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1397: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -1189,7 +1413,7 @@ EOF
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1193: checking how to run the C preprocessor" >&5
+echo "configure:1417: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1204,13 +1428,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1208 "configure"
+#line 1432 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1214: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1438: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1221,13 +1445,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1225 "configure"
+#line 1449 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1231: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1455: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1238,13 +1462,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1242 "configure"
+#line 1466 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1472: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1269,12 +1493,12 @@ fi
echo "$ac_t""$CPP" 1>&6
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1273: checking for ANSI C header files" >&5
+echo "configure:1497: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1278 "configure"
+#line 1502 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1282,7 +1506,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1286: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1510: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1299,7 +1523,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1303 "configure"
+#line 1527 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1317,7 +1541,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1321 "configure"
+#line 1545 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1338,7 +1562,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1342 "configure"
+#line 1566 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1349,7 +1573,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1577: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1373,12 +1597,12 @@ EOF
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1377: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1601: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1382 "configure"
+#line 1606 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -1387,7 +1611,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1391: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -1410,8 +1634,10 @@ fi
for ac_hdr in \
form.h \
getopt.h \
+locale.h \
menu.h \
nc_alloc.h \
+nomacros.h \
panel.h \
sys/ioctl.h \
sys/select.h \
@@ -1422,17 +1648,17 @@ unistd.h \
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1426: checking for $ac_hdr" >&5
+echo "configure:1652: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1431 "configure"
+#line 1657 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1436: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1460,8 +1686,10 @@ done
for ac_func in \
+getnstr \
gettimeofday \
napms \
+resize_term \
resizeterm \
strdup \
use_default_colors \
@@ -1470,12 +1698,12 @@ wresize \
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1474: checking for $ac_func" >&5
+echo "configure:1702: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1479 "configure"
+#line 1707 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1498,7 +1726,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1524,7 +1752,7 @@ done
echo $ac_n "checking for function curses_version""... $ac_c" 1>&6
-echo "configure:1528: checking for function curses_version" >&5
+echo "configure:1756: checking for function curses_version" >&5
if eval "test \"`echo '$''{'cf_cv_func_curses_version'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1533,7 +1761,7 @@ if test "$cross_compiling" = yes; then
cf_cv_func_curses_version=unknown
else
cat > conftest.$ac_ext <<EOF
-#line 1537 "configure"
+#line 1765 "configure"
#include "confdefs.h"
#include <curses.h>
@@ -1545,7 +1773,7 @@ int main()
}
EOF
-if { (eval echo configure:1549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
cf_cv_func_curses_version=yes
@@ -1568,20 +1796,194 @@ test "$cf_cv_func_curses_version" = yes && cat >> confdefs.h <<\EOF
EOF
-echo $ac_n "checking if sys/time.h conflicts with sys/select.h""... $ac_c" 1>&6
-echo "configure:1573: checking if sys/time.h conflicts with sys/select.h" >&5
+echo $ac_n "checking for alternate character set array""... $ac_c" 1>&6
+echo "configure:1801: checking for alternate character set array" >&5
+if eval "test \"`echo '$''{'cf_cv_curses_acs_map'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+cf_cv_curses_acs_map=unknown
+for name in acs_map _acs_map __acs_map _nc_acs_map
+do
+cat > conftest.$ac_ext <<EOF
+#line 1810 "configure"
+#include "confdefs.h"
+
+#include <curses.h>
+
+int main() {
+
+$name['k'] = ACS_PLUS
+
+; return 0; }
+EOF
+if { (eval echo configure:1821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ cf_cv_curses_acs_map=$name; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$cf_cv_curses_acs_map" 1>&6
+
+test "$cf_cv_curses_acs_map" != unknown && cat >> confdefs.h <<EOF
+#define CURSES_ACS_ARRAY $cf_cv_curses_acs_map
+EOF
+
+
+echo $ac_n "checking for wide alternate character set array""... $ac_c" 1>&6
+echo "configure:1841: checking for wide alternate character set array" >&5
+if eval "test \"`echo '$''{'cf_cv_curses_wacs_map'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+cf_cv_curses_wacs_map=unknown
+for name in wacs_map _wacs_map __wacs_map _nc_wacs
+do
+cat > conftest.$ac_ext <<EOF
+#line 1850 "configure"
+#include "confdefs.h"
+
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <curses.h>
+
+int main() {
+
+$name['k'] = *WACS_PLUS
+
+; return 0; }
+EOF
+if { (eval echo configure:1864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ cf_cv_curses_wacs_map=$name; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$cf_cv_curses_wacs_map" 1>&6
+
+test "$cf_cv_curses_wacs_map" != unknown && cat >> confdefs.h <<EOF
+#define CURSES_WACS_ARRAY $cf_cv_curses_wacs_map
+EOF
+
+
+
+
+
+echo $ac_n "checking for type attr_t in curses.h""... $ac_c" 1>&6
+echo "configure:1887: checking for type attr_t in curses.h" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1889 "configure"
+#include "confdefs.h"
+
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <curses.h>
+int main() {
+
+attr_t foo
+
+; return 0; }
+EOF
+if { (eval echo configure:1902: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ cf_result=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ cf_result=no
+fi
+rm -f conftest*
+echo "$ac_t""$cf_result" 1>&6
+if test $cf_result = yes ; then
+
+cf_result=`echo "have_type_attr_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+ cat >> confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+else
+ cat >> confdefs.h <<EOF
+#define attr_t long
+EOF
+
+fi
+
+
+echo $ac_n "checking for type mbstate_t in curses.h""... $ac_c" 1>&6
+echo "configure:1930: checking for type mbstate_t in curses.h" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1932 "configure"
+#include "confdefs.h"
+
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <curses.h>
+int main() {
+
+mbstate_t foo
+
+; return 0; }
+EOF
+if { (eval echo configure:1945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ cf_result=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ cf_result=no
+fi
+rm -f conftest*
+echo "$ac_t""$cf_result" 1>&6
+if test $cf_result = yes ; then
+
+cf_result=`echo "have_type_mbstate_t" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+ cat >> confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+else
+ cat >> confdefs.h <<EOF
+#define mbstate_t long
+EOF
+
+fi
+
+
+
+echo $ac_n "checking if sys/time.h works with sys/select.h""... $ac_c" 1>&6
+echo "configure:1974: checking if sys/time.h works with sys/select.h" >&5
if eval "test \"`echo '$''{'cf_cv_sys_time_select'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1579 "configure"
+#line 1980 "configure"
#include "confdefs.h"
-#if HAVE_SYS_TIME_H
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
-#if HAVE_SYS_SELECT_H
+#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@@ -1589,7 +1991,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1593: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1995: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cf_cv_sys_time_select=yes
else
@@ -1603,11 +2005,12 @@ rm -f conftest*
fi
echo "$ac_t""$cf_cv_sys_time_select" 1>&6
-test $cf_cv_sys_time_select = yes && cat >> confdefs.h <<\EOF
+test "$cf_cv_sys_time_select" = yes && cat >> confdefs.h <<\EOF
#define HAVE_SYS_TIME_SELECT 1
EOF
+
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
diff --git a/contrib/ncurses/test/configure.in b/contrib/ncurses/test/configure.in
index d61d477..28a75b6 100644
--- a/contrib/ncurses/test/configure.in
+++ b/contrib/ncurses/test/configure.in
@@ -1,5 +1,5 @@
dnl***************************************************************************
-dnl Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+dnl Copyright (c) 1998-2000,2002 Free Software Foundation, Inc. *
dnl *
dnl Permission is hereby granted, free of charge, to any person obtaining a *
dnl copy of this software and associated documentation files (the *
@@ -26,9 +26,9 @@ dnl sale, use or other dealings in this Software without prior written *
dnl authorization. *
dnl***************************************************************************
dnl
-dnl Author: Thomas E. Dickey 1996,1997,1998,2000
+dnl Author: Thomas E. Dickey 1996, etc.
dnl
-dnl $Id: configure.in,v 1.31 2000/10/15 18:46:17 tom Exp $
+dnl $Id: configure.in,v 1.35 2002/04/06 22:02:50 tom Exp $
dnl This is a simple configuration-script for the ncurses test programs that
dnl allows the test-directory to be separately configured against a reference
dnl system (i.e., sysvr4 curses)
@@ -77,6 +77,57 @@ AC_ARG_WITH(5lib,
[LIBS="-L/usr/5lib $LIBS"
CPPFLAGS="$CPPFLAGS -I/usr/5include"])
+dnl ---------------------------------------------------------------------------
+dnl Check for libutf8
+AC_DEFUN([CF_LIBUTF8],
+[
+AC_CACHE_CHECK(for putwc in libutf8,cf_cv_libutf8,[
+ cf_save_LIBS="$LIBS"
+ LIBS="-lutf8 $LIBS"
+AC_TRY_LINK([
+#include <libutf8.h>],[putwc(0,0);],
+ [cf_cv_libutf8=yes],
+ [cf_cv_libutf8=no])
+ LIBS="$cf_save_LIBS"
+])
+
+if test "$cf_cv_libutf8" = yes ; then
+ AC_DEFINE(HAVE_LIBUTF8_H)
+ LIBS="-lutf8 $LIBS"
+fi
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl NcursesW, installed in conventional location
+AC_ARG_WITH(ncursesw,
+ [ --with-ncursesw use wide ncurses-libraries (installed)],
+ [
+ AC_DEFINE(_GNU_SOURCE)
+ AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
+ AC_CHECK_FUNC(initscr,,[
+ AC_CHECK_LIB(gpm,Gpm_Open)
+ LIB_NAME=ncursesw
+ AC_CHECK_FUNC(putwc,,[CF_LIBUTF8])
+ for p in $HOME /usr/local /usr
+ do
+ if test -f $p/include/ncursesw/curses.h
+ then
+ CPPFLAGS="$CPPFLAGS -I$p/include/ncursesw"
+ test $p != /usr && CPPFLAGS="$CPPFLAGS -I$p/include"
+ test $p != /usr && LIBS="-L$p/lib $LIBS"
+ break
+ elif test $p != /usr
+ then
+ if test -f $p/include/curses.h
+ then
+ CPPFLAGS="$CPPFLAGS -I$p/include"
+ LIBS="-L$p/lib $LIBS"
+ break
+ fi
+ fi
+ done
+ ],[test -d /usr/ccs/lib && LIBS="-L/usr/ccs/lib $LIBS"])])
+
dnl Ncurses, installed in conventional location
AC_ARG_WITH(ncurses,
[ --with-ncurses use ncurses-libraries (installed)],
@@ -121,8 +172,10 @@ AC_HEADER_TIME
AC_CHECK_HEADERS( \
form.h \
getopt.h \
+locale.h \
menu.h \
nc_alloc.h \
+nomacros.h \
panel.h \
sys/ioctl.h \
sys/select.h \
@@ -132,8 +185,10 @@ unistd.h \
)
AC_CHECK_FUNCS( \
+getnstr \
gettimeofday \
napms \
+resize_term \
resizeterm \
strdup \
use_default_colors \
@@ -141,6 +196,7 @@ vsscanf \
wresize \
)
+dnl ---------------------------------------------------------------------------
dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
dnl It's a character string "SVR4", not documented.
AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
@@ -159,21 +215,93 @@ rm -f core])
test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
dnl ---------------------------------------------------------------------------
+dnl Check for likely values of acs_map[]:
+AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
+cf_cv_curses_acs_map=unknown
+for name in acs_map _acs_map __acs_map _nc_acs_map
+do
+AC_TRY_LINK([
+#include <curses.h>
+],[
+$name['k'] = ACS_PLUS
+],[cf_cv_curses_acs_map=$name; break])
+done
+])
+
+test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
+
+dnl ---------------------------------------------------------------------------
+dnl Check for likely values of wacs_map[]:
+AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
+cf_cv_curses_wacs_map=unknown
+for name in wacs_map _wacs_map __wacs_map _nc_wacs
+do
+AC_TRY_LINK([
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <curses.h>
+],[
+$name['k'] = *WACS_PLUS
+],[cf_cv_curses_wacs_map=$name; break])
+done
+])
+
+test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map)
+
+dnl ---------------------------------------------------------------------------
+dnl Make an uppercase version of a variable
+dnl $1=uppercase($2)
+AC_DEFUN([CF_UPPER],
+[
+$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Check if curses.h defines the given type
+AC_DEFUN([CF_CURSES_TYPE],
+[
+AC_MSG_CHECKING(for type $1 in curses.h)
+AC_TRY_COMPILE([
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <curses.h>],[
+$1 foo
+],cf_result=yes,cf_result=no)
+AC_MSG_RESULT($cf_result)
+if test $cf_result = yes ; then
+ CF_UPPER(cf_result,have_type_$1)
+ AC_DEFINE_UNQUOTED($cf_result)
+else
+ AC_DEFINE_UNQUOTED($1,$2)
+fi
+])dnl
+
+CF_CURSES_TYPE(attr_t,long)
+CF_CURSES_TYPE(mbstate_t,long)
+
+dnl ---------------------------------------------------------------------------
+dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
+dnl older SCO configurations.
dnl [CF_SYS_TIME_SELECT]
-AC_MSG_CHECKING(if sys/time.h conflicts with sys/select.h)
+
+AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
AC_CACHE_VAL(cf_cv_sys_time_select,[
AC_TRY_COMPILE([
-#if HAVE_SYS_TIME_H
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
-#if HAVE_SYS_SELECT_H
+#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
],[],[cf_cv_sys_time_select=yes],
[cf_cv_sys_time_select=no])
])
AC_MSG_RESULT($cf_cv_sys_time_select)
-test $cf_cv_sys_time_select = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
+test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
+
dnl ---------------------------------------------------------------------------
AC_OUTPUT(Makefile,[
diff --git a/contrib/ncurses/test/ditto.c b/contrib/ncurses/test/ditto.c
index 8ceafe5..c2c6b26 100644
--- a/contrib/ncurses/test/ditto.c
+++ b/contrib/ncurses/test/ditto.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,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 *
@@ -29,7 +29,7 @@
/*
* Author: Thomas E. Dickey <dickey@clark.net> 1998
*
- * $Id: ditto.c,v 1.3 1998/08/15 23:39:34 tom Exp $
+ * $Id: ditto.c,v 1.4 2001/09/15 21:53:37 tom Exp $
*
* The program illustrates how to set up multiple screens from a single
* program. Invoke the program by specifying another terminal on the same
@@ -41,108 +41,108 @@
#include <errno.h>
typedef struct {
- FILE *input;
- FILE *output;
- SCREEN *screen;
+ FILE *input;
+ FILE *output;
+ SCREEN *screen;
} DITTO;
static void
failed(const char *s)
{
- perror(s);
- exit(EXIT_FAILURE);
+ perror(s);
+ ExitProgram(EXIT_FAILURE);
}
static void
usage(void)
{
- fprintf(stderr, "usage: ditto [terminal1 ...]\n");
- exit(EXIT_FAILURE);
+ fprintf(stderr, "usage: ditto [terminal1 ...]\n");
+ ExitProgram(EXIT_FAILURE);
}
static FILE *
open_tty(char *path)
{
- FILE *fp;
- struct stat sb;
+ FILE *fp;
+ struct stat sb;
- if (stat(path, &sb) < 0)
- failed(path);
- if ((sb.st_mode & S_IFMT) != S_IFCHR) {
- errno = ENOTTY;
- failed(path);
- }
- fp = fopen(path, "a+");
- if (fp == 0)
- failed(path);
- printf("opened %s\n", path);
- return fp;
+ if (stat(path, &sb) < 0)
+ failed(path);
+ if ((sb.st_mode & S_IFMT) != S_IFCHR) {
+ errno = ENOTTY;
+ failed(path);
+ }
+ fp = fopen(path, "a+");
+ if (fp == 0)
+ failed(path);
+ printf("opened %s\n", path);
+ return fp;
}
int
main(
int argc GCC_UNUSED,
- char *argv[] GCC_UNUSED)
+ char *argv[]GCC_UNUSED)
{
- int j;
- int active_tty = 0;
- DITTO *data;
+ int j;
+ int active_tty = 0;
+ DITTO *data;
- if (argc <= 1)
- usage();
+ if (argc <= 1)
+ usage();
- if ((data = (DITTO *)calloc(argc, sizeof(DITTO))) == 0)
- failed("calloc data");
+ if ((data = (DITTO *) calloc(argc, sizeof(DITTO))) == 0)
+ failed("calloc data");
- data[0].input = stdin;
- data[0].output = stdout;
- for (j = 1; j < argc; j++) {
- data[j].input =
- data[j].output = open_tty(argv[j]);
- }
+ data[0].input = stdin;
+ data[0].output = stdout;
+ for (j = 1; j < argc; j++) {
+ data[j].input =
+ data[j].output = open_tty(argv[j]);
+ }
- /*
- * If we got this far, we have open connection(s) to the terminal(s).
- * Set up the screens.
- */
- for (j = 0; j < argc; j++) {
- active_tty++;
- data[j].screen = newterm(
- (char *)0, /* assume $TERM is the same */
- data[j].output,
- data[j].input);
- if (data[j].screen == 0)
- failed("newterm");
- cbreak();
- noecho();
- scrollok(stdscr, TRUE);
- }
+ /*
+ * If we got this far, we have open connection(s) to the terminal(s).
+ * Set up the screens.
+ */
+ for (j = 0; j < argc; j++) {
+ active_tty++;
+ data[j].screen = newterm(
+ (char *) 0, /* assume $TERM is the same */
+ data[j].output,
+ data[j].input);
+ if (data[j].screen == 0)
+ failed("newterm");
+ cbreak();
+ noecho();
+ scrollok(stdscr, TRUE);
+ }
- /*
- * Loop, reading characters from any of the inputs and writing to all
- * of the screens.
- */
- for(;;) {
- int ch;
- set_term(data[0].screen);
- ch = getch();
- if (ch == ERR)
- continue;
- if (ch == 4)
- break;
- for (j = 0; j < argc; j++) {
- set_term(data[j].screen);
- addch(ch);
- refresh();
- }
+ /*
+ * Loop, reading characters from any of the inputs and writing to all
+ * of the screens.
+ */
+ for (;;) {
+ int ch;
+ set_term(data[0].screen);
+ ch = getch();
+ if (ch == ERR)
+ continue;
+ if (ch == 4)
+ break;
+ for (j = 0; j < argc; j++) {
+ set_term(data[j].screen);
+ addch(ch);
+ refresh();
}
+ }
- /*
- * Cleanup and exit
- */
- for (j = argc-1; j >= 0; j--) {
- set_term(data[j].screen);
- endwin();
- }
- return EXIT_SUCCESS;
+ /*
+ * Cleanup and exit
+ */
+ for (j = argc - 1; j >= 0; j--) {
+ set_term(data[j].screen);
+ endwin();
+ }
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/dots.c b/contrib/ncurses/test/dots.c
index a5ddcaa..2e0190f 100644
--- a/contrib/ncurses/test/dots.c
+++ b/contrib/ncurses/test/dots.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2001,2002 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,16 +29,13 @@
/*
* Author: Thomas E. Dickey <dickey@clark.net> 1999
*
- * $Id: dots.c,v 1.4 2000/02/13 01:05:13 tom Exp $
+ * $Id: dots.c,v 1.8 2002/04/06 21:33:42 tom Exp $
*
* A simple demo of the terminfo interface.
*/
-#include <test.priv.h>
-
-#include <term.h> /* for tparm() */
-
#include <time.h>
-#include <signal.h>
+
+#include <test.priv.h>
#define valid(s) ((s != 0) && s != (char *)-1)
@@ -81,7 +78,7 @@ onsig(int n GCC_UNUSED)
{
interrupted = TRUE;
cleanup();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static float
@@ -93,8 +90,8 @@ ranf(void)
int
main(
- int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
+ int argc GCC_UNUSED,
+ char *argv[]GCC_UNUSED)
{
int x, y, z, j, p;
float r;
@@ -123,19 +120,19 @@ main(
y = (int) (r * ranf()) + 2;
p = (ranf() > 0.9) ? '*' : ' ';
- tputs(tparm(cursor_address, y, x), 1, outc);
+ tputs(tparm3(cursor_address, y, x), 1, outc);
if (max_colors > 0) {
- z = (int)(ranf() * max_colors);
+ z = (int) (ranf() * max_colors);
if (ranf() > 0.01) {
- tputs(tparm(set_a_foreground, z), 1, outc);
+ tputs(tparm2(set_a_foreground, z), 1, outc);
} else {
- tputs(tparm(set_a_background, z), 1, outc);
+ tputs(tparm2(set_a_background, z), 1, outc);
}
} else if (valid(exit_attribute_mode)
- && valid(enter_reverse_mode)) {
+ && valid(enter_reverse_mode)) {
if (ranf() <= 0.01)
outs((ranf() > 0.6) ? enter_reverse_mode :
- exit_attribute_mode);
+ exit_attribute_mode);
}
outc(p);
fflush(stdout);
diff --git a/contrib/ncurses/test/filter.c b/contrib/ncurses/test/filter.c
index 6ccaffd..c3ea3c1 100644
--- a/contrib/ncurses/test/filter.c
+++ b/contrib/ncurses/test/filter.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
/*
* Author: Thomas E. Dickey <dickey@clark.net> 1998
*
- * $Id: filter.c,v 1.5 2001/02/24 22:11:58 tom Exp $
+ * $Id: filter.c,v 1.7 2002/03/23 23:02:15 tom Exp $
*/
#include <test.priv.h>
@@ -45,11 +45,6 @@
* and refresh(), but that does not work any better.
*/
-#ifndef NCURSES_VERSION
-#define attr_t long
-#define getnstr(s,n) getstr(s)
-#endif
-
static int
new_command(char *buffer, int length, attr_t underline)
{
@@ -104,5 +99,5 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
printw("done");
refresh();
endwin();
- return 0;
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/firework.c b/contrib/ncurses/test/firework.c
index 66c1227..3d84c43 100644
--- a/contrib/ncurses/test/firework.c
+++ b/contrib/ncurses/test/firework.c
@@ -1,11 +1,10 @@
/*
- * $Id: firework.c,v 1.17 2000/09/02 18:41:12 tom Exp $
+ * $Id: firework.c,v 1.20 2002/03/23 21:41:42 tom Exp $
*/
-#include <test.priv.h>
-
-#include <signal.h>
#include <time.h>
+#include <test.priv.h>
+
static int my_bg = COLOR_BLACK;
static void
@@ -19,7 +18,7 @@ static RETSIGTYPE
onsig(int n GCC_UNUSED)
{
cleanup();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static void
@@ -35,7 +34,7 @@ showit(void)
#endif
if (ch == 'q') {
cleanup();
- exit(EXIT_SUCCESS);
+ ExitProgram(EXIT_SUCCESS);
} else if (ch == 's') {
nodelay(stdscr, FALSE);
} else if (ch == ' ') {
@@ -114,8 +113,8 @@ explode(int row, int col)
int
main(
- int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
+ int argc GCC_UNUSED,
+ char *argv[]GCC_UNUSED)
{
int j;
int start, end, row, diff, flag = 0, direction;
@@ -154,7 +153,7 @@ main(
attrset(A_NORMAL);
for (row = 0; row < diff; row++) {
mvprintw(LINES - row, start + (row * direction),
- (direction < 0) ? "\\" : "/");
+ (direction < 0) ? "\\" : "/");
if (flag++) {
showit();
erase();
diff --git a/contrib/ncurses/test/firstlast.c b/contrib/ncurses/test/firstlast.c
index f9515dc..6a79a33 100644
--- a/contrib/ncurses/test/firstlast.c
+++ b/contrib/ncurses/test/firstlast.c
@@ -2,88 +2,89 @@
* This test was written by Alexander V. Lukyanov to demonstrate difference
* between ncurses 4.1 and SVR4 curses
*
- * $Id: firstlast.c,v 1.2 1997/10/18 21:34:53 tom Exp $
+ * $Id: firstlast.c,v 1.3 2001/09/15 21:46:34 tom Exp $
*/
#include <test.priv.h>
-static void fill(WINDOW *w,const char *str)
+static void
+fill(WINDOW *w, const char *str)
{
- const char *s;
- for(;;) {
- for(s=str; *s; s++) {
- if(waddch(w,*s)==ERR)
- {
- wmove(w,0,0);
- return;
- }
- }
+ const char *s;
+ for (;;) {
+ for (s = str; *s; s++) {
+ if (waddch(w, *s) == ERR) {
+ wmove(w, 0, 0);
+ return;
+ }
}
+ }
}
-int main(
+int
+main(
int argc GCC_UNUSED,
- char *argv[] GCC_UNUSED)
+ char *argv[]GCC_UNUSED)
{
- WINDOW *large,*small;
- initscr();
- noecho();
-
- large = newwin(20,60,2,10);
- small = newwin(10,30,7,25);
-
- /* test 1 - addch */
- fill(large,"LargeWindow");
-
- refresh();
- wrefresh(large);
- wrefresh(small);
-
- mvwaddstr(small,5,5," Test <place to change> String ");
- wrefresh(small);
- getch();
-
- touchwin(large);
- wrefresh(large);
-
- mvwaddstr(small,5,5," Test <***************> String ");
- wrefresh(small);
-
- /* DIFFERENCE! */
- getch();
-
- /* test 2: erase */
- erase();
- refresh();
- getch();
-
- /* test 3: clrtoeol */
- werase(small);
- wrefresh(small);
- touchwin(large);
- wrefresh(large);
- wmove(small,5,0);
- waddstr(small," clrtoeol>");
- wclrtoeol(small);
- wrefresh(small);
-
- /* DIFFERENCE! */;
- getch();
-
- /* test 4: clrtobot */
- werase(small);
- wrefresh(small);
- touchwin(large);
- wrefresh(large);
- wmove(small,5,3);
- waddstr(small," clrtobot>");
- wclrtobot(small);
- wrefresh(small);
-
- /* DIFFERENCE! */
- getch();
-
- endwin();
-
- return EXIT_SUCCESS;
+ WINDOW *large, *small;
+ initscr();
+ noecho();
+
+ large = newwin(20, 60, 2, 10);
+ small = newwin(10, 30, 7, 25);
+
+ /* test 1 - addch */
+ fill(large, "LargeWindow");
+
+ refresh();
+ wrefresh(large);
+ wrefresh(small);
+
+ mvwaddstr(small, 5, 5, " Test <place to change> String ");
+ wrefresh(small);
+ getch();
+
+ touchwin(large);
+ wrefresh(large);
+
+ mvwaddstr(small, 5, 5, " Test <***************> String ");
+ wrefresh(small);
+
+ /* DIFFERENCE! */
+ getch();
+
+ /* test 2: erase */
+ erase();
+ refresh();
+ getch();
+
+ /* test 3: clrtoeol */
+ werase(small);
+ wrefresh(small);
+ touchwin(large);
+ wrefresh(large);
+ wmove(small, 5, 0);
+ waddstr(small, " clrtoeol>");
+ wclrtoeol(small);
+ wrefresh(small);
+
+ /* DIFFERENCE! */ ;
+ getch();
+
+ /* test 4: clrtobot */
+ werase(small);
+ wrefresh(small);
+ touchwin(large);
+ wrefresh(large);
+ wmove(small, 5, 3);
+ waddstr(small, " clrtobot>");
+ wclrtobot(small);
+ wrefresh(small);
+
+ /* DIFFERENCE! */
+ getch();
+
+ endwin();
+
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/gdc.c b/contrib/ncurses/test/gdc.c
index c215874..8b37b1e44 100644
--- a/contrib/ncurses/test/gdc.c
+++ b/contrib/ncurses/test/gdc.c
@@ -6,14 +6,12 @@
* modified 10-18-89 for curses (jrl)
* 10-18-89 added signal handling
*
- * $Id: gdc.c,v 1.16 2001/02/24 23:27:22 tom Exp $
+ * $Id: gdc.c,v 1.21 2002/03/23 22:17:24 tom Exp $
*/
-#include <test.priv.h>
-
#include <time.h>
-#include <signal.h>
-#include <string.h>
+
+#include <test.priv.h>
#define YBASE 10
#define XBASE 10
@@ -38,7 +36,7 @@ sighndl(int signo)
sigtermed = signo;
if (redirected) {
endwin();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
}
@@ -120,7 +118,7 @@ usage(void)
unsigned j;
for (j = 0; j < SIZEOF(msg); j++)
fprintf(stderr, "%s\n", msg[j]);
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
int
@@ -163,7 +161,7 @@ main(int argc, char *argv[])
if (name == 0
|| newterm(name, ofp, ifp) == 0) {
fprintf(stderr, "cannot open terminal\n");
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
} else {
@@ -304,7 +302,7 @@ main(int argc, char *argv[])
standend();
endwin();
fprintf(stderr, "gdc terminated by signal %d\n", sigtermed);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
/* FALLTHRU */
default:
@@ -313,5 +311,5 @@ main(int argc, char *argv[])
} while (--count);
standend();
endwin();
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/hanoi.c b/contrib/ncurses/test/hanoi.c
index 0b032f8..ef09514 100644
--- a/contrib/ncurses/test/hanoi.c
+++ b/contrib/ncurses/test/hanoi.c
@@ -14,17 +14,15 @@
*
* Date: 05.Nov.90
*
- * $Id: hanoi.c,v 1.19 2000/09/02 18:51:16 tom Exp $
+ * $Id: hanoi.c,v 1.23 2002/03/24 00:40:01 tom Exp $
*/
#include <test.priv.h>
-#include <string.h>
-
#define NPEGS 3 /* This is not configurable !! */
#define MINTILES 3
#define MAXTILES 9
-#define DEFAULTTILES 7
+#define DEFAULTTILES 7
#define TOPLINE 6
#define BASELINE 16
#define STATUSLINE (LINES-3)
@@ -70,7 +68,7 @@ int
main(int argc, char **argv)
{
int NTiles, FromCol, ToCol;
- unsigned char AutoFlag = 0;
+ bool AutoFlag = 0;
switch (argc) {
case 1:
@@ -80,24 +78,24 @@ main(int argc, char **argv)
NTiles = atoi(argv[1]);
if (NTiles > MAXTILES || NTiles < MINTILES) {
fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
break;
case 3:
if (strcmp(argv[2], "a")) {
Usage();
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
NTiles = atoi(argv[1]);
if (NTiles > MAXTILES || NTiles < MINTILES) {
fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
AutoFlag = TRUE;
break;
default:
Usage();
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
#ifdef TRACE
trace(TRACE_MAXIMUM);
@@ -118,7 +116,7 @@ main(int argc, char **argv)
if (LINES < 24) {
endwin();
fprintf(stderr, "Min screen length 24 lines\n");
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
if (AutoFlag) {
curs_set(0);
@@ -154,7 +152,7 @@ main(int argc, char **argv)
}
}
endwin();
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
static int
@@ -295,7 +293,7 @@ Solved(int NumTiles)
}
static void
-Usage()
+Usage(void)
{
fprintf(stderr, "Usage: hanoi [<No Of Tiles>] [a]\n");
fprintf(stderr,
diff --git a/contrib/ncurses/test/hashtest.c b/contrib/ncurses/test/hashtest.c
index 682368d..9ddb07c 100644
--- a/contrib/ncurses/test/hashtest.c
+++ b/contrib/ncurses/test/hashtest.c
@@ -3,7 +3,7 @@
*
* Generate timing statistics for vertical-motion optimization.
*
- * $Id: hashtest.c,v 1.17 2001/03/10 19:47:22 tom Exp $
+ * $Id: hashtest.c,v 1.21 2002/03/23 22:17:24 tom Exp $
*/
#ifdef TRACE
@@ -14,11 +14,9 @@
#define USE_TRACE 0
#endif
-#include <test.priv.h>
-
-#include <string.h>
#include <ctype.h>
-#include <signal.h>
+
+#include <test.priv.h>
#define LO_CHAR ' '
#define HI_CHAR '~'
@@ -43,7 +41,7 @@ static RETSIGTYPE
finish(int sig GCC_UNUSED)
{
cleanup();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static void
@@ -154,7 +152,7 @@ usage(void)
for (n = 0; n < SIZEOF(tbl); n++)
fprintf(stderr, "%s\n", tbl[n]);
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
int
@@ -223,6 +221,6 @@ main(int argc, char *argv[])
}
cleanup(); /* we're done */
- return (EXIT_SUCCESS);
+ ExitProgram(EXIT_SUCCESS);
}
/* hashtest.c ends here */
diff --git a/contrib/ncurses/test/keynames.c b/contrib/ncurses/test/keynames.c
index 88cadd2..c2056ec 100644
--- a/contrib/ncurses/test/keynames.c
+++ b/contrib/ncurses/test/keynames.c
@@ -1,14 +1,15 @@
/*
- * $Id: keynames.c,v 1.2 1998/06/06 22:45:13 tom Exp $
+ * $Id: keynames.c,v 1.3 2001/09/15 21:46:34 tom Exp $
*/
#include <test.priv.h>
-int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
- int n;
- for (n = -1; n < 512; n++) {
- printf("%d(%5o):%s\n", n, n, keyname(n));
- }
- return EXIT_SUCCESS;
+ int n;
+ for (n = -1; n < 512; n++) {
+ printf("%d(%5o):%s\n", n, n, keyname(n));
+ }
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/knight.c b/contrib/ncurses/test/knight.c
index b922371..469d25e 100644
--- a/contrib/ncurses/test/knight.c
+++ b/contrib/ncurses/test/knight.c
@@ -6,14 +6,12 @@
* Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995. Mouse support
* added September 20th 1995.
*
- * $Id: knight.c,v 1.20 2000/10/29 00:51:51 tom Exp $
+ * $Id: knight.c,v 1.24 2002/03/23 22:17:24 tom Exp $
*/
-#include <test.priv.h>
-
#include <ctype.h>
-#include <signal.h>
-#include <string.h>
+
+#include <test.priv.h>
/* board size */
#define BDEPTH 8
@@ -696,7 +694,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
play();
endwin();
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
/* knight.c ends here */
diff --git a/contrib/ncurses/test/lrtest.c b/contrib/ncurses/test/lrtest.c
index f2fc9d2..a3b856a 100644
--- a/contrib/ncurses/test/lrtest.c
+++ b/contrib/ncurses/test/lrtest.c
@@ -7,11 +7,10 @@
* This can't be part of the ncurses test-program, because ncurses rips off the
* bottom line to do labels.
*
- * $Id: lrtest.c,v 0.15 2000/12/31 02:09:42 tom Exp $
+ * $Id: lrtest.c,v 0.17 2002/04/06 20:45:22 tom Exp $
*/
#include <test.priv.h>
-#include <term.h>
typedef struct {
int y, x, mode, dir, inc;
@@ -139,7 +138,7 @@ main(
curs_set(1);
endwin();
- return 0;
+ ExitProgram(EXIT_SUCCESS);
}
/* lrtest.c ends here */
diff --git a/contrib/ncurses/test/ncurses.c b/contrib/ncurses/test/ncurses.c
index 8bbf023..0782d40 100644
--- a/contrib/ncurses/test/ncurses.c
+++ b/contrib/ncurses/test/ncurses.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,18 +38,17 @@ DESCRIPTION
AUTHOR
Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
+ Thomas E. Dickey (beginning revision 1.27 in 1996).
-$Id: ncurses.c,v 1.143 2001/05/12 23:49:04 tom Exp $
+$Id: ncurses.c,v 1.170 2002/04/21 21:08:07 tom Exp $
***************************************************************************/
-#include <test.priv.h>
-
#include <stdio.h>
#include <ctype.h>
-#include <string.h>
#include <assert.h>
-#include <signal.h>
+
+#include <test.priv.h>
#if HAVE_LOCALE_H
#include <locale.h>
@@ -64,7 +63,7 @@ $Id: ncurses.c,v 1.143 2001/05/12 23:49:04 tom Exp $
#endif
#endif
-#if HAVE_PANEL_H
+#if HAVE_PANEL_H && HAVE_LIBPANEL
#define USE_LIBPANEL 1
#include <panel.h>
#else
@@ -92,34 +91,54 @@ static int save_trace = TRACE_ORDINARY | TRACE_CALLS;
extern int _nc_tracing;
#endif
-#if !defined(HAVE_NAPMS)
-#define HAVE_NAPMS 1
-#endif
-
#else
#define mmask_t chtype /* not specified in XSI */
-#define attr_t chtype /* not specified in XSI */
-#define ACS_S3 (acs_map['p']) /* scan line 3 */
-#define ACS_S7 (acs_map['r']) /* scan line 7 */
-#define ACS_LEQUAL (acs_map['y']) /* less/equal */
-#define ACS_GEQUAL (acs_map['z']) /* greater/equal */
-#define ACS_PI (acs_map['{']) /* Pi */
-#define ACS_NEQUAL (acs_map['|']) /* not equal */
-#define ACS_STERLING (acs_map['}']) /* UK pound sign */
+
+#ifdef CURSES_ACS_ARRAY
+#define ACS_S3 (CURSES_ACS_ARRAY['p']) /* scan line 3 */
+#define ACS_S7 (CURSES_ACS_ARRAY['r']) /* scan line 7 */
+#define ACS_LEQUAL (CURSES_ACS_ARRAY['y']) /* less/equal */
+#define ACS_GEQUAL (CURSES_ACS_ARRAY['z']) /* greater/equal */
+#define ACS_PI (CURSES_ACS_ARRAY['{']) /* Pi */
+#define ACS_NEQUAL (CURSES_ACS_ARRAY['|']) /* not equal */
+#define ACS_STERLING (CURSES_ACS_ARRAY['}']) /* UK pound sign */
+#else
+#define ACS_S3 (A_ALTCHARSET + 'p') /* scan line 3 */
+#define ACS_S7 (A_ALTCHARSET + 'r') /* scan line 7 */
+#define ACS_LEQUAL (A_ALTCHARSET + 'y') /* less/equal */
+#define ACS_GEQUAL (A_ALTCHARSET + 'z') /* greater/equal */
+#define ACS_PI (A_ALTCHARSET + '{') /* Pi */
+#define ACS_NEQUAL (A_ALTCHARSET + '|') /* not equal */
+#define ACS_STERLING (A_ALTCHARSET + '}') /* UK pound sign */
+#endif
+
+#ifdef CURSES_WACS_ARRAY
+#define WACS_S3 (&(CURSES_WACS_ARRAY['p'])) /* scan line 3 */
+#define WACS_S7 (&(CURSES_WACS_ARRAY['r'])) /* scan line 7 */
+#define WACS_LEQUAL (&(CURSES_WACS_ARRAY['y'])) /* less/equal */
+#define WACS_GEQUAL (&(CURSES_WACS_ARRAY['z'])) /* greater/equal */
+#define WACS_PI (&(CURSES_WACS_ARRAY['{'])) /* Pi */
+#define WACS_NEQUAL (&(CURSES_WACS_ARRAY['|'])) /* not equal */
+#define WACS_STERLING (&(CURSES_WACS_ARRAY['}'])) /* UK pound sign */
+#endif
#endif
#define P(string) printw("%s\n", string)
-#ifndef CTRL
-#define CTRL(x) ((x) & 0x1f)
+#ifdef CTRL
+#undef CTRL
#endif
+#define CTRL(x) ((x) & 0x1f)
#define QUIT CTRL('Q')
#define ESCAPE CTRL('[')
#define BLANK ' ' /* this is the background character */
+#undef max_colors
static int max_colors; /* the actual number of colors we'll use */
+
+#undef max_pairs
static int max_pairs; /* ...and the number of color pairs */
/* The behavior of mvhline, mvvline for negative/zero length is unspecified,
@@ -166,6 +185,33 @@ wGetchar(WINDOW *win)
}
#define Getchar() wGetchar(stdscr)
+#if USE_WIDEC_SUPPORT
+static int
+wGet_wchar(WINDOW *win, wint_t * result)
+{
+ int c;
+#ifdef TRACE
+ while ((c = wget_wch(win, result)) == CTRL('T')) {
+ if (_nc_tracing) {
+ save_trace = _nc_tracing;
+ _tracef("TOGGLE-TRACING OFF");
+ _nc_tracing = 0;
+ } else {
+ _nc_tracing = save_trace;
+ }
+ trace(_nc_tracing);
+ if (_nc_tracing)
+ _tracef("TOGGLE-TRACING ON");
+ }
+#else
+ c = wget_wch(win, result);
+#endif
+ return c;
+}
+#define Get_wchar(result) wGet_wchar(stdscr, result)
+
+#endif
+
static void
Pause(void)
{
@@ -249,106 +295,380 @@ mouse_decode(MEVENT const *ep)
****************************************************************************/
static void
-getch_test(void)
-/* test the keypad feature */
+setup_getch(WINDOW *win, bool flags[])
+{
+ keypad(win, flags['k']); /* should be redundant, but for testing */
+ meta(win, flags['m']); /* force this to a known state */
+ if (flags['e'])
+ echo();
+ else
+ noecho();
+}
+
+static void
+wgetch_help(WINDOW *win, bool flags[])
+{
+ static const char *help[] =
+ {
+ "e -- toggle echo mode"
+ ,"g -- triggers a getstr test"
+ ,"k -- toggle keypad/literal mode"
+ ,"m -- toggle meta (7-bit/8-bit) mode"
+ ,"q -- quit (x also exits)"
+ ,"s -- shell out\n"
+ ,"w -- create a new window"
+#ifdef SIGTSTP
+ ,"z -- suspend this process"
+#endif
+ };
+ int y, x;
+ unsigned chk = ((SIZEOF(help) + 1) / 2);
+ unsigned n;
+
+ getyx(win, y, x);
+ move(0, 0);
+ printw("Type any key to see its %s value. Also:\n",
+ flags['k'] ? "keypad" : "literal");
+ for (n = 0; n < SIZEOF(help); ++n) {
+ int row = 1 + (n % chk);
+ int col = (n >= chk) ? COLS / 2 : 0;
+ int flg = ((strstr(help[n], "toggle") != 0)
+ && (flags[UChar(*help[n])] != FALSE));
+ if (flg)
+ standout();
+ mvprintw(row, col, "%s", help[n]);
+ if (col == 0)
+ clrtoeol();
+ if (flg)
+ standend();
+ }
+ wrefresh(stdscr);
+ wmove(win, y, x);
+}
+
+static void
+wgetch_wrap(WINDOW *win, int first_y)
+{
+ int last_y = getmaxy(win) - 1;
+ int y = getcury(win) + 1;
+
+ if (y >= last_y)
+ y = first_y;
+ wmove(win, y, 0);
+ wclrtoeol(win);
+}
+
+static void
+wgetch_test(WINDOW *win, int delay)
{
char buf[BUFSIZ];
+ int first_y, first_x;
+ int last_y = getmaxy(win) - 1;
int c;
- int incount = 0, firsttime = 0;
- bool blocking = TRUE;
- int y;
-
- refresh();
+ int incount = 0;
+ bool flags[256];
+ bool blocking = (delay < 0);
+ int y, x;
-#ifdef NCURSES_MOUSE_VERSION
- mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
-#endif
+ memset(flags, FALSE, sizeof(flags));
+ flags['k'] = (win == stdscr);
- (void) printw("Delay in 10ths of a second (<CR> for blocking input)? ");
- echo();
- getstr(buf);
- noecho();
- nonl();
+ setup_getch(win, flags);
+ wtimeout(win, delay);
+ getyx(win, first_y, first_x);
- if (isdigit(CharOf(buf[0]))) {
- timeout(atoi(buf) * 100);
- blocking = FALSE;
- }
+ wgetch_help(win, flags);
+ wsetscrreg(win, first_y, last_y);
+ scrollok(win, TRUE);
- c = '?';
- raw();
for (;;) {
- if (firsttime++) {
- printw("Key pressed: %04o ", c);
+ while ((c = wGetchar(win)) == ERR) {
+ incount++;
+ if (blocking) {
+ (void) wprintw(win, "%05d: input error", incount);
+ break;
+ } else {
+ (void) wprintw(win, "%05d: input timed out", incount);
+ }
+ wgetch_wrap(win, first_y);
+ }
+ if (c == ERR && blocking) {
+ wprintw(win, "ERR");
+ wgetch_wrap(win, first_y);
+ } else if (c == 'x' || c == 'q') {
+ break;
+ } else if (c == 'e') {
+ flags['e'] = !flags['e'];
+ setup_getch(win, flags);
+ wgetch_help(win, flags);
+ } else if (c == 'g') {
+ waddstr(win, "getstr test: ");
+ echo();
+ wgetnstr(win, buf, sizeof(buf) - 1);
+ noecho();
+ wprintw(win, "I saw %d characters:\n\t`%s'.", (int) strlen(buf), buf);
+ wclrtoeol(win);
+ wgetch_wrap(win, first_y);
+ } else if (c == 'k') {
+ flags['k'] = !flags['k'];
+ setup_getch(win, flags);
+ wgetch_help(win, flags);
+ } else if (c == 'm') {
+ flags['m'] = !flags['m'];
+ setup_getch(win, flags);
+ wgetch_help(win, flags);
+ } else if (c == 's') {
+ ShellOut(TRUE);
+ } else if (c == 'w') {
+ int high = last_y - first_y + 1;
+ int wide = getmaxx(win) - first_x;
+ int old_y, old_x;
+ int new_y = first_y + getbegy(win);
+ int new_x = first_x + getbegx(win);
+
+ getyx(win, old_y, old_x);
+ if (high > 2 && wide > 2) {
+ WINDOW *wb = newwin(high, wide, new_y, new_x);
+ WINDOW *wi = newwin(high - 2, wide - 2, new_y + 1, new_x + 1);
+
+ box(wb, 0, 0);
+ wrefresh(wb);
+ wmove(wi, 0, 0);
+ wgetch_test(wi, delay);
+ delwin(wi);
+ delwin(wb);
+
+ wgetch_help(win, flags);
+ wmove(win, old_y, old_x);
+ touchwin(win);
+ wrefresh(win);
+ }
+#ifdef SIGTSTP
+ } else if (c == 'z') {
+ kill(getpid(), SIGTSTP);
+#endif
+ } else {
+ wprintw(win, "Key pressed: %04o ", c);
#ifdef NCURSES_MOUSE_VERSION
if (c == KEY_MOUSE) {
MEVENT event;
getmouse(&event);
- printw("KEY_MOUSE, %s\n", mouse_decode(&event));
+ wprintw(win, "KEY_MOUSE, %s", mouse_decode(&event));
+ getyx(win, y, x);
+ move(event.y, event.x);
+ addch('*');
+ wmove(win, y, x);
} else
#endif /* NCURSES_MOUSE_VERSION */
if (c >= KEY_MIN) {
- (void) addstr(keyname(c));
- addch('\n');
+ (void) waddstr(win, keyname(c));
} else if (c > 0x80) {
int c2 = (c & 0x7f);
if (isprint(c2))
- (void) printw("M-%c", c2);
+ (void) wprintw(win, "M-%c", c2);
else
- (void) printw("M-%s", unctrl(c2));
- addstr(" (high-half character)\n");
+ (void) wprintw(win, "M-%s", unctrl(c2));
+ waddstr(win, " (high-half character)");
} else {
if (isprint(c))
- (void) printw("%c (ASCII printable character)\n", c);
+ (void) wprintw(win, "%c (ASCII printable character)", c);
else
- (void) printw("%s (ASCII control character)\n", unctrl(c));
+ (void) wprintw(win, "%s (ASCII control character)",
+ unctrl(c));
}
- y = getcury(stdscr);
- if (y >= LINES - 1)
- move(0, 0);
- clrtoeol();
+ wgetch_wrap(win, first_y);
}
+ }
- if (c == 'g') {
- addstr("getstr test: ");
- echo();
- getstr(buf);
- noecho();
- printw("I saw `%s'.\n", buf);
- }
- if (c == 's') {
- ShellOut(TRUE);
- }
- if (c == 'x' || c == 'q' || (c == ERR && blocking))
- break;
- if (c == '?') {
- addstr("Type any key to see its keypad value. Also:\n");
- addstr("g -- triggers a getstr test\n");
- addstr("s -- shell out\n");
- addstr("q -- quit\n");
- addstr("? -- repeats this help message\n");
- }
+ wtimeout(win, -1);
+}
- while ((c = Getchar()) == ERR)
- if (!blocking)
- (void) printw("%05d: input timed out\n", incount++);
- else {
- (void) printw("%05d: input error\n", incount++);
- break;
- }
+static int
+begin_getch_test(void)
+{
+ char buf[BUFSIZ];
+ int delay;
+
+ refresh();
+
+#ifdef NCURSES_MOUSE_VERSION
+ mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
+#endif
+
+ (void) printw("Delay in 10ths of a second (<CR> for blocking input)? ");
+ echo();
+ getnstr(buf, sizeof(buf) - 1);
+ noecho();
+ nonl();
+
+ if (isdigit(UChar(buf[0]))) {
+ delay = atoi(buf) * 100;
+ } else {
+ delay = -1;
}
+ raw();
+ move(5, 0);
+ return delay;
+}
+static void
+finish_getch_test(void)
+{
#ifdef NCURSES_MOUSE_VERSION
mousemask(0, (mmask_t *) 0);
#endif
- timeout(-1);
erase();
noraw();
nl();
endwin();
}
+static void
+getch_test(void)
+{
+ int delay = begin_getch_test();
+ wgetch_test(stdscr, delay);
+ finish_getch_test();
+}
+
+#if USE_WIDEC_SUPPORT
+static void
+wget_wch_test(WINDOW *win, int delay)
+{
+ char buf[BUFSIZ];
+ int first_y, first_x;
+ int last_y = getmaxy(win) - 1;
+ wint_t c;
+ int incount = 0;
+ bool flags[256];
+ bool blocking = (delay < 0);
+ int y, x, code;
+
+ memset(flags, FALSE, sizeof(flags));
+ flags['k'] = (win == stdscr);
+
+ setup_getch(win, flags);
+ wtimeout(win, delay);
+ getyx(win, first_y, first_x);
+
+ wgetch_help(win, flags);
+ wsetscrreg(win, first_y, last_y);
+ scrollok(win, TRUE);
+
+ for (;;) {
+ while ((code = wGet_wchar(win, &c)) == ERR) {
+ incount++;
+ if (blocking) {
+ (void) wprintw(win, "%05d: input error", incount);
+ break;
+ } else {
+ (void) wprintw(win, "%05d: input timed out", incount);
+ }
+ wgetch_wrap(win, first_y);
+ }
+ if (code == ERR && blocking) {
+ wprintw(win, "ERR");
+ wgetch_wrap(win, first_y);
+ } else if (c == 'x' || c == 'q') {
+ break;
+ } else if (c == 'e') {
+ flags['e'] = !flags['e'];
+ setup_getch(win, flags);
+ wgetch_help(win, flags);
+ } else if (c == 'g') {
+ waddstr(win, "getstr test: ");
+ echo();
+ wgetnstr(win, buf, sizeof(buf) - 1);
+ noecho();
+ wprintw(win, "I saw %d characters:\n\t`%s'.", strlen(buf), buf);
+ wclrtoeol(win);
+ wgetch_wrap(win, first_y);
+ } else if (c == 'k') {
+ flags['k'] = !flags['k'];
+ setup_getch(win, flags);
+ wgetch_help(win, flags);
+ } else if (c == 'm') {
+ flags['m'] = !flags['m'];
+ setup_getch(win, flags);
+ wgetch_help(win, flags);
+ } else if (c == 's') {
+ ShellOut(TRUE);
+ } else if (c == 'w') {
+ int high = last_y - first_y + 1;
+ int wide = getmaxx(win) - first_x;
+ int old_y, old_x;
+ int new_y = first_y + getbegy(win);
+ int new_x = first_x + getbegx(win);
+
+ getyx(win, old_y, old_x);
+ if (high > 2 && wide > 2) {
+ WINDOW *wb = newwin(high, wide, new_y, new_x);
+ WINDOW *wi = newwin(high - 2, wide - 2, new_y + 1, new_x + 1);
+
+ box_set(wb, 0, 0);
+ wrefresh(wb);
+ wmove(wi, 0, 0);
+ wget_wch_test(wi, delay);
+ delwin(wi);
+ delwin(wb);
+
+ wgetch_help(win, flags);
+ wmove(win, old_y, old_x);
+ touchwin(win);
+ wrefresh(win);
+ }
+#ifdef SIGTSTP
+ } else if (c == 'z') {
+ kill(getpid(), SIGTSTP);
+#endif
+ } else {
+ wprintw(win, "Key pressed: %04o ", c);
+#ifdef NCURSES_MOUSE_VERSION
+ if (c == KEY_MOUSE) {
+ MEVENT event;
+
+ getmouse(&event);
+ wprintw(win, "KEY_MOUSE, %s", mouse_decode(&event));
+ getyx(win, y, x);
+ move(event.y, event.x);
+ addch('*');
+ wmove(win, y, x);
+ } else
+#endif /* NCURSES_MOUSE_VERSION */
+ if (code == KEY_CODE_YES) {
+ (void) waddstr(win, key_name(c));
+ } else {
+ if (c < 256 && iscntrl(c)) {
+ (void) wprintw(win, "%s (control character)", unctrl(c));
+ } else {
+ wchar_t c2 = c;
+ waddnwstr(win, &c2, 1);
+ (void) wprintw(win, " = %#x (printable character)", c);
+ }
+ }
+ wgetch_wrap(win, first_y);
+ }
+ }
+
+ wtimeout(win, -1);
+}
+
+static void
+get_wch_test(void)
+{
+ int delay = begin_getch_test();
+ wget_wch_test(stdscr, delay);
+ finish_getch_test();
+}
+#endif
+
+/****************************************************************************
+ *
+ * Character attributes test
+ *
+ ****************************************************************************/
+
static int
show_attr(int row, int skip, chtype attr, const char *name)
{
@@ -379,8 +699,10 @@ show_attr(int row, int skip, chtype attr, const char *name)
const char *s = string;
while (*s) {
int ch = *s++;
- if ((ch = acs_map[ch]) == 0)
+#ifdef CURSES_ACS_ARRAY
+ if ((ch = CURSES_ACS_ARRAY[ch]) == 0)
ch = ' ';
+#endif
addch(ch);
}
} else {
@@ -394,7 +716,7 @@ show_attr(int row, int skip, chtype attr, const char *name)
if (!(termattrs() & attr)) {
printw(" (N/A)");
} else if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) {
- static const attr_t table[] =
+ static const chtype table[] =
{
A_STANDOUT,
A_UNDERLINE,
@@ -550,7 +872,7 @@ attr_test(void)
*
****************************************************************************/
-static NCURSES_CONST char *color_names[] =
+static NCURSES_CONST char *the_color_names[] =
{
"black",
"red",
@@ -576,7 +898,7 @@ show_color_name(int y, int x, int color)
if (max_colors > 8)
mvprintw(y, x, "%02d ", color);
else
- mvaddstr(y, x, color_names[color]);
+ mvaddstr(y, x, the_color_names[color]);
}
static void
@@ -671,8 +993,8 @@ color_edit(void)
for (i = 0; i < max_colors; i++) {
mvprintw(2 + i, 0, "%c %-8s:",
(i == current ? '>' : ' '),
- (i < (int) SIZEOF(color_names)
- ? color_names[i] : ""));
+ (i < (int) SIZEOF(the_color_names)
+ ? the_color_names[i] : ""));
attrset(COLOR_PAIR(i));
addstr(" ");
attrset(A_NORMAL);
@@ -949,6 +1271,27 @@ show_upper_chars(int first)
}
}
+static void
+show_box_chars(void)
+{
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Display of the ACS Line-Drawing Set");
+ attroff(A_BOLD);
+ refresh();
+ box(stdscr, 0, 0);
+ /* *INDENT-OFF* */
+ mvhline(LINES / 2, 0, ACS_HLINE, COLS);
+ mvvline(0, COLS / 2, ACS_VLINE, LINES);
+ mvaddch(0, COLS / 2, ACS_TTEE);
+ mvaddch(LINES / 2, COLS / 2, ACS_PLUS);
+ mvaddch(LINES - 1, COLS / 2, ACS_BTEE);
+ mvaddch(LINES / 2, 0, ACS_LTEE);
+ mvaddch(LINES / 2, COLS - 1, ACS_RTEE);
+ /* *INDENT-ON* */
+
+}
+
static int
show_1_acs(int n, const char *name, chtype code)
{
@@ -975,37 +1318,43 @@ show_acs_chars(void)
refresh();
n = show_1_acs(0, BOTH(ACS_ULCORNER));
- n = show_1_acs(n, BOTH(ACS_LLCORNER));
n = show_1_acs(n, BOTH(ACS_URCORNER));
+ n = show_1_acs(n, BOTH(ACS_LLCORNER));
n = show_1_acs(n, BOTH(ACS_LRCORNER));
- n = show_1_acs(n, BOTH(ACS_RTEE));
+
n = show_1_acs(n, BOTH(ACS_LTEE));
- n = show_1_acs(n, BOTH(ACS_BTEE));
+ n = show_1_acs(n, BOTH(ACS_RTEE));
n = show_1_acs(n, BOTH(ACS_TTEE));
+ n = show_1_acs(n, BOTH(ACS_BTEE));
+
n = show_1_acs(n, BOTH(ACS_HLINE));
n = show_1_acs(n, BOTH(ACS_VLINE));
- n = show_1_acs(n, BOTH(ACS_PLUS));
- n = show_1_acs(n, BOTH(ACS_S1));
- n = show_1_acs(n, BOTH(ACS_S9));
- n = show_1_acs(n, BOTH(ACS_DIAMOND));
- n = show_1_acs(n, BOTH(ACS_CKBOARD));
- n = show_1_acs(n, BOTH(ACS_DEGREE));
- n = show_1_acs(n, BOTH(ACS_PLMINUS));
- n = show_1_acs(n, BOTH(ACS_BULLET));
+
n = show_1_acs(n, BOTH(ACS_LARROW));
n = show_1_acs(n, BOTH(ACS_RARROW));
- n = show_1_acs(n, BOTH(ACS_DARROW));
n = show_1_acs(n, BOTH(ACS_UARROW));
+ n = show_1_acs(n, BOTH(ACS_DARROW));
+
+ n = show_1_acs(n, BOTH(ACS_BLOCK));
n = show_1_acs(n, BOTH(ACS_BOARD));
n = show_1_acs(n, BOTH(ACS_LANTERN));
- n = show_1_acs(n, BOTH(ACS_BLOCK));
- n = show_1_acs(n, BOTH(ACS_S3));
- n = show_1_acs(n, BOTH(ACS_S7));
- n = show_1_acs(n, BOTH(ACS_LEQUAL));
+ n = show_1_acs(n, BOTH(ACS_BULLET));
+ n = show_1_acs(n, BOTH(ACS_CKBOARD));
+ n = show_1_acs(n, BOTH(ACS_DEGREE));
+ n = show_1_acs(n, BOTH(ACS_DIAMOND));
+ n = show_1_acs(n, BOTH(ACS_PLMINUS));
+ n = show_1_acs(n, BOTH(ACS_PLUS));
+
n = show_1_acs(n, BOTH(ACS_GEQUAL));
- n = show_1_acs(n, BOTH(ACS_PI));
n = show_1_acs(n, BOTH(ACS_NEQUAL));
+ n = show_1_acs(n, BOTH(ACS_LEQUAL));
+
n = show_1_acs(n, BOTH(ACS_STERLING));
+ n = show_1_acs(n, BOTH(ACS_PI));
+ n = show_1_acs(n, BOTH(ACS_S1));
+ n = show_1_acs(n, BOTH(ACS_S3));
+ n = show_1_acs(n, BOTH(ACS_S7));
+ n = show_1_acs(n, BOTH(ACS_S9));
}
static void
@@ -1018,6 +1367,9 @@ acs_display(void)
case 'a':
show_acs_chars();
break;
+ case 'b':
+ show_box_chars();
+ break;
case '0':
case '1':
case '2':
@@ -1028,7 +1380,216 @@ acs_display(void)
mvprintw(LINES - 3, 0,
"Note: ANSI terminals may not display C1 characters.");
mvprintw(LINES - 2, 0,
- "Select: a=ACS, 0=C1, 1,2,3=GR characters, q=quit");
+ "Select: a=ACS, b=box, 0=C1, 1,2,3=GR characters, q=quit");
+ refresh();
+ } while ((c = Getchar()) != 'x' && c != 'q');
+
+ Pause();
+ erase();
+ endwin();
+}
+
+#if USE_WIDEC_SUPPORT
+static void
+show_upper_widechars(int first)
+{
+ cchar_t temp;
+ wchar_t code;
+ int last = first + 31;
+
+ erase();
+ attron(A_BOLD);
+ mvprintw(0, 20, "Display of Character Codes %d to %d", first, last);
+ attroff(A_BOLD);
+ refresh();
+
+ for (code = first; code <= last; code++) {
+ int row = 4 + ((code - first) % 16);
+ int col = ((code - first) / 16) * COLS / 2;
+ attr_t attrs = A_NORMAL;
+ char tmp[80];
+ sprintf(tmp, "%3d (0x%x)", code, code);
+ mvprintw(row, col, "%*s: ", COLS / 4, tmp);
+ setcchar(&temp, &code, attrs, 0, 0);
+ echo_wchar(&temp);
+ }
+}
+
+static int
+show_1_wacs(int n, const char *name, const cchar_t * code)
+{
+ const int height = 16;
+ int row = 4 + (n % height);
+ int col = (n / height) * COLS / 2;
+ mvprintw(row, col, "%*s : ", COLS / 4, name);
+ add_wchnstr(code, 1);
+ return n + 1;
+}
+
+static void
+show_wacs_chars(void)
+/* display the wide-ACS character set */
+{
+ int n;
+
+/*#define BOTH2(name) #name, &(name) */
+#define BOTH2(name) #name, name
+
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Display of the Wide-ACS Character Set");
+ attroff(A_BOLD);
+ refresh();
+
+ n = show_1_wacs(0, BOTH2(WACS_ULCORNER));
+ n = show_1_wacs(n, BOTH2(WACS_URCORNER));
+ n = show_1_wacs(n, BOTH2(WACS_LLCORNER));
+ n = show_1_wacs(n, BOTH2(WACS_LRCORNER));
+
+ n = show_1_wacs(n, BOTH2(WACS_LTEE));
+ n = show_1_wacs(n, BOTH2(WACS_RTEE));
+ n = show_1_wacs(n, BOTH2(WACS_TTEE));
+ n = show_1_wacs(n, BOTH2(WACS_BTEE));
+
+ n = show_1_wacs(n, BOTH2(WACS_HLINE));
+ n = show_1_wacs(n, BOTH2(WACS_VLINE));
+
+ n = show_1_wacs(n, BOTH2(WACS_LARROW));
+ n = show_1_wacs(n, BOTH2(WACS_RARROW));
+ n = show_1_wacs(n, BOTH2(WACS_UARROW));
+ n = show_1_wacs(n, BOTH2(WACS_DARROW));
+
+ n = show_1_wacs(n, BOTH2(WACS_BLOCK));
+ n = show_1_wacs(n, BOTH2(WACS_BOARD));
+ n = show_1_wacs(n, BOTH2(WACS_LANTERN));
+ n = show_1_wacs(n, BOTH2(WACS_BULLET));
+ n = show_1_wacs(n, BOTH2(WACS_CKBOARD));
+ n = show_1_wacs(n, BOTH2(WACS_DEGREE));
+ n = show_1_wacs(n, BOTH2(WACS_DIAMOND));
+ n = show_1_wacs(n, BOTH2(WACS_PLMINUS));
+ n = show_1_wacs(n, BOTH2(WACS_PLUS));
+
+#ifdef CURSES_WACS_ARRAY
+ n = show_1_wacs(n, BOTH2(WACS_GEQUAL));
+ n = show_1_wacs(n, BOTH2(WACS_NEQUAL));
+ n = show_1_wacs(n, BOTH2(WACS_LEQUAL));
+
+ n = show_1_wacs(n, BOTH2(WACS_STERLING));
+ n = show_1_wacs(n, BOTH2(WACS_PI));
+ n = show_1_wacs(n, BOTH2(WACS_S1));
+ n = show_1_wacs(n, BOTH2(WACS_S3));
+ n = show_1_wacs(n, BOTH2(WACS_S7));
+ n = show_1_wacs(n, BOTH2(WACS_S9));
+#endif
+}
+
+static void
+show_wbox_chars(void)
+{
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Display of the Wide-ACS Line-Drawing Set");
+ attroff(A_BOLD);
+ refresh();
+ box_set(stdscr, 0, 0);
+ /* *INDENT-OFF* */
+ mvhline_set(LINES / 2, 0, WACS_HLINE, COLS);
+ mvvline_set(0, COLS / 2, WACS_VLINE, LINES);
+ mvadd_wch(0, COLS / 2, WACS_TTEE);
+ mvadd_wch(LINES / 2, COLS / 2, WACS_PLUS);
+ mvadd_wch(LINES - 1, COLS / 2, WACS_BTEE);
+ mvadd_wch(LINES / 2, 0, WACS_LTEE);
+ mvadd_wch(LINES / 2, COLS - 1, WACS_RTEE);
+ /* *INDENT-ON* */
+
+}
+
+static int
+show_2_wacs(int n, const char *name, char *code)
+{
+ const int height = 16;
+ int row = 4 + (n % height);
+ int col = (n / height) * COLS / 2;
+ mvprintw(row, col, "%*s : ", COLS / 4, name);
+ addstr(code);
+ return n + 1;
+}
+
+static void
+show_utf8_chars(void)
+/* display the wide-ACS character set */
+{
+ int n;
+
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Display of the Wide-ACS Character Set");
+ attroff(A_BOLD);
+ refresh();
+ /* *INDENT-OFF* */
+ n = show_2_wacs(0, "WACS_ULCORNER", "\342\224\214");
+ n = show_2_wacs(n, "WACS_URCORNER", "\342\224\220");
+ n = show_2_wacs(n, "WACS_LLCORNER", "\342\224\224");
+ n = show_2_wacs(n, "WACS_LRCORNER", "\342\224\230");
+
+ n = show_2_wacs(n, "WACS_LTEE", "\342\224\234");
+ n = show_2_wacs(n, "WACS_RTEE", "\342\224\244");
+ n = show_2_wacs(n, "WACS_TTEE", "\342\224\254");
+ n = show_2_wacs(n, "WACS_BTEE", "\342\224\264");
+
+ n = show_2_wacs(n, "WACS_HLINE", "\342\224\200");
+ n = show_2_wacs(n, "WACS_VLINE", "\342\224\202");
+
+ n = show_2_wacs(n, "WACS_LARROW", "\342\206\220");
+ n = show_2_wacs(n, "WACS_RARROW", "\342\206\222");
+ n = show_2_wacs(n, "WACS_UARROW", "\342\206\221");
+ n = show_2_wacs(n, "WACS_DARROW", "\342\206\223");
+
+ n = show_2_wacs(n, "WACS_STERLING", "\302\243");
+
+ n = show_2_wacs(n, "WACS_BLOCK", "\342\226\256");
+ n = show_2_wacs(n, "WACS_BOARD", "\342\226\222");
+ n = show_2_wacs(n, "WACS_LANTERN", "\342\230\203");
+ n = show_2_wacs(n, "WACS_BULLET", "\302\267");
+ n = show_2_wacs(n, "WACS_CKBOARD", "\342\226\222");
+ n = show_2_wacs(n, "WACS_DEGREE", "\302\260");
+ n = show_2_wacs(n, "WACS_DIAMOND", "\342\227\206");
+ n = show_2_wacs(n, "WACS_GEQUAL", "\342\211\245");
+ n = show_2_wacs(n, "WACS_NEQUAL", "\342\211\240");
+ n = show_2_wacs(n, "WACS_LEQUAL", "\342\211\244");
+ n = show_2_wacs(n, "WACS_PLMINUS", "\302\261");
+ n = show_2_wacs(n, "WACS_PLUS", "\342\224\274");
+ n = show_2_wacs(n, "WACS_PI", "\317\200");
+ n = show_2_wacs(n, "WACS_S1", "\342\216\272");
+ n = show_2_wacs(n, "WACS_S3", "\342\216\273");
+ n = show_2_wacs(n, "WACS_S7", "\342\216\274");
+ n = show_2_wacs(n, "WACS_S9", "\342\216\275");
+ /* *INDENT-OFF* */
+}
+
+static void
+wide_acs_display(void)
+{
+ int c = 'a';
+
+ do {
+ switch (c) {
+ case 'a':
+ show_wacs_chars();
+ break;
+ case 'b':
+ show_wbox_chars();
+ break;
+ case 'u':
+ show_utf8_chars();
+ break;
+ default:
+ if (isdigit(c))
+ show_upper_widechars((c - '0') * 32 + 128);
+ break;
+ }
+ mvprintw(LINES - 2, 0,
+ "Select: a WACS, b box, u UTF-8, 0-9 non-ASCII characters, q=quit");
refresh();
} while ((c = Getchar()) != 'x' && c != 'q');
@@ -1037,6 +1598,8 @@ acs_display(void)
endwin();
}
+#endif
+
/*
* Graphic-rendition test (adapted from vttest)
*/
@@ -1138,21 +1701,30 @@ FRAME
WINDOW *wind;
};
+#ifdef NCURSES_VERSION
+#define keypad_active(win) (win)->_use_keypad
+#define scroll_active(win) (win)->_scroll
+#else
+#define keypad_active(win) FALSE
+#define scroll_active(win) FALSE
+#endif
+
/* We need to know if these flags are actually set, so don't look in FRAME.
- * These names are known to work with SVr4 curses as well as ncurses.
+ * These names are known to work with SVr4 curses as well as ncurses. The
+ * _use_keypad name does not work with Solaris 8.
*/
static bool
HaveKeypad(FRAME * curp)
{
WINDOW *win = (curp ? curp->wind : stdscr);
- return win->_use_keypad;
+ return keypad_active(win);
}
static bool
HaveScroll(FRAME * curp)
{
WINDOW *win = (curp ? curp->wind : stdscr);
- return win->_scroll;
+ return scroll_active(win);
}
static void
@@ -1628,7 +2200,7 @@ acs_and_scroll(void)
wrefresh(usescr);
} while
((c = wGetchar(usescr)) != QUIT
- && !((c == ESCAPE) && (usescr->_use_keypad))
+ && !((c == ESCAPE) && (keypad_active(usescr)))
&& (c != ERR));
breakout:
@@ -3260,6 +3832,12 @@ do_single_test(const char c)
getch_test();
break;
+#if USE_WIDEC_SUPPORT
+ case 'A':
+ get_wch_test();
+ break;
+#endif
+
case 'b':
attr_test();
break;
@@ -3288,6 +3866,12 @@ do_single_test(const char c)
acs_display();
break;
+#if USE_WIDEC_SUPPORT
+ case 'F':
+ wide_acs_display();
+ break;
+#endif
+
#if USE_LIBPANEL
case 'o':
demo_panels();
@@ -3367,7 +3951,7 @@ usage(void)
size_t n;
for (n = 0; n < SIZEOF(tbl); n++)
fprintf(stderr, "%s\n", tbl[n]);
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static void
@@ -3390,23 +3974,23 @@ announce_sig(int sig)
#endif
static int
-rip_footer(WINDOW *win, int columns)
+rip_footer(WINDOW *win, int cols)
{
wbkgd(win, A_REVERSE);
werase(win);
wmove(win, 0, 0);
- wprintw(win, "footer: %d columns", columns);
+ wprintw(win, "footer: %d columns", cols);
wnoutrefresh(win);
return OK;
}
static int
-rip_header(WINDOW *win, int columns)
+rip_header(WINDOW *win, int cols)
{
wbkgd(win, A_REVERSE);
werase(win);
wmove(win, 0, 0);
- wprintw(win, "header: %d columns", columns);
+ wprintw(win, "header: %d columns", cols);
wnoutrefresh(win);
return OK;
}
@@ -3505,12 +4089,14 @@ main(int argc, char *argv[])
start_color();
#ifdef NCURSES_VERSION_PATCH
max_colors = COLORS > 16 ? 16 : COLORS;
+#if HAVE_USE_DEFAULT_COLORS
if (default_colors)
use_default_colors();
#if NCURSES_VERSION_PATCH >= 20000708
else if (assumed_colors)
assume_default_colors(default_fg, default_bg);
#endif
+#endif
#else /* normal SVr4 curses */
max_colors = COLORS > 8 ? 8 : COLORS;
#endif
@@ -3541,11 +4127,17 @@ main(int argc, char *argv[])
do {
(void) puts("This is the ncurses main menu");
(void) puts("a = keyboard and mouse input test");
+#if USE_WIDEC_SUPPORT
+ (void) puts("A = wide-character keyboard and mouse input test");
+#endif
(void) puts("b = character attribute test");
(void) puts("c = color test pattern");
(void) puts("d = edit RGB color values");
(void) puts("e = exercise soft keys");
(void) puts("f = display ACS characters");
+#if USE_WIDEC_SUPPORT
+ (void) puts("F = display Wide-ACS characters");
+#endif
(void) puts("g = display windows and scrolling");
(void) puts("i = test of flushinp()");
(void) puts("k = display character attributes");
@@ -3581,7 +4173,7 @@ main(int argc, char *argv[])
if (command == 0)
command = 'q';
break;
- } else if (command == 0 && !isspace(CharOf(ch))) {
+ } else if (command == 0 && !isspace(UChar(ch))) {
command = ch;
} else if (ch == '\n' || ch == '\r') {
if (command != 0)
diff --git a/contrib/ncurses/test/newdemo.c b/contrib/ncurses/test/newdemo.c
index c0042e2..f10a2d6 100644
--- a/contrib/ncurses/test/newdemo.c
+++ b/contrib/ncurses/test/newdemo.c
@@ -2,14 +2,12 @@
* newdemo.c - A demo program using PDCurses. The program illustrate
* the use of colours for text output.
*
- * $Id: newdemo.c,v 1.18 2001/03/10 22:27:17 tom Exp $
+ * $Id: newdemo.c,v 1.23 2002/03/23 22:17:24 tom Exp $
*/
-#include <test.priv.h>
-
-#include <signal.h>
#include <time.h>
-#include <string.h>
+
+#include <test.priv.h>
#define delay_output(x) napms(x)
@@ -55,7 +53,7 @@ static RETSIGTYPE
trap(int sig GCC_UNUSED)
{
endwin();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
/*
@@ -236,7 +234,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
if (win == NULL) {
endwin();
- return 1;
+ ExitProgram(EXIT_FAILURE);
}
while (1) {
@@ -354,5 +352,5 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
break;
}
endwin();
- return 0;
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/railroad.c b/contrib/ncurses/test/railroad.c
index 6d5cd25..fd773c8 100644
--- a/contrib/ncurses/test/railroad.c
+++ b/contrib/ncurses/test/railroad.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * Copyright (c) 2000-2001,2002 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,15 +29,13 @@
/*
* Author: Thomas E. Dickey <dickey@clark.net> 2000
*
- * $Id: railroad.c,v 1.5 2001/03/24 22:01:42 tom Exp $
+ * $Id: railroad.c,v 1.10 2002/04/06 20:45:22 tom Exp $
*
* A simple demo of the termcap interface.
*/
#include <test.priv.h>
-#include <termcap.h>
#include <ctype.h>
-#include <signal.h>
static char *wipeit;
static char *moveit;
@@ -119,36 +117,38 @@ ShowSign(char *string)
while (*string != 0) {
ch = *string;
- if (moveit != 0) {
- for (first = length - 2; first >= (string - base); first--) {
- if (first < length - 1) {
- tputs(tgoto(moveit, first + 1, height - 1), 1, outc);
- PutChar(' ');
+ if (ch != ' ') {
+ if (moveit != 0) {
+ for (first = length - 2; first >= (string - base); first--) {
+ if (first < length - 1) {
+ tputs(tgoto(moveit, first + 1, height - 1), 1, outc);
+ PutChar(' ');
+ }
+ tputs(tgoto(moveit, first, height - 1), 1, outc);
+ PutChar(ch);
}
- tputs(tgoto(moveit, first, height - 1), 1, outc);
- PutChar(ch);
- }
- } else {
- last = ch;
- if (isalpha(ch)) {
- first = isupper(ch) ? 'A' : 'a';
- } else if (isdigit(ch)) {
- first = '0';
} else {
- first = ch;
- }
- if (first < last) {
- Underline(1);
- while (first < last) {
- PutChar(first);
- Backup();
- first++;
+ last = ch;
+ if (isalpha(ch)) {
+ first = isupper(ch) ? 'A' : 'a';
+ } else if (isdigit(ch)) {
+ first = '0';
+ } else {
+ first = ch;
+ }
+ if (first < last) {
+ Underline(1);
+ while (first < last) {
+ PutChar(first);
+ Backup();
+ first++;
+ }
+ Underline(0);
}
- Underline(0);
}
+ if (moveit != 0)
+ Backup();
}
- if (moveit != 0)
- Backup();
StandOut(1);
PutChar(ch);
StandOut(0);
@@ -173,7 +173,7 @@ onsig(int n GCC_UNUSED)
{
interrupted = TRUE;
cleanup();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static void
@@ -238,5 +238,5 @@ main(int argc, char *argv[])
{world, 0};
railroad(hello);
}
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/rain.c b/contrib/ncurses/test/rain.c
index a7771b0..46fa80a5 100644
--- a/contrib/ncurses/test/rain.c
+++ b/contrib/ncurses/test/rain.c
@@ -1,22 +1,22 @@
/*
- * $Id: rain.c,v 1.15 2000/09/02 18:41:22 tom Exp $
+ * $Id: rain.c,v 1.19 2002/04/06 20:45:22 tom Exp $
*/
#include <test.priv.h>
-#include <term.h> /* for tparm() */
-
-#include <signal.h>
-
/* rain 11/3/1980 EPS/CITHEP */
static float ranf(void);
static void onsig(int sig);
-static int next_j(int j)
+static int
+next_j(int j)
{
- if (j==0) j=4; else --j;
+ if (j == 0)
+ j = 4;
+ else
+ --j;
if (has_colors()) {
- int z = (int)(3*ranf());
+ int z = (int) (3 * ranf());
chtype color = COLOR_PAIR(z);
if (z)
color |= A_BOLD;
@@ -28,15 +28,16 @@ static int next_j(int j)
int
main(
int argc GCC_UNUSED,
- char *argv[] GCC_UNUSED)
+ char *argv[]GCC_UNUSED)
{
-int x, y, j;
-static int xpos[5], ypos[5];
-float r;
-float c;
+ int x, y, j;
+ static int xpos[5], ypos[5];
+ float r;
+ float c;
- for (j=SIGHUP;j<=SIGTERM;j++)
- if (signal(j,SIG_IGN)!=SIG_IGN) signal(j,onsig);
+ for (j = SIGHUP; j <= SIGTERM; j++)
+ if (signal(j, SIG_IGN) != SIG_IGN)
+ signal(j, onsig);
initscr();
if (has_colors()) {
@@ -44,7 +45,7 @@ float c;
start_color();
#if HAVE_USE_DEFAULT_COLORS
if (use_default_colors() == OK)
- bg = -1;
+ bg = -1;
#endif
init_pair(1, COLOR_BLUE, bg);
init_pair(2, COLOR_CYAN, bg);
@@ -54,18 +55,18 @@ float c;
curs_set(0);
timeout(0);
- r = (float)(LINES - 4);
- c = (float)(COLS - 4);
- for (j=5;--j>=0;) {
- xpos[j]=(int)(c* ranf())+2;
- ypos[j]=(int)(r* ranf())+2;
+ r = (float) (LINES - 4);
+ c = (float) (COLS - 4);
+ for (j = 5; --j >= 0;) {
+ xpos[j] = (int) (c * ranf()) + 2;
+ ypos[j] = (int) (r * ranf()) + 2;
}
- for (j=0;;) {
- x=(int)(c*ranf())+2;
- y=(int)(r*ranf())+2;
+ for (j = 0;;) {
+ x = (int) (c * ranf()) + 2;
+ y = (int) (r * ranf()) + 2;
- mvaddch(y,x, '.');
+ mvaddch(y, x, '.');
mvaddch(ypos[j], xpos[j], 'o');
@@ -73,33 +74,33 @@ float c;
mvaddch(ypos[j], xpos[j], 'O');
j = next_j(j);
- mvaddch( ypos[j]-1, xpos[j], '-');
- mvaddstr(ypos[j], xpos[j]-1, "|.|");
- mvaddch( ypos[j]+1, xpos[j], '-');
+ mvaddch(ypos[j] - 1, xpos[j], '-');
+ mvaddstr(ypos[j], xpos[j] - 1, "|.|");
+ mvaddch(ypos[j] + 1, xpos[j], '-');
j = next_j(j);
- mvaddch( ypos[j]-2, xpos[j], '-');
- mvaddstr(ypos[j]-1, xpos[j]-1, "/ \\");
- mvaddstr(ypos[j], xpos[j]-2, "| O |");
- mvaddstr(ypos[j]+1, xpos[j]-1, "\\ /");
- mvaddch( ypos[j]+2, xpos[j], '-');
+ mvaddch(ypos[j] - 2, xpos[j], '-');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
+ mvaddstr(ypos[j], xpos[j] - 2, "| O |");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
+ mvaddch(ypos[j] + 2, xpos[j], '-');
j = next_j(j);
- mvaddch( ypos[j]-2, xpos[j], ' ');
- mvaddstr(ypos[j]-1, xpos[j]-1, " ");
- mvaddstr(ypos[j], xpos[j]-2, " ");
- mvaddstr(ypos[j]+1, xpos[j]-1, " ");
- mvaddch( ypos[j]+2, xpos[j], ' ');
-
- xpos[j] = x; ypos[j] = y;
-
- switch(getch())
- {
- case('q'):
- case('Q'):
+ mvaddch(ypos[j] - 2, xpos[j], ' ');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
+ mvaddstr(ypos[j], xpos[j] - 2, " ");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
+ mvaddch(ypos[j] + 2, xpos[j], ' ');
+
+ xpos[j] = x;
+ ypos[j] = y;
+
+ switch (getch()) {
+ case ('q'):
+ case ('Q'):
curs_set(1);
endwin();
- return(EXIT_SUCCESS);
+ ExitProgram(EXIT_SUCCESS);
case 's':
nodelay(stdscr, FALSE);
break;
@@ -107,9 +108,9 @@ float c;
nodelay(stdscr, TRUE);
break;
#ifdef KEY_RESIZE
- case(KEY_RESIZE):
- r = (float)(LINES - 4);
- c = (float)(COLS - 4);
+ case (KEY_RESIZE):
+ r = (float) (LINES - 4);
+ c = (float) (COLS - 4);
break;
#endif
}
@@ -122,7 +123,7 @@ onsig(int n GCC_UNUSED)
{
curs_set(1);
endwin();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static float
diff --git a/contrib/ncurses/test/tclock.c b/contrib/ncurses/test/tclock.c
index 319b0d4..6661b83 100644
--- a/contrib/ncurses/test/tclock.c
+++ b/contrib/ncurses/test/tclock.c
@@ -1,7 +1,17 @@
#include "test.priv.h"
#include <math.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
/*
tclock - analog/digital clock for curses.
@@ -103,9 +113,7 @@ dline(int pair, int from_x, int from_y, int x2, int y2, char ch)
}
int
-main(
- int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
int i, cx, cy;
double cr, mradius, hradius, mangle, hangle;
@@ -119,6 +127,10 @@ main(
struct tm *t;
char szChar[10];
int my_bg = COLOR_BLACK;
+#if HAVE_GETTIMEOFDAY
+ struct timeval current;
+ double fraction = 0.0;
+#endif
initscr();
noecho();
@@ -172,7 +184,7 @@ main(
if (hours > 12.0)
hours -= 12.0;
- mangle = ((t->tm_min) * (2 * PI) / 60.0);
+ mangle = ((t->tm_min + (t->tm_sec / 60.0)) * (2 * PI) / 60.0);
mdx = A2X(mangle, mradius);
mdy = A2Y(mangle, mradius);
@@ -180,7 +192,11 @@ main(
hdx = A2X(hangle, hradius);
hdy = A2Y(hangle, hradius);
- sangle = ((t->tm_sec) * (2.0 * PI) / 60.0);
+#if HAVE_GETTIMEOFDAY
+ gettimeofday(&current, 0);
+ fraction = (current.tv_usec / 1.0e6);
+#endif
+ sangle = ((t->tm_sec + fraction) * (2.0 * PI) / 60.0);
sdx = A2X(sangle, sradius);
sdy = A2Y(sangle, sradius);
@@ -193,7 +209,7 @@ main(
if (has_colors())
attrset(COLOR_PAIR(1));
- plot(cx + sdx, cy - sdy, 'O');
+ dline(1, cx, cy, cx + sdx, cy - sdy, 'O');
if (has_colors())
attrset(COLOR_PAIR(0));
@@ -218,13 +234,13 @@ main(
break;
}
- plot(cx + sdx, cy - sdy, ' ');
dline(0, cx, cy, cx + hdx, cy - hdy, ' ');
dline(0, cx, cy, cx + mdx, cy - mdy, ' ');
+ dline(0, cx, cy, cx + sdx, cy - sdy, ' ');
}
curs_set(1);
endwin();
- return 0;
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/test.priv.h b/contrib/ncurses/test/test.priv.h
index f5ecf02..05973d9 100644
--- a/contrib/ncurses/test/test.priv.h
+++ b/contrib/ncurses/test/test.priv.h
@@ -29,7 +29,7 @@
/****************************************************************************
* Author: Thomas E. Dickey <dickey@clark.net> 1996 *
****************************************************************************/
-/* $Id: test.priv.h,v 1.20 2000/11/04 22:56:50 tom Exp $ */
+/* $Id: test.priv.h,v 1.34 2002/04/06 23:32:15 tom Exp $ */
#if HAVE_CONFIG_H
#include <ncurses_cfg.h>
@@ -40,14 +40,50 @@
#define HAVE_WRESIZE 0
#endif
-#ifndef HAVE_NC_ALLOC_H
-#define HAVE_NC_ALLOC_H 0
+#ifndef HAVE_CURSES_VERSION
+#define HAVE_CURSES_VERSION 0
+#endif
+
+#ifndef HAVE_FORM_H
+#define HAVE_FORM_H 0
+#endif
+
+#ifndef HAVE_LIBFORM
+#define HAVE_LIBFORM 0
+#endif
+
+#ifndef HAVE_LIBMENU
+#define HAVE_LIBMENU 0
+#endif
+
+#ifndef HAVE_LIBPANEL
+#define HAVE_LIBPANEL 0
#endif
#ifndef HAVE_LOCALE_H
#define HAVE_LOCALE_H 0
#endif
+#ifndef HAVE_MENU_H
+#define HAVE_MENU_H 0
+#endif
+
+#ifndef HAVE_NAPMS
+#define HAVE_NAPMS 1
+#endif
+
+#ifndef HAVE_NC_ALLOC_H
+#define HAVE_NC_ALLOC_H 0
+#endif
+
+#ifndef HAVE_PANEL_H
+#define HAVE_PANEL_H 0
+#endif
+
+#ifndef HAVE_WRESIZE
+#define HAVE_WRESIZE 0
+#endif
+
#ifndef NCURSES_NOMACROS
#define NCURSES_NOMACROS 0
#endif
@@ -64,7 +100,10 @@
#include <unistd.h>
#endif
+#include <signal.h> /* include before curses.h to work around glibc bug */
+
#include <curses.h>
+#include <term.h>
#if NCURSES_NOMACROS
#include <nomacros.h>
@@ -87,19 +126,74 @@ extern int optind;
#define GCC_UNUSED /* nothing */
#endif
-#define CharOf(c) ((unsigned char)(c))
+#ifndef HAVE_GETNSTR
+#define getnstr(s,n) getstr(s)
+#endif
+
+#ifndef USE_WIDEC_SUPPORT
+#if defined(_XOPEN_SOURCE_EXTENDED) && defined(WACS_ULCORNER)
+#define USE_WIDEC_SUPPORT 1
+#else
+#define USE_WIDEC_SUPPORT 0
+#endif
+#endif
+
+#ifndef HAVE_TYPE_ATTR_T
+#if !USE_WIDEC_SUPPORT
+#define attr_t long
+#endif
+#endif
+
+#ifndef NCURSES_CH_T
+#if !USE_WIDEC_SUPPORT
+#define NCURSES_CH_T chtype
+#else
+#define NCURSES_CH_T cchar_t
+#endif
+#endif
+
+#ifndef CCHARW_MAX
+#define CCHARW_MAX 5
+#endif
+
+#ifndef KEY_MIN
+#define KEY_MIN 256 /* not defined in Solaris 8 */
+#endif
+
+#ifndef getcurx
+#define getcurx(win) ((win)?(win)->_curx:ERR)
+#define getcury(win) ((win)?(win)->_cury:ERR)
+#endif
+
+#ifndef getbegx
+#define getbegx(win) ((win)?(win)->_begx:ERR)
+#define getbegy(win) ((win)?(win)->_begy:ERR)
+#endif
+
+#ifndef getmaxx
+#define getmaxx(win) ((win)?((win)->_maxx + 1):ERR)
+#define getmaxy(win) ((win)?((win)->_maxy + 1):ERR)
+#endif
+
+/* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
+ * (which is incompatible with legacy usage, doesn't solve any problems).
+ */
+#define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
+#define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0)
+
+#define UChar(c) ((unsigned char)(c))
#define SIZEOF(table) (sizeof(table)/sizeof(table[0]))
#if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
#include <nc_alloc.h>
#else
-#define typeMalloc(type,n) (type *) malloc(n * sizeof(type))
-#define typeRealloc(type,n,p) (type *) realloc(p, n * sizeof(type))
+#define typeMalloc(type,n) (type *) malloc((n) * sizeof(type))
+#define typeRealloc(type,n,p) (type *) realloc(p, (n) * sizeof(type))
#endif
#ifndef ExitProgram
-#define ExitProgram(code) return code
+#define ExitProgram(code) exit(code)
#endif
#ifndef EXIT_SUCCESS
diff --git a/contrib/ncurses/test/testaddch.c b/contrib/ncurses/test/testaddch.c
index 444da0a..311eb81 100644
--- a/contrib/ncurses/test/testaddch.c
+++ b/contrib/ncurses/test/testaddch.c
@@ -2,59 +2,58 @@
* This is an example written by Alexander V. Lukyanov <lav@yars.free.net>,
* to demonstrate an inconsistency between ncurses and SVr4 curses.
*
- * $Id: testaddch.c,v 1.3 1997/10/18 21:35:15 tom Exp $
+ * $Id: testaddch.c,v 1.4 2001/09/15 21:46:34 tom Exp $
*/
#include <test.priv.h>
-static void attr_addstr(const char *s, chtype a)
+static void
+attr_addstr(const char *s, chtype a)
{
- while(*s)
- addch(((unsigned char)(*s++))|a);
+ while (*s)
+ addch(((unsigned char) (*s++)) | a);
}
int
main(
int argc GCC_UNUSED,
- char *argv[] GCC_UNUSED)
+ char *argv[]GCC_UNUSED)
{
- unsigned i;
- chtype back,set,attr;
-
- initscr();
- start_color();
- init_pair(1,COLOR_WHITE,COLOR_BLUE);
- init_pair(2,COLOR_WHITE,COLOR_RED);
- init_pair(3,COLOR_BLACK,COLOR_MAGENTA);
- init_pair(4,COLOR_BLACK,COLOR_GREEN);
- init_pair(5,COLOR_BLACK,COLOR_CYAN);
- init_pair(6,COLOR_BLACK,COLOR_YELLOW);
- init_pair(7,COLOR_BLACK,COLOR_WHITE);
-
- for(i=0; i<8; i++)
- {
- back = (i&1) ? A_BOLD|'B' : ' ';
- set = (i&2) ? A_REVERSE : 0;
- attr = (i&4) ? COLOR_PAIR(4) : 0;
-
- bkgdset(back);
- attrset(set);
-
- attr_addstr("Test string with spaces -> <-\n",attr);
- }
- addch('\n');
- for(i=0; i<8; i++)
- {
- back = (i&1) ? A_BOLD|'B'|COLOR_PAIR(1) : ' ';
- set = (i&2) ? A_REVERSE|COLOR_PAIR(2) : 0;
- attr = (i&4) ? COLOR_PAIR(4) : 0;
-
- bkgdset(back);
- attrset(set);
-
- attr_addstr("Test string with spaces -> <-\n",attr);
- }
-
- getch();
- endwin();
- return EXIT_SUCCESS;
+ unsigned i;
+ chtype back, set, attr;
+
+ initscr();
+ start_color();
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ init_pair(2, COLOR_WHITE, COLOR_RED);
+ init_pair(3, COLOR_BLACK, COLOR_MAGENTA);
+ init_pair(4, COLOR_BLACK, COLOR_GREEN);
+ init_pair(5, COLOR_BLACK, COLOR_CYAN);
+ init_pair(6, COLOR_BLACK, COLOR_YELLOW);
+ init_pair(7, COLOR_BLACK, COLOR_WHITE);
+
+ for (i = 0; i < 8; i++) {
+ back = (i & 1) ? A_BOLD | 'B' : ' ';
+ set = (i & 2) ? A_REVERSE : 0;
+ attr = (i & 4) ? COLOR_PAIR(4) : 0;
+
+ bkgdset(back);
+ attrset(set);
+
+ attr_addstr("Test string with spaces -> <-\n", attr);
+ }
+ addch('\n');
+ for (i = 0; i < 8; i++) {
+ back = (i & 1) ? A_BOLD | 'B' | COLOR_PAIR(1) : ' ';
+ set = (i & 2) ? A_REVERSE | COLOR_PAIR(2) : 0;
+ attr = (i & 4) ? COLOR_PAIR(4) : 0;
+
+ bkgdset(back);
+ attrset(set);
+
+ attr_addstr("Test string with spaces -> <-\n", attr);
+ }
+
+ getch();
+ endwin();
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/testcurs.c b/contrib/ncurses/test/testcurs.c
index efcd39fa..b08c766 100644
--- a/contrib/ncurses/test/testcurs.c
+++ b/contrib/ncurses/test/testcurs.c
@@ -7,7 +7,7 @@
* wrs(5/28/93) -- modified to be consistent (perform identically) with either
* PDCurses or under Unix System V, R4
*
- * $Id: testcurs.c,v 1.24 2001/02/24 22:13:23 tom Exp $
+ * $Id: testcurs.c,v 1.28 2002/02/03 00:29:22 tom Exp $
*/
#include <test.priv.h>
@@ -36,7 +36,7 @@ typedef struct commands COMMAND;
const COMMAND command[] =
{
- {"Intro Test", introTest},
+ {"General Test", introTest},
{"Pad Test", padTest},
#if defined(PDCURSES) && !defined(XCURSES)
{"Resize Test", resizeTest},
@@ -51,22 +51,25 @@ int width, height;
int
main(
- int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
+ int argc GCC_UNUSED,
+ char *argv[]GCC_UNUSED)
{
WINDOW *win;
- int key, old_option = (-1), new_option = 0;
+ int key;
+ int old_option = (-1);
+ int new_option = 0;
bool quit = FALSE;
+ unsigned n;
#ifdef PDCDEBUG
PDC_debug("testcurs started\n");
#endif
if (!initTest(&win))
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
erase();
display_menu(old_option, new_option);
- while (1) {
+ for (;;) {
#ifdef A_COLOR
if (has_colors()) {
init_pair(1, COLOR_WHITE, COLOR_BLUE);
@@ -82,6 +85,17 @@ main(
keypad(stdscr, TRUE);
raw();
key = getch();
+ if (key < KEY_MIN && key > 0 && isalpha(key)) {
+ if (islower(key))
+ key = toupper(key);
+ for (n = 0; n < MAX_OPTIONS; ++n) {
+ if (key == command[n].text[0]) {
+ display_menu(old_option, new_option = n);
+ key = ' ';
+ break;
+ }
+ }
+ }
switch (key) {
case 10:
case 13:
@@ -106,6 +120,9 @@ main(
quit = TRUE;
break;
default:
+ beep();
+ break;
+ case ' ':
break;
}
if (quit == TRUE)
@@ -118,7 +135,7 @@ main(
#ifdef XCURSES
XCursesExit();
#endif
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
static void
@@ -186,7 +203,7 @@ introTest(WINDOW *win)
wrefresh(win);
cbreak();
mvwaddstr(win, 1, 1,
- "You should have rectangle in the middle of the screen");
+ "You should have rectangle in the middle of the screen");
mvwaddstr(win, 2, 1, "You should have heard a beep");
Continue(win);
return;
@@ -249,6 +266,8 @@ scrollTest(WINDOW *win)
static void
inputTest(WINDOW *win)
{
+ int answered;
+ int repeat;
int w, h, bx, by, sw, sh, i, c, num;
char buffer[80];
WINDOW *subWin;
@@ -317,7 +336,7 @@ inputTest(WINDOW *win)
#if defined(PDCURSES)
mouse_set(ALL_MOUSE_EVENTS);
#endif
- while (1) {
+ for (;;) {
wmove(win, 3, 5);
c = wgetch(win);
wclrtobot(win);
@@ -365,20 +384,38 @@ inputTest(WINDOW *win)
mouse_set(0L);
#endif
refresh();
- wclear(win);
- mvwaddstr(win, 3, 2, "The window should have moved");
- mvwaddstr(win, 4, 2,
- "This text should have appeared without you pressing a key");
- mvwaddstr(win, 6, 2, "Enter a number then a string separated by space");
- mvwin(win, 2, 1);
- wrefresh(win);
- echo();
- noraw();
- num = 0;
- *buffer = 0;
- mvwscanw(win, 7, 6, "%d %s", &num, buffer);
- mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
- Continue(win);
+
+ repeat = 0;
+ do {
+ static char *fmt[] = {
+ "%d %10s",
+ "%d %[a-zA-Z]s",
+ "%d %[][a-zA-Z]s",
+ "%d %[^0-9]"
+ };
+ char *format = fmt[repeat % SIZEOF(fmt)];
+
+ wclear(win);
+ mvwaddstr(win, 3, 2, "The window should have moved");
+ mvwaddstr(win, 4, 2,
+ "This text should have appeared without you pressing a key");
+ mvwprintw(win, 6, 2,
+ "Scanning with format \"%s\"", format);
+ mvwin(win, 2 + 2 * (repeat % 4), 1 + 2 * (repeat % 4));
+ erase();
+ refresh();
+ wrefresh(win);
+ echo();
+ noraw();
+ num = 0;
+ *buffer = 0;
+ answered = mvwscanw(win, 7, 6, format, &num, buffer);
+ mvwprintw(win, 8, 6,
+ "String: %s Number: %d (%d values read)",
+ buffer, num, answered);
+ Continue(win);
+ ++repeat;
+ } while (answered > 0);
}
static void
@@ -392,7 +429,7 @@ outputTest(WINDOW *win)
nl();
wclear(win);
mvwaddstr(win, 1, 1,
- "You should now have a screen in the upper left corner, and this text should have wrapped");
+ "You should now have a screen in the upper left corner, and this text should have wrapped");
mvwin(win, 2, 1);
waddstr(win, "\nThis text should be down\n");
waddstr(win, "and broken into two here ^");
@@ -409,7 +446,7 @@ outputTest(WINDOW *win)
if (LINES < 24 || COLS < 75) {
mvwaddstr(win, 5, 1,
- "Some tests have been skipped as they require a");
+ "Some tests have been skipped as they require a");
mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
Continue(win);
} else {
@@ -429,7 +466,7 @@ outputTest(WINDOW *win)
#endif
wclear(win1);
mvwaddstr(win1, 5, 1,
- "This text should appear; using overlay option");
+ "This text should appear; using overlay option");
copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
#if defined(PDCURSES) && !defined(XCURSES)
@@ -444,7 +481,7 @@ outputTest(WINDOW *win)
wclear(win1);
wattron(win1, A_BLINK);
mvwaddstr(win1, 4, 1,
- "This blinking text should appear in only the second window");
+ "This blinking text should appear in only the second window");
wattroff(win1, A_BLINK);
mvwin(win1, by, bx);
overlay(win, win1);
@@ -490,7 +527,7 @@ outputTest(WINDOW *win)
wclear(win);
wmove(win, 2, 2);
wprintw(win, "This is a formatted string in a window: %d %s\n", 42,
- "is it");
+ "is it");
mvwaddstr(win, 10, 1, "Enter a string: ");
wrefresh(win);
noraw();
@@ -514,7 +551,7 @@ outputTest(WINDOW *win)
wclear(win);
curs_set(0);
mvwaddstr(win, 1, 1,
- "The cursor should have disappeared (invisible)");
+ "The cursor should have disappeared (invisible)");
Continue(win);
}
@@ -608,7 +645,7 @@ padTest(WINDOW *dummy GCC_UNUSED)
mvwaddstr(pad, 5, 2, "This is a new pad");
wattrset(pad, A_NORMAL);
mvwaddstr(pad, 8, 0,
- "The end of this line should be truncated here:except now");
+ "The end of this line should be truncated here:except now");
mvwaddstr(pad, 11, 1, "This line should not appear.It will now");
wmove(pad, 10, 1);
wclrtoeol(pad);
@@ -652,6 +689,6 @@ display_menu(int old_option, int new_option)
mvaddstr(5 + new_option, 25, command[new_option].text);
attrset(A_NORMAL);
mvaddstr(13, 3,
- "Use Up and Down Arrows to select - Enter to run - Q to quit");
+ "Use Up and Down Arrows to select - Enter to run - Q to quit");
refresh();
}
diff --git a/contrib/ncurses/test/testscanw.c b/contrib/ncurses/test/testscanw.c
index c9a1623..a1c25b9 100644
--- a/contrib/ncurses/test/testscanw.c
+++ b/contrib/ncurses/test/testscanw.c
@@ -2,7 +2,7 @@
* Date: 1997/03/17
* From: bayern@morpheus.cis.yale.edu
*
- * $Id: testscanw.c,v 1.6 2000/11/04 23:32:56 tom Exp $
+ * $Id: testscanw.c,v 1.8 2001/09/15 21:41:45 tom Exp $
*/
#include <test.priv.h>
#include <ctype.h>
@@ -22,7 +22,7 @@ main(int argc, char *argv[])
trace(TRACE_UPDATE | TRACE_CALLS);
#endif
while (argc > 1) {
- if (isdigit(CharOf(*argv[1])))
+ if (isdigit(UChar(*argv[1])))
move(atoi(argv[1]), 0);
else if (!strcmp(argv[1], "-k"))
keypad(stdscr, TRUE);
@@ -35,5 +35,5 @@ main(int argc, char *argv[])
scanw("%20ld", response); /* yes, it's a pointer */
}
endwin();
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
diff --git a/contrib/ncurses/test/view.c b/contrib/ncurses/test/view.c
index ee60f27..83139d4 100644
--- a/contrib/ncurses/test/view.c
+++ b/contrib/ncurses/test/view.c
@@ -23,15 +23,14 @@
* scroll operation worked, and the refresh() code only had to do a
* partial repaint.
*
- * $Id: view.c,v 1.35 2001/01/14 01:39:24 tom Exp $
+ * $Id: view.c,v 1.52 2002/04/27 22:37:39 tom Exp $
*/
-#include <test.priv.h>
-
-#include <string.h>
#include <ctype.h>
-#include <signal.h>
#include <time.h>
+#include <locale.h>
+
+#include <test.priv.h>
#if HAVE_TERMIOS_H
# include <termios.h>
@@ -45,6 +44,8 @@
# endif
#endif
+#define my_pair 1
+
/* This is needed to compile 'struct winsize' */
#if NEED_PTEM_H
#include <sys/stream.h>
@@ -52,7 +53,7 @@
#endif
static RETSIGTYPE finish(int sig) GCC_NORETURN;
-static void show_all(void);
+static void show_all(const char *tag);
#if defined(SIGWINCH) && defined(TIOCGWINSZ) && HAVE_RESIZETERM
#define CAN_RESIZE 1
@@ -65,13 +66,13 @@ static RETSIGTYPE adjust(int sig);
static int interrupted;
#endif
-static int waiting;
-static int shift;
-static int utf8_mode = FALSE;
+static bool waiting = FALSE;
+static int shift = 0;
+static bool try_color = FALSE;
static char *fname;
-static chtype **lines;
-static chtype **lptr;
+static NCURSES_CH_T **my_lines;
+static NCURSES_CH_T **lptr;
static void
usage(void)
@@ -81,28 +82,37 @@ usage(void)
"Usage: view [options] file"
,""
,"Options:"
+ ," -c use color if terminal supports it"
+ ," -i ignore INT, QUIT, TERM signals"
," -n NUM specify maximum number of lines (default 1000)"
#if defined(KEY_RESIZE)
- ," -r use experimental KEY_RESIZE rather than our own handler"
+ ," -r use old-style sigwinch handler rather than KEY_RESIZE"
#endif
#ifdef TRACE
," -t trace screen updates"
," -T NUM specify trace mask"
#endif
- ," -u translate UTF-8 data"
};
size_t n;
for (n = 0; n < SIZEOF(msg); n++)
fprintf(stderr, "%s\n", msg[n]);
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static int
-ch_len(chtype * src)
+ch_len(NCURSES_CH_T * src)
{
int result = 0;
+#if USE_WIDEC_SUPPORT
+#endif
+
+#if USE_WIDEC_SUPPORT
+ while (getcchar(src++, NULL, NULL, NULL, NULL) > 0)
+ result++;
+#else
while (*src++)
result++;
+#endif
return result;
}
@@ -110,78 +120,56 @@ ch_len(chtype * src)
* Allocate a string into an array of chtype's. If UTF-8 mode is
* active, translate the string accordingly.
*/
-static chtype *
+static NCURSES_CH_T *
ch_dup(char *src)
{
unsigned len = strlen(src);
- chtype *dst = typeMalloc(chtype, len + 1);
+ NCURSES_CH_T *dst = typeMalloc(NCURSES_CH_T, len + 1);
unsigned j, k;
- unsigned utf_count = 0;
- unsigned utf_char = 0;
-
-#define UCS_REPL 0xfffd
+#if USE_WIDEC_SUPPORT
+ wchar_t wstr[CCHARW_MAX + 1];
+ wchar_t wch;
+ int l = 0;
+ mbstate_t state;
+ size_t rc;
+ int width;
+#endif
+#if USE_WIDEC_SUPPORT
+ memset(&state, 0, sizeof(state));
+#endif
for (j = k = 0; j < len; j++) {
- if (utf8_mode) {
- unsigned c = CharOf(src[j]);
- /* Combine UTF-8 into Unicode */
- if (c < 0x80) {
- /* We received an ASCII character */
- if (utf_count > 0)
- dst[k++] = UCS_REPL; /* prev. sequence incomplete */
- dst[k++] = c;
- utf_count = 0;
- } else if (c < 0xc0) {
- /* We received a continuation byte */
- if (utf_count < 1) {
- dst[k++] = UCS_REPL; /* ... unexpectedly */
- } else {
- if (!utf_char && !((c & 0x7f) >> (7 - utf_count))) {
- utf_char = UCS_REPL;
- }
- /* characters outside UCS-2 become UCS_REPL */
- if (utf_char > 0x03ff) {
- /* value would be >0xffff */
- utf_char = UCS_REPL;
- } else {
- utf_char <<= 6;
- utf_char |= (c & 0x3f);
- }
- utf_count--;
- if (utf_count == 0)
- dst[k++] = utf_char;
- }
- } else {
- /* We received a sequence start byte */
- if (utf_count > 0)
- dst[k++] = UCS_REPL; /* prev. sequence incomplete */
- if (c < 0xe0) {
- utf_count = 1;
- utf_char = (c & 0x1f);
- if (!(c & 0x1e))
- utf_char = UCS_REPL; /* overlong sequence */
- } else if (c < 0xf0) {
- utf_count = 2;
- utf_char = (c & 0x0f);
- } else if (c < 0xf8) {
- utf_count = 3;
- utf_char = (c & 0x07);
- } else if (c < 0xfc) {
- utf_count = 4;
- utf_char = (c & 0x03);
- } else if (c < 0xfe) {
- utf_count = 5;
- utf_char = (c & 0x01);
- } else {
- dst[k++] = UCS_REPL;
- utf_count = 0;
- }
- }
- } else {
- dst[k++] = src[j];
+#if USE_WIDEC_SUPPORT
+ rc = mbrtowc(&wch, src + j, len - j, &state);
+ if (rc == (size_t) -1 || rc == (size_t) -2)
+ break;
+ j += rc - 1;
+ if ((width = wcwidth(wch)) < 0)
+ break;
+ if ((width > 0 && l > 0) || l == CCHARW_MAX) {
+ wstr[l] = L'\0';
+ l = 0;
+ if (setcchar(dst + k, wstr, 0, 0, NULL) != OK)
+ break;
+ ++k;
}
+ if (width == 0 && l == 0)
+ wstr[l++] = L' ';
+ wstr[l++] = wch;
+#else
+ dst[k++] = src[j];
+#endif
+ }
+#if USE_WIDEC_SUPPORT
+ if (l > 0) {
+ wstr[l] = L'\0';
+ if (setcchar(dst + k, wstr, 0, 0, NULL) == OK)
+ ++k;
}
+ setcchar(dst + k, L"", 0, 0, NULL);
+#else
dst[k] = 0;
+#endif
return dst;
}
@@ -193,24 +181,43 @@ main(int argc, char *argv[])
char buf[BUFSIZ];
int i;
int my_delay = 0;
- chtype **olptr;
+ NCURSES_CH_T **olptr;
int length = 0;
int value = 0;
bool done = FALSE;
bool got_number = FALSE;
#if CAN_RESIZE
- bool use_resize = TRUE;
+ bool nonposix_resize = FALSE;
+#endif
+ const char *my_label = "Input";
+
+ setlocale(LC_ALL, "");
+
+#ifndef NCURSES_VERSION
+ /*
+ * We know ncurses will catch SIGINT if we don't establish our own handler.
+ * Other versions of curses may/may not catch it.
+ */
+ (void) signal(SIGINT, finish); /* arrange interrupts to terminate */
#endif
- while ((i = getopt(argc, argv, "n:rtT:u")) != EOF) {
+ while ((i = getopt(argc, argv, "cin:rtT:")) != EOF) {
switch (i) {
+ case 'c':
+ try_color = TRUE;
+ break;
+ case 'i':
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ break;
case 'n':
if ((MAXLINES = atoi(optarg)) < 1)
usage();
break;
#if CAN_RESIZE
case 'r':
- use_resize = FALSE;
+ nonposix_resize = TRUE;
break;
#endif
#ifdef TRACE
@@ -221,9 +228,6 @@ main(int argc, char *argv[])
trace(TRACE_CALLS);
break;
#endif
- case 'u':
- utf8_mode = TRUE;
- break;
default:
usage();
}
@@ -231,23 +235,21 @@ main(int argc, char *argv[])
if (optind + 1 != argc)
usage();
- if ((lines = typeMalloc(chtype *, MAXLINES + 2)) == 0)
+ if ((my_lines = typeMalloc(NCURSES_CH_T *, MAXLINES + 2)) == 0)
usage();
fname = argv[optind];
if ((fp = fopen(fname, "r")) == 0) {
perror(fname);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
-
- (void) signal(SIGINT, finish); /* arrange interrupts to terminate */
#if CAN_RESIZE
- if (use_resize)
+ if (nonposix_resize)
(void) signal(SIGWINCH, adjust); /* arrange interrupts to resize */
#endif
/* slurp the file */
- for (lptr = &lines[0]; (lptr - lines) < MAXLINES; lptr++) {
+ for (lptr = &my_lines[0]; (lptr - my_lines) < MAXLINES; lptr++) {
char temp[BUFSIZ], *s, *d;
int col;
@@ -263,19 +265,24 @@ main(int argc, char *argv[])
col = (col | 7) + 1;
while ((d - temp) != col)
*d++ = ' ';
- } else if (isprint(CharOf(*d)) || utf8_mode) {
+ } else
+#if USE_WIDEC_SUPPORT
+ col++, d++;
+#else
+ if (isprint(UChar(*d))) {
col++;
d++;
} else {
- sprintf(d, "\\%03o", CharOf(*s));
+ sprintf(d, "\\%03o", UChar(*s));
d += strlen(d);
col = (d - temp);
}
+#endif
}
*lptr = ch_dup(temp);
}
(void) fclose(fp);
- length = lptr - lines;
+ length = lptr - my_lines;
(void) initscr(); /* initialize the curses library */
keypad(stdscr, TRUE); /* enable keyboard mapping */
@@ -285,18 +292,30 @@ main(int argc, char *argv[])
nodelay(stdscr, TRUE);
idlok(stdscr, TRUE); /* allow use of insert/delete line */
- lptr = lines;
+ if (try_color) {
+ if (has_colors()) {
+ start_color();
+ init_pair(my_pair, COLOR_WHITE, COLOR_BLUE);
+ bkgd(COLOR_PAIR(my_pair));
+ } else {
+ try_color = FALSE;
+ }
+ }
+
+ lptr = my_lines;
while (!done) {
int n, c;
if (!got_number)
- show_all();
+ show_all(my_label);
n = 0;
for (;;) {
#if CAN_RESIZE
- if (interrupted)
+ if (interrupted) {
adjust(0);
+ my_label = "interrupt";
+ }
#endif
waiting = TRUE;
c = getch();
@@ -318,12 +337,14 @@ main(int argc, char *argv[])
n = 1;
}
+ if (c != ERR)
+ my_label = keyname(c);
switch (c) {
case KEY_DOWN:
case 'n':
olptr = lptr;
for (i = 0; i < n; i++)
- if ((lptr - lines) < (length - LINES + 1))
+ if ((lptr - my_lines) < (length - LINES + 1))
lptr++;
else
break;
@@ -334,7 +355,7 @@ main(int argc, char *argv[])
case 'p':
olptr = lptr;
for (i = 0; i < n; i++)
- if (lptr > lines)
+ if (lptr > my_lines)
lptr--;
else
break;
@@ -343,28 +364,29 @@ main(int argc, char *argv[])
case 'h':
case KEY_HOME:
- lptr = lines;
+ lptr = my_lines;
break;
case 'e':
case KEY_END:
if (length > LINES)
- lptr = lines + length - LINES + 1;
+ lptr = my_lines + length - LINES + 1;
else
- lptr = lines;
+ lptr = my_lines;
break;
case 'r':
case KEY_RIGHT:
- shift++;
+ shift += n;
break;
case 'l':
case KEY_LEFT:
- if (shift)
- shift--;
- else
+ shift -= n;
+ if (shift < 0) {
+ shift = 0;
beep();
+ }
break;
case 'q':
@@ -408,14 +430,20 @@ static RETSIGTYPE
finish(int sig)
{
endwin();
- exit(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
+ ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
#if CAN_RESIZE
/*
* This uses functions that are "unsafe", but it seems to work on SunOS and
- * Linux. The 'wrefresh(curscr)' is needed to force the refresh to start from
- * the top of the screen -- some xterms mangle the bitmap while resizing.
+ * Linux. Usually: the "unsafe" refers to the functions that POSIX lists
+ * which may be called from a signal handler. Those do not include buffered
+ * I/O, which is used for instance in wrefresh(). To be really portable, you
+ * should use the KEY_RESIZE return (which relies on ncurses' sigwinch
+ * handler).
+ *
+ * The 'wrefresh(curscr)' is needed to force the refresh to start from the top
+ * of the screen -- some xterms mangle the bitmap while resizing.
*/
static RETSIGTYPE
adjust(int sig)
@@ -424,9 +452,9 @@ adjust(int sig)
struct winsize size;
if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) {
- resizeterm(size.ws_row, size.ws_col);
+ resize_term(size.ws_row, size.ws_col);
wrefresh(curscr); /* Linux needs this */
- show_all();
+ show_all(sig ? "SIGWINCH" : "interrupt");
}
interrupted = FALSE;
} else {
@@ -437,15 +465,15 @@ adjust(int sig)
#endif /* CAN_RESIZE */
static void
-show_all(void)
+show_all(const char *tag)
{
int i;
char temp[BUFSIZ];
- chtype *s;
+ NCURSES_CH_T *s;
time_t this_time;
#if CAN_RESIZE
- sprintf(temp, "(%3dx%3d) col %d ", LINES, COLS, shift);
+ sprintf(temp, "%s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
i = strlen(temp);
sprintf(temp + i, "view %.*s", (int) (sizeof(temp) - 7 - i), fname);
#else
@@ -465,12 +493,18 @@ show_all(void)
scrollok(stdscr, FALSE); /* prevent screen from moving */
for (i = 1; i < LINES; i++) {
move(i, 0);
- printw("%3ld:", (long) (lptr + i - lines));
+ printw("%3ld:", (long) (lptr + i - my_lines));
clrtoeol();
if ((s = lptr[i - 1]) != 0) {
int len = ch_len(s);
if (len > shift)
+#if USE_WIDEC_SUPPORT
+ add_wchstr(s + shift);
+#else
addchstr(s + shift);
+#endif
+ if (try_color)
+ wchgat(stdscr, -1, A_NORMAL, my_pair, NULL);
}
}
setscrreg(1, LINES - 1);
diff --git a/contrib/ncurses/test/worm.c b/contrib/ncurses/test/worm.c
index 02d9e1f..d493d08 100644
--- a/contrib/ncurses/test/worm.c
+++ b/contrib/ncurses/test/worm.c
@@ -34,13 +34,11 @@ Options:
traces will be dumped. The program stops and waits for one character of
input at the beginning and end of the interval.
- $Id: worm.c,v 1.32 2000/12/31 01:54:07 tom Exp $
+ $Id: worm.c,v 1.36 2002/03/23 21:46:54 tom Exp $
*/
#include <test.priv.h>
-#include <signal.h>
-
static chtype flavor[] =
{
'O', '*', '#', '$', '%', '0', '@',
@@ -165,7 +163,7 @@ static RETSIGTYPE
onsig(int sig GCC_UNUSED)
{
cleanup();
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
static float
@@ -201,7 +199,7 @@ main(int argc, char *argv[])
goto usage;
if ((length = atoi(argv[x])) < 2 || length > 1024) {
fprintf(stderr, "%s: Invalid length\n", *argv);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
break;
case 'n':
@@ -209,7 +207,7 @@ main(int argc, char *argv[])
goto usage;
if ((number = atoi(argv[x])) < 1 || number > 40) {
fprintf(stderr, "%s: Invalid number of worms\n", *argv);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
break;
case 't':
@@ -230,8 +228,8 @@ main(int argc, char *argv[])
default:
usage:
fprintf(stderr,
- "usage: %s [-field] [-length #] [-number #] [-trail]\n", *argv);
- return EXIT_FAILURE;
+ "usage: %s [-field] [-length #] [-number #] [-trail]\n", *argv);
+ ExitProgram(EXIT_FAILURE);
}
}
@@ -286,14 +284,14 @@ main(int argc, char *argv[])
w->orientation = w->head = 0;
if (!(ip = typeMalloc(short, (length + 1)))) {
fprintf(stderr, "%s: out of memory\n", *argv);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
w->xpos = ip;
for (x = length; --x >= 0;)
*ip++ = -1;
if (!(ip = typeMalloc(short, (length + 1)))) {
fprintf(stderr, "%s: out of memory\n", *argv);
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
}
w->ypos = ip;
for (y = length; --y >= 0;)
@@ -365,7 +363,7 @@ main(int argc, char *argv[])
*/
if (ch == 'q') {
cleanup();
- return (EXIT_SUCCESS);
+ ExitProgram(EXIT_SUCCESS);
} else if (ch == 's') {
nodelay(stdscr, FALSE);
} else if (ch == ' ') {
@@ -400,14 +398,14 @@ main(int argc, char *argv[])
}
}
op = &(x == 0 ? (y == 0 ? upleft : (y == bottom ? lowleft :
- left)) :
- (x == last ? (y == 0 ? upright : (y == bottom ? lowright :
- right)) :
+ left)) :
+ (x == last ? (y == 0 ? upright : (y == bottom ? lowright :
+ right)) :
(y == 0 ? upper : (y == bottom ? lower : normal))))[w->orientation];
switch (op->nopts) {
case 0:
cleanup();
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
case 1:
w->orientation = op->opts[0];
break;
diff --git a/contrib/ncurses/test/xmas.c b/contrib/ncurses/test/xmas.c
index d99b821..f7edde7 100644
--- a/contrib/ncurses/test/xmas.c
+++ b/contrib/ncurses/test/xmas.c
@@ -92,12 +92,10 @@
/******************************************************************************/
/*
- * $Id: xmas.c,v 1.15 2000/09/02 18:45:53 tom Exp $
+ * $Id: xmas.c,v 1.18 2002/03/23 21:46:58 tom Exp $
*/
#include <test.priv.h>
-#include <signal.h>
-
#define FROMWHO "Mark Hessling - (M.Hessling@gu.edu.au)"
static int my_bg = COLOR_BLACK;
@@ -149,11 +147,10 @@ static int strng5(void);
static int reindeer(void);
static int blinkit(void);
-static RETSIGTYPE
-done(int sig) GCC_NORETURN;
+static RETSIGTYPE done(int sig) GCC_NORETURN;
- static void
- set_color(WINDOW *win, chtype color)
+static void
+set_color(WINDOW *win, chtype color)
{
if (has_colors()) {
static bool *pairs;
@@ -1156,5 +1153,5 @@ done(int sig GCC_UNUSED)
refresh();
endwin();
curs_set(1);
- exit(EXIT_SUCCESS);
+ ExitProgram(EXIT_SUCCESS);
}
OpenPOWER on IntegriCloud