bug-bash
[Top][All Lists]
Advanced

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

[PATCH 1/2] Multibyte characters support for ansic_shouldqoute()


From: Roman Rakus
Subject: [PATCH 1/2] Multibyte characters support for ansic_shouldqoute()
Date: Tue, 16 Aug 2011 15:42:38 +0200

Properly check for printable characters in ansic_shouldqoute().
Use wchar_t* and iswprint() instead of isprint() and char*.

Signed-off-by: Roman Rakus <address@hidden>
---
 bash-4.2/lib/sh/strtrans.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/bash-4.2/lib/sh/strtrans.c b/bash-4.2/lib/sh/strtrans.c
index 2265782..57f9af0 100644
--- a/bash-4.2/lib/sh/strtrans.c
+++ b/bash-4.2/lib/sh/strtrans.c
@@ -277,10 +277,34 @@ ansic_shouldquote (string)
   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;
 }
 
-- 
1.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]