?
read-only

Current branch/tag:

Cloning the repository:

git clone https://abf.rosalinux.ru/import/bash.git bash

cd bash

Add this repository as a remote to an existing local repository:

git remote add bash https://abf.rosalinux.ru/import/bash.git

git fetch bash

git checkout -b my-local-tracking-branch bash/master_or_other_branch

About project

Bash is a GNU project sh-compatible shell or command language interpreter. Bash (Bourne Again shell) incorporates useful features from the Korn shell (ksh) and the C shell (csh). Most sh scripts can be run by bash without modification. Bash offers several improvements over sh, including command line editing, unlimited size command history, job control, shell functions and aliases, indexed arrays of unlimited size and integer arithmetic in any base from two to 64. Bash is ultimately intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard.

Last commit

avatar
dm has added 5d4db90502
LOG fix displaying unicode characters in some cases (#598)

Files in

bash / bash-4.2-multibyte.patch

100644 | 88 lines (83 sloc) | 1.74 KB
--- bash-4.2/lib/sh/strtrans.c.orig	2012-08-06 17:37:02.478363913 +0400
+++ bash-4.2/lib/sh/strtrans.c	2012-08-06 17:45:29.647803781 +0400
@@ -212,6 +212,11 @@
   if (str == 0 || *str == 0)
     return ((char *)0);
 
+#if defined (HANDLE_MULTIBYTE)
+  wchar_t wcc;
+  size_t wc_len;
+#endif
+
   l = strlen (str);
   rsize = 4 * l + 4;
   r = ret = (char *)xmalloc (rsize);
@@ -222,6 +227,9 @@
   for (s = str, l = 0; *s; s++)
     {
       c = *s;
+#if defined (HANDLE_MULTIBYTE)
+      wc_len = 1;
+#endif
       l = 1;		/* 1 == add backslash; 0 == no backslash */
       switch (c)
 	{
@@ -243,7 +251,12 @@
 	case '\'':
 	  break;
 	default:
-	  if (ISPRINT (c) == 0)
+#if defined (HANDLE_MULTIBYTE)
+          wc_len = mbrtowc(&wcc, s, MB_CUR_MAX, NULL);
+          if ((int)wc_len < 0 || iswprint(wcc) == 0)
+#else
+          if (ISPRINT (c) == 0)
+#endif
 	    {
 	      *r++ = '\\';
 	      *r++ = TOCHAR ((c >> 6) & 07);
@@ -256,7 +269,12 @@
 	}
       if (l)
 	*r++ = '\\';
+#if defined (HANDLE_MULTIBYTE)
+      for (; (int)wc_len > 0; wc_len--, c = wc_len ? *++s : c)
+          *r++ = c;
+#else
       *r++ = c;
+#endif
     }
 
   *r++ = '\'';
@@ -277,10 +295,34 @@
   if (string == 0)
     return 0;
 
+#if defined (HANDLE_MULTIBYTE)
+  const wchar_t *wcs;
+  wchar_t wcc;
+
+  wchar_t *wcstr = NULL;
+  size_t wclen, slen;
+
+ 
+  slen = mbstowcs (wcstr, string, 0);
+ 
+  if (slen == -1)
+    slen = 0;
+  wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (slen + 1));
+  mbstowcs (wcstr, string, slen + 1);
+
+  
+  for (wcs = wcstr; wcc = *wcs; wcs++)
+    if (iswprint(wcc) == 0)
+      {
+        free (wcstr);
+        return 1;
+      }
+  free (wcstr);
+#else
   for (s = string; c = *s; s++)
     if (ISPRINT (c) == 0)
       return 1;
-
+#endif
   return 0;
 }