commit 4e13ff39c341fe7c7fcc0190739a142aff9f9c37
Author: Silvan Jegen <[email protected]>
Date:   Sat Apr 12 20:50:51 2014 +0200

    Wrap mbtowc to check for errors

diff --git a/tr.c b/tr.c
index 9f92332..527c0e0 100644
--- a/tr.c
+++ b/tr.c
@@ -46,6 +46,17 @@ handleescapes(char *s)
        }
 }
 
+static int
+xmbtowc(wchar_t *unicodep, const char *s)
+{
+       int rv;
+
+       rv = mbtowc(unicodep, s, 4);
+       if (rv < 0)
+                       eprintf("mbtowc:");
+       return rv;
+}
+
 static void
 parsemapping(const char *set1, const char *set2, wchar_t *mappings)
 {
@@ -64,12 +75,12 @@ parsemapping(const char *set1, const char *set2, wchar_t 
*mappings)
        while(*s1) {
                if(*s1 == '\')
                        handleescapes(++s1);
-               leftbytes = mbtowc(&runeleft, s1, 4);
+               leftbytes = xmbtowc(&runeleft, s1);
                s1 += leftbytes;
                if(*s2 == '\')
                        handleescapes(++s2);
                if(*s2 != '

Reply via email to