aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/nvi/common/log.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/contrib/nvi/common/log.c b/contrib/nvi/common/log.c
index 96b246efad02..d9b142b16d01 100644
--- a/contrib/nvi/common/log.c
+++ b/contrib/nvi/common/log.c
@@ -706,30 +706,18 @@ apply_with(int (*db_func)(SCR *, recno_t, CHAR_T *, size_t), SCR *sp,
recno_t lno, u_char *p, size_t len)
{
#ifdef USE_WIDECHAR
- typedef unsigned long nword;
-
static size_t blen;
- static nword *bp;
- nword *lp = (nword *)((uintptr_t)p / sizeof(nword) * sizeof(nword));
-
- if (lp != (nword *)p) {
- int offl = ((uintptr_t)p - (uintptr_t)lp) << 3;
- int offr = (sizeof(nword) << 3) - offl;
- size_t i, cnt = (len + sizeof(nword) / 2) / sizeof(nword);
+ static u_char *bp;
+ if (!__builtin_is_aligned(p, sizeof(unsigned long))) {
if (len > blen) {
blen = p2roundup(MAX(len, 512));
- REALLOC(sp, bp, nword *, blen);
+ REALLOC(sp, bp, u_char *, blen);
if (bp == NULL)
return (1);
}
- for (i = 0; i < cnt; ++i)
-#if BYTE_ORDER == BIG_ENDIAN
- bp[i] = (lp[i] << offl) ^ (lp[i+1] >> offr);
-#else
- bp[i] = (lp[i] >> offl) ^ (lp[i+1] << offr);
-#endif
- p = (u_char *)bp;
+ memmove(bp, p, len);
+ p = bp;
}
#endif
return db_func(sp, lno, (CHAR_T *)p, len / sizeof(CHAR_T));