From 66b11df76ad19d0a90d73f1c21e9392acc2b70de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Thu, 15 Oct 1998 20:54:31 +0200
Subject: [PATCH] Fixed sign-expansion bug on little-endian systems.

Rev: src/builtin_functions.c:1.134
---
 src/builtin_functions.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index b596e15243..f6d874658e 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: builtin_functions.c,v 1.133 1998/10/15 18:47:51 grubba Exp $");
+RCSID("$Id: builtin_functions.c,v 1.134 1998/10/15 18:54:31 grubba Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "pike_macros.h"
@@ -636,8 +636,8 @@ void f_string_to_unicode(INT32 args)
       p_wchar1 *str1 = STR1(in);
       for(i = in->len; i--;) {
 	unsigned INT32 c = str1[i];
-	out->str[i * 2] = c >> 8;
 	out->str[i * 2 + 1] = c & 0xff;
+	out->str[i * 2] = c >> 8;
       }
     }
 #endif
@@ -736,7 +736,8 @@ void f_unicode_to_string(INT32 args)
     p_wchar1 *str1 = STR1(out);
 
     for (i = len; i--;) {
-      str1[i] = (in->str[i*2]<<8) + in->str[i*2 + 1];
+      str1[i] = (((unsigned char *)in->str)[i*2]<<8) +
+	((unsigned char *)in->str)[i*2 + 1];
     }
   }
 #endif /* BYTEORDER == 4321 */
-- 
GitLab