/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2015,2016 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 *
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: hashmap.c,v 1.62 2010/04/24 23:46:07 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.66 2016/05/28 23:32:40 tom Exp $")
#ifdef HASHDEBUG
# define _tracef printf
# undef TR
+# ifdef TRACE
# define TR(n, a) if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
+# else
+# define TR(n, a) { _tracef a ; putchar('\n'); }
+# endif
# undef screen_lines
-# define screen_lines MAXLINES
-# define TEXTWIDTH 1
+# define screen_lines(sp) MAXLINES
+# define TEXTWIDTH(sp) 1
int oldnums[MAXLINES], reallines[MAXLINES];
-static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH];
-static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH];
+static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH(sp)];
+static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH(sp)];
# define OLDNUM(sp,n) oldnums[n]
# define OLDTEXT(sp,n) oldtext[n]
# define NEWTEXT(sp,m) newtext[m]
int i;
NCURSES_CH_T ch;
unsigned long result = 0;
+ (void) sp;
+
for (i = TEXTWIDTH(sp); i > 0; i--) {
ch = *text++;
result += (result << 5) + (unsigned long) HASH_VAL(ch);
{
int cost = 0;
int i;
+ (void) sp;
for (i = TEXTWIDTH(sp); i > 0; i--, from++, to++)
if (!(CharEq(*from, *to)))
int cost = 0;
int i;
NCURSES_CH_T blank = blankchar;
+ (void) sp;
if (back_color_erase)
SetPair(blank, GetPair(stdscr->_nc_bkgd));
* effective. 'blank' indicates whether the line 'to' would become blank.
*/
static NCURSES_INLINE bool
-cost_effective(SCREEN *sp, const int from, const int to, const bool blank)
+cost_effective(SCREEN *sp, const int from, const int to, const int blank)
{
int new_from;
static void
grow_hunks(SCREEN *sp)
{
- int start, end, shift;
- int back_limit, forward_limit; /* limits for cells to fill */
- int back_ref_limit, forward_ref_limit; /* limits for refrences */
+ int back_limit; /* limits for cells to fill */
+ int back_ref_limit; /* limit for references */
int i;
int next_hunk;
while (i < screen_lines(sp) && OLDNUM(sp, i) == _NEWINDEX)
i++;
for (; i < screen_lines(sp); i = next_hunk) {
- start = i;
- shift = OLDNUM(sp, i) - i;
+ int forward_limit;
+ int forward_ref_limit;
+ int end;
+ int start = i;
+ int shift = OLDNUM(sp, i) - i;
/* get forward limit */
i = start + 1;
{
HASHMAP *hsp;
register int i;
- int start, shift, size;
if (screen_lines(SP_PARM) > lines_alloc(SP_PARM)) {
if (hashtab(SP_PARM))
* more than carry.
*/
for (i = 0; i < screen_lines(SP_PARM);) {
+ int start, shift, size;
+
while (i < screen_lines(SP_PARM) && OLDNUM(SP_PARM, i) == _NEWINDEX)
i++;
if (i >= screen_lines(SP_PARM))
return EXIT_FAILURE;
(void) _nc_alloc_screen();
- for (n = 0; n < screen_lines; n++) {
+ for (n = 0; n < screen_lines(sp); n++) {
reallines[n] = n;
oldnums[n] = _NEWINDEX;
CharOf(oldtext[n][0]) = CharOf(newtext[n][0]) = '.';
}
- if (isatty(fileno(stdin)))
+ if (NC_ISATTY(fileno(stdin)))
usage();
#ifdef TRACE
break;
case 'l': /* get initial line number vector */
- for (n = 0; n < screen_lines; n++) {
+ for (n = 0; n < screen_lines(sp); n++) {
reallines[n] = n;
oldnums[n] = _NEWINDEX;
}
break;
case 'n': /* use following letters as text of new lines */
- for (n = 0; n < screen_lines; n++)
+ for (n = 0; n < screen_lines(sp); n++)
CharOf(newtext[n][0]) = '.';
- for (n = 0; n < screen_lines; n++)
+ for (n = 0; n < screen_lines(sp); n++)
if (line[n + 1] == '\n')
break;
else
break;
case 'o': /* use following letters as text of old lines */
- for (n = 0; n < screen_lines; n++)
+ for (n = 0; n < screen_lines(sp); n++)
CharOf(oldtext[n][0]) = '.';
- for (n = 0; n < screen_lines; n++)
+ for (n = 0; n < screen_lines(sp); n++)
if (line[n + 1] == '\n')
break;
else
_nc_linedump();
#endif
(void) fputs("Old lines: [", stdout);
- for (n = 0; n < screen_lines; n++)
+ for (n = 0; n < screen_lines(sp); n++)
putchar(CharOf(oldtext[n][0]));
putchar(']');
putchar('\n');
(void) fputs("New lines: [", stdout);
- for (n = 0; n < screen_lines; n++)
+ for (n = 0; n < screen_lines(sp); n++)
putchar(CharOf(newtext[n][0]));
putchar(']');
putchar('\n');