[hackers] [sbase] Wrap mbtowc to check for errors || Silvan Jegen

From: <git_AT_suckless.org>
Date: Sat, 12 Apr 2014 22:29:20 +0200

commit 4e13ff39c341fe7c7fcc0190739a142aff9f9c37
Author: Silvan Jegen <s.jegen_AT_gmail.com>
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
_AT_@ -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)
 {
_AT_@ -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 != '
Received on Sat Apr 12 2014 - 22:29:20 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 12 2014 - 22:36:20 CEST