components/ksh93/patches/CR7065478.patch
author Edwin Beasant <Edwin.Beasant@oracle.com>
Mon, 23 Apr 2012 08:30:27 -0700
changeset 789 5f074ca23733
permissions -rw-r--r--
7106955 move ksh93 from ON to userland

--- a/src/lib/libast/comp/setlocale.c	Mon Dec 27 04:23:49 2010
+++ b/src/lib/libast/comp/setlocale.c	Fri Jul 22 00:30:31 2011
@@ -19,6 +19,9 @@
 *                   Phong Vo <[email protected]>                    *
 *                                                                      *
 ***********************************************************************/
+/*
+ * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ */
 #pragma prototyped
 
 /*
@@ -2236,6 +2239,24 @@
 
 typedef int (*Isw_f)(wchar_t);
 
+static int
+wide_wctomb(char* u, wchar_t w) 
+{
+	int size = 0;
+
+	if (u)
+	{
+		size = wctomb(u, w);
+		if (size < 0)
+		{
+			*u = (char)(w & 0xff);
+			size = 1;
+		}
+	}
+
+	return size;
+}
+
 /*
  * called when LC_CTYPE initialized or changes
  */
@@ -2280,7 +2301,7 @@
 	{
 		if (!(ast.mb_width = wcwidth))
 			ast.mb_width = default_wcwidth;
-		ast.mb_conv = wctomb;
+		ast.mb_conv = wide_wctomb;
 #ifdef mb_state
 		{
 			/*