Created
September 6, 2021 12:09
-
-
Save rokuyama/fad462d0b63934e909b83b584dd3cdc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/libcurses/cur_hash.c | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libcurses/cur_hash.c,v | |
retrieving revision 1.13 | |
diff -p -u -r1.13 cur_hash.c | |
--- lib/libcurses/cur_hash.c 6 Jan 2017 09:14:07 -0000 1.13 | |
+++ lib/libcurses/cur_hash.c 6 Sep 2021 10:59:09 -0000 | |
@@ -63,3 +63,25 @@ __hash_more(const void *v_s, size_t len | |
} | |
return h; | |
} | |
+ | |
+unsigned int | |
+__hash_line(const __LDATA *cp, int ncols) | |
+{ | |
+#ifdef HAVE_WCHAR | |
+ unsigned int h; | |
+ const nschar_t *np; | |
+ int x; | |
+ | |
+ h = 0; | |
+ for (x = 0; x < ncols; x++) { | |
+ h = __hash_more(&cp->ch, sizeof(cp->ch), h); | |
+ h = __hash_more(&cp->attr, sizeof(cp->attr), h); | |
+ for (np = cp->nsp; np != NULL; np = np->next) | |
+ h = __hash_more(&np->ch, sizeof(np->ch), h); | |
+ cp++; | |
+ } | |
+ return h; | |
+#else | |
+ return __hash(cp, (size_t)(ncols * __LDATASIZE)); | |
+#endif | |
+} | |
Index: lib/libcurses/curses_private.h | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libcurses/curses_private.h,v | |
retrieving revision 1.75 | |
diff -p -u -r1.75 curses_private.h | |
--- lib/libcurses/curses_private.h 6 Sep 2021 07:03:49 -0000 1.75 | |
+++ lib/libcurses/curses_private.h 6 Sep 2021 10:59:10 -0000 | |
@@ -59,13 +59,17 @@ typedef struct nschar_t { | |
/* | |
* A window is an array of __LINE structures pointed to by the 'lines' pointer. | |
* A line is an array of __LDATA structures pointed to by the 'line' pointer. | |
- * | |
+ */ | |
+ | |
+#ifndef HAVE_WCHAR | |
+/* | |
* IMPORTANT: the __LDATA structure must NOT induce any padding, so if new | |
* fields are added -- padding fields with *constant values* should ensure | |
* that the compiler will not generate any padding when storing an array of | |
* __LDATA structures. This is to enable consistent use of memcmp, and memcpy | |
* for comparing and copying arrays. | |
*/ | |
+#endif | |
struct __ldata { | |
wchar_t ch; /* Character */ | |
@@ -373,6 +377,7 @@ void _cursesi_resetterm(SCREEN *); | |
int _cursesi_setterm(char *, SCREEN *); | |
int __delay(void); | |
unsigned int __hash_more(const void *, size_t, unsigned int); | |
+unsigned int __hash_line(const __LDATA *, int); | |
#define __hash(s, len) __hash_more((s), (len), 0u) | |
void __id_subwins(WINDOW *); | |
void __init_getch(SCREEN *); | |
Index: lib/libcurses/newwin.c | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libcurses/newwin.c,v | |
retrieving revision 1.61 | |
diff -p -u -r1.61 newwin.c | |
--- lib/libcurses/newwin.c 6 Sep 2021 07:03:50 -0000 1.61 | |
+++ lib/libcurses/newwin.c 6 Sep 2021 10:59:10 -0000 | |
@@ -169,8 +169,7 @@ __newwin(SCREEN *screen, int nlines, int | |
SET_WCOL(*sp, 1); | |
#endif /* HAVE_WCHAR */ | |
} | |
- lp->hash = __hash((char *)(void *)lp->line, | |
- (size_t)(maxx * __LDATASIZE)); | |
+ lp->hash = __hash_line(lp->line, maxx); | |
} | |
return (win); | |
} | |
@@ -227,11 +226,6 @@ __set_subwin(WINDOW *orig, WINDOW *win) | |
{ | |
int i; | |
__LINE *lp, *olp; | |
-#ifdef HAVE_WCHAR | |
- __LDATA *cp; | |
- int j; | |
- nschar_t *np; | |
-#endif /* HAVE_WCHAR */ | |
win->ch_off = win->begx - orig->begx; | |
/* Point line pointers to line space. */ | |
@@ -244,26 +238,7 @@ __set_subwin(WINDOW *orig, WINDOW *win) | |
lp->line = &olp->line[win->ch_off]; | |
lp->firstchp = &olp->firstch; | |
lp->lastchp = &olp->lastch; | |
-#ifndef HAVE_WCHAR | |
- lp->hash = __hash((char *)(void *)lp->line, | |
- (size_t)(win->maxx * __LDATASIZE)); | |
-#else | |
- lp->hash = 0; | |
- for (cp = lp->line, j = 0; j < win->maxx; j++, cp++) { | |
- lp->hash = __hash_more( &cp->ch, | |
- sizeof( wchar_t ), lp->hash ); | |
- lp->hash = __hash_more( &cp->attr, | |
- sizeof( wchar_t ), lp->hash ); | |
- if ( cp->nsp ) { | |
- np = cp->nsp; | |
- while ( np ) { | |
- lp->hash = __hash_more( &np->ch, | |
- sizeof( wchar_t ), lp->hash ); | |
- np = np->next; | |
- } | |
- } | |
- } | |
-#endif /* HAVE_WCHAR */ | |
+ lp->hash = __hash_line(lp->line, win->maxx); | |
} | |
__CTRACE(__CTRACE_WINDOW, "__set_subwin: win->ch_off = %d\n", | |
Index: lib/libcurses/refresh.c | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libcurses/refresh.c,v | |
retrieving revision 1.115 | |
diff -p -u -r1.115 refresh.c | |
--- lib/libcurses/refresh.c 6 Sep 2021 07:45:48 -0000 1.115 | |
+++ lib/libcurses/refresh.c 6 Sep 2021 10:59:10 -0000 | |
@@ -515,11 +515,6 @@ doupdate(void) | |
__LINE *wlp, *vlp; | |
short wy; | |
int dnum, was_cleared, changed; | |
-#ifdef HAVE_WCHAR | |
- __LDATA *lp; | |
- nschar_t *np; | |
- int x; | |
-#endif /* HAVE_WCHAR */ | |
/* Check if we need to restart ... */ | |
if (_cursesi_screen->endwin) | |
@@ -538,32 +533,8 @@ doupdate(void) | |
if (!_cursesi_screen->curwin) { | |
for (wy = 0; wy < win->maxy; wy++) { | |
wlp = win->alines[wy]; | |
- if (wlp->flags & __ISDIRTY) { | |
-#ifndef HAVE_WCHAR | |
- wlp->hash = __hash(wlp->line, | |
- (size_t)(win->maxx * __LDATASIZE)); | |
-#else | |
- wlp->hash = 0; | |
- for ( x = 0; x < win->maxx; x++ ) { | |
- lp = &wlp->line[ x ]; | |
- wlp->hash = __hash_more( &lp->ch, | |
- sizeof(wchar_t), wlp->hash ); | |
- wlp->hash = __hash_more( &lp->attr, | |
- sizeof(attr_t), wlp->hash ); | |
- np = lp->nsp; | |
- if (np) { | |
- while (np) { | |
- wlp->hash | |
- = __hash_more( | |
- &np->ch, | |
- sizeof(wchar_t), | |
- wlp->hash); | |
- np = np->next; | |
- } | |
- } | |
- } | |
-#endif /* HAVE_WCHAR */ | |
- } | |
+ if (wlp->flags & __ISDIRTY) | |
+ wlp->hash = __hash_line(wlp->line, win->maxx); | |
} | |
} | |
Index: lib/libcurses/resize.c | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libcurses/resize.c,v | |
retrieving revision 1.32 | |
diff -p -u -r1.32 resize.c | |
--- lib/libcurses/resize.c 6 Sep 2021 07:03:50 -0000 1.32 | |
+++ lib/libcurses/resize.c 6 Sep 2021 10:59:10 -0000 | |
@@ -360,8 +360,7 @@ __resizewin(WINDOW *win, int nlines, int | |
SET_WCOL(*sp, 1); | |
#endif /* HAVE_WCHAR */ | |
} | |
- lp->hash = __hash((char *)(void *)lp->line, | |
- (size_t)(ncols * __LDATASIZE)); | |
+ lp->hash = __hash_line(lp->line, ncols); | |
} | |
__CTRACE(__CTRACE_WINDOW, "resize: win->wattr = %08x\n", win->wattr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment