Hi,

just to say the change

  11-05-27  A bug with command substitution with the shift jis locale has been
            fixed.

has been removed from ksh93u+ 2012-08-01 as well as from ksh93v found in the
git repository.  Please re-add the change as e.g. found in the attachment.
Maybe together some more comments to avoid such drops.  Even if the code works
for e.g. UTF-8 ... Shift-JIS is special as it includes ASCII characters in
its multi byte encoding.  Without this patch my own regression check will
trow out errors (see second attachment).


     Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
--- src/cmd/ksh93/sh/macro.c
+++ src/cmd/ksh93/sh/macro.c	2013-02-05 16:41:12.997452597 +0000
@@ -2026,6 +2026,9 @@ static void comsubst(Mac_t *mp,register
 	struct _mac_		savemac;
 	int			savtop = stktell(stkp);
 	char			lastc=0, *savptr = stkfreeze(stkp,0);
+#if SHOPT_MULTIBYTE
+	wchar_t			lastw=0;
+#endif /* SHOPT_MULTIBYTE */
 	int			was_history = sh_isstate(SH_HISTORY);
 	int			was_verbose = sh_isstate(SH_VERBOSE);
 	int			was_interactive = sh_isstate(SH_INTERACTIVE);
@@ -2209,6 +2209,17 @@ static void comsubst(Mac_t *mp,register
 		}
 		else if(lastc)
 		{
+#if SHOPT_MULTIBYTE
+			if(lastw)
+			{
+				int	n;
+				char	mb[8];
+				n = mbconv(mb, lastw);
+				mac_copy(mp,mb,n);
+				lastw = 0;
+			}
+			else
+#endif /* SHOPT_MULTIBYTE */
 			mac_copy(mp,&lastc,1);
 			lastc = 0;
 		}
@@ -2220,6 +2231,17 @@ static void comsubst(Mac_t *mp,register
 			ssize_t len = 1;
 
 			/* can't write past buffer so save last character */
+#if SHOPT_MULTIBYTE
+			if ((len = mbsize(str))>1)
+			{
+				len = mb2wc(lastw,str,len);
+				if (len < 0)
+				{
+					lastw = 0;
+					len = 1;
+				}
+			}
+#endif /* SHOPT_MULTIBYTE */
 			c -= len;
 			lastc = str[c];
 			str[c] = 0;
@@ -2240,6 +2262,17 @@ static void comsubst(Mac_t *mp,register
 	}
 	if(lastc)
 	{
+#if SHOPT_MULTIBYTE
+		if(lastw)
+		{
+			int	n;
+			char	mb[8];
+			n = mbconv(mb, lastw);
+			mac_copy(mp,mb,n);
+			lastw = 0;
+		}
+		else
+#endif /* SHOPT_MULTIBYTE */
 		mac_copy(mp,&lastc,1);
 		lastc = 0;
 	}

Attachment: sjis.sh
Description: sjis.sh

_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to