summaryrefslogtreecommitdiffstats
path: root/contrib/ncurses/ncurses/tty/hashmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/tty/hashmap.c')
-rw-r--r--contrib/ncurses/ncurses/tty/hashmap.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/contrib/ncurses/ncurses/tty/hashmap.c b/contrib/ncurses/ncurses/tty/hashmap.c
index 1f482d4..9b60df6 100644
--- a/contrib/ncurses/ncurses/tty/hashmap.c
+++ b/contrib/ncurses/ncurses/tty/hashmap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -70,7 +70,7 @@ AUTHOR
#include <curses.priv.h>
#include <term.h> /* for back_color_erase */
-MODULE_ID("$Id: hashmap.c,v 1.49 2006/03/11 19:33:49 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.56 2007/10/13 18:47:25 Miroslav.Lichvar Exp $")
#ifdef HASHDEBUG
@@ -81,7 +81,8 @@ MODULE_ID("$Id: hashmap.c,v 1.49 2006/03/11 19:33:49 tom Exp $")
# define screen_lines MAXLINES
# define TEXTWIDTH 1
int oldnums[MAXLINES], reallines[MAXLINES];
-static chtype oldtext[MAXLINES][TEXTWIDTH], newtext[MAXLINES][TEXTWIDTH];
+static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH];
+static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH];
# define OLDNUM(n) oldnums[n]
# define OLDTEXT(n) oldtext[n]
# define NEWTEXT(m) newtext[m]
@@ -89,7 +90,7 @@ static chtype oldtext[MAXLINES][TEXTWIDTH], newtext[MAXLINES][TEXTWIDTH];
#else /* !HASHDEBUG */
-# define OLDNUM(n) _nc_oldnums[n]
+# define OLDNUM(n) SP->_oldnum_list[n]
# define OLDTEXT(n) curscr->_line[n].text
# define NEWTEXT(m) newscr->_line[m].text
# define TEXTWIDTH (curscr->_maxx+1)
@@ -130,8 +131,8 @@ update_cost(NCURSES_CH_T * from, NCURSES_CH_T * to)
int cost = 0;
int i;
- for (i = TEXTWIDTH; i > 0; i--)
- if (!(CharEq(*from++, *to++)))
+ for (i = TEXTWIDTH; i > 0; i--, from++, to++)
+ if (!(CharEq(*from, *to)))
cost++;
return cost;
@@ -147,8 +148,8 @@ update_cost_from_blank(NCURSES_CH_T * to)
if (back_color_erase)
SetPair(blank, GetPair(stdscr->_nc_bkgd));
- for (i = TEXTWIDTH; i > 0; i--)
- if (!(CharEq(blank, *to++)))
+ for (i = TEXTWIDTH; i > 0; i--, to++)
+ if (!(CharEq(blank, *to)))
cost++;
return cost;
@@ -446,11 +447,14 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
char line[BUFSIZ], *st;
int n;
- SP = typeCalloc(SCREEN, 1);
+ if (setupterm(NULL, fileno(stdout), (int *) 0) == ERR)
+ return EXIT_FAILURE;
+ (void) _nc_alloc_screen();
+
for (n = 0; n < screen_lines; n++) {
reallines[n] = n;
oldnums[n] = _NEWINDEX;
- oldtext[n][0] = newtext[n][0] = '.';
+ CharOf(oldtext[n][0]) = CharOf(newtext[n][0]) = '.';
}
if (isatty(fileno(stdin)))
@@ -462,7 +466,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
for (;;) {
/* grab a test command */
if (fgets(line, sizeof(line), stdin) == (char *) NULL)
- exit(EXIT_SUCCESS);
+ break;
switch (line[0]) {
case '#': /* comment */
@@ -484,22 +488,22 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
case 'n': /* use following letters as text of new lines */
for (n = 0; n < screen_lines; n++)
- newtext[n][0] = '.';
+ CharOf(newtext[n][0]) = '.';
for (n = 0; n < screen_lines; n++)
if (line[n + 1] == '\n')
break;
else
- newtext[n][0] = line[n + 1];
+ CharOf(newtext[n][0]) = line[n + 1];
break;
case 'o': /* use following letters as text of old lines */
for (n = 0; n < screen_lines; n++)
- oldtext[n][0] = '.';
+ CharOf(oldtext[n][0]) = '.';
for (n = 0; n < screen_lines; n++)
if (line[n + 1] == '\n')
break;
else
- oldtext[n][0] = line[n + 1];
+ CharOf(oldtext[n][0]) = line[n + 1];
break;
case 'd': /* dump state of test arrays */
@@ -508,12 +512,12 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
#endif
(void) fputs("Old lines: [", stdout);
for (n = 0; n < screen_lines; n++)
- putchar(oldtext[n][0]);
+ putchar(CharOf(oldtext[n][0]));
putchar(']');
putchar('\n');
(void) fputs("New lines: [", stdout);
for (n = 0; n < screen_lines; n++)
- putchar(newtext[n][0]);
+ putchar(CharOf(newtext[n][0]));
putchar(']');
putchar('\n');
break;
@@ -527,12 +531,17 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
_nc_scroll_optimize();
(void) fputs("Done.\n", stderr);
break;
+ default:
case '?':
usage();
break;
}
}
+#if NO_LEAKS
+ _nc_free_and_exit(EXIT_SUCCESS);
+#else
return EXIT_SUCCESS;
+#endif
}
#endif /* HASHDEBUG */
OpenPOWER on IntegriCloud