Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Make sure utf-16 strings are written as little endi...



details:   https://anonhg.NetBSD.org/src/rev/322e9f9e85de
branches:  trunk
changeset: 780449:322e9f9e85de
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Jul 25 01:07:49 2012 +0000

description:
Make sure utf-16 strings are written as little endian words.

diffstat:

 sbin/gpt/gpt.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (31 lines):

diff -r bde4d7fe830f -r 322e9f9e85de sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c    Tue Jul 24 22:37:08 2012 +0000
+++ b/sbin/gpt/gpt.c    Wed Jul 25 01:07:49 2012 +0000
@@ -31,7 +31,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.15 2011/08/27 17:38:16 joerg Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.16 2012/07/25 01:07:49 matt Exp $");
 #endif
 
 #include <sys/param.h>
@@ -225,12 +225,14 @@
                }
                if (utfbytes == 0) {
                        if (utfchar >= 0x10000 && s16idx + 2 >= s16len)
-                               utfchar = 0xfffd;
+                               utfchar = htole16(0xfffd);
                        if (utfchar >= 0x10000) {
-                               s16[s16idx++] = 0xd800 | ((utfchar>>10)-0x40);
-                               s16[s16idx++] = 0xdc00 | (utfchar & 0x3ff);
+                               s16[s16idx++] =
+                                   htole16(0xd800 | ((utfchar>>10)-0x40));
+                               s16[s16idx++] =
+                                   htole16(0xdc00 | (utfchar & 0x3ff));
                        } else
-                               s16[s16idx++] = utfchar;
+                               s16[s16idx++] = htole16(utfchar);
                        if (s16idx == s16len) {
                                s16[--s16idx] = 0;
                                return;



Home | Main Index | Thread Index | Old Index