more useful list primitives
[apps/madmutt.git] / mbyte.c
diff --git a/mbyte.c b/mbyte.c
index 4750581..6c9a76c 100644 (file)
--- a/mbyte.c
+++ b/mbyte.c
@@ -1,19 +1,10 @@
 /*
+ * Copyright notice from original mutt:
  * Copyright (C) 2000 Edmund Grimley Evans <edmundo@rano.org>
  *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- *
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- *
- *     You should have received a copy of the GNU General Public License
- *     along with this program; if not, write to the Free Software
- *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
  */
 
 /*
 # include "config.h"
 #endif
 
+#include <lib-lib/macros.h>
+
 #include "mutt.h"
 #include "mbyte.h"
 #include "charset.h"
 
+
 #include <errno.h>
 
 #include <ctype.h>
@@ -98,7 +92,7 @@ void mutt_set_charset (char *charset)
 static size_t wcrtomb_iconv (char *s, wchar_t wc, iconv_t cd)
 {
   char buf[MB_LEN_MAX];
-  ICONV_CONST char *ib;
+  const char *ib;
   char *ob;
   size_t ibl, obl, r;
 
@@ -109,14 +103,14 @@ static size_t wcrtomb_iconv (char *s, wchar_t wc, iconv_t cd)
     ib = buf;
     ob = s;
     obl = MB_LEN_MAX;
-    r = iconv (cd, &ib, &ibl, &ob, &obl);
+    r = my_iconv(cd, &ib, &ibl, &ob, &obl);
   }
   else {
     ib = "";
     ibl = 1;
     ob = buf;
     obl = sizeof (buf);
-    r = iconv (cd, &ib, &ibl, &ob, &obl);
+    r = my_iconv(cd, &ib, &ibl, &ob, &obl);
   }
   return ob - s;
 }
@@ -145,7 +139,7 @@ size_t mbrtowc_iconv (wchar_t * pwc, const char *s, size_t n,
                       mbstate_t * ps, iconv_t cd)
 {
   static mbstate_t mbstate;
-  ICONV_CONST char *ib, *ibmax;
+  const char *ib, *ibmax;
   char *ob, *t;
   size_t ibl, obl, k, r;
   char bufi[8], bufo[6];
@@ -175,10 +169,10 @@ size_t mbrtowc_iconv (wchar_t * pwc, const char *s, size_t n,
   ibl = 1;
 
   for (;;) {
-    r = iconv (cd, &ib, &ibl, &ob, &obl);
+    r = my_iconv(cd, &ib, &ibl, &ob, &obl);
     if (ob > bufo && (!k || ib > bufi + k)) {
       /* we have a character */
-      memset (ps, 0, sizeof (*ps));
+      p_clear(ps, 1);
       utf8rtowc (pwc, bufo, ob - bufo, &mbstate);
       return (pwc && *pwc) ? (ib - (k ? bufi + k : s)) : 0;
     }
@@ -195,7 +189,7 @@ size_t mbrtowc_iconv (wchar_t * pwc, const char *s, size_t n,
       }
       else {
         /* save the state and give up */
-        memset (ps, 0, sizeof (*ps));
+        p_clear(ps, 1);
         if (ibl <= sizeof (mbstate_t))  /* need extra condition here! */
           memcpy (ps, ib, ibl);
         return (size_t) (-2);
@@ -222,7 +216,7 @@ size_t mbrtowc (wchar_t * pwc, const char *s, size_t n, mbstate_t * ps)
     return mbrtowc_iconv (pwc, s, n, ps, charset_to_utf8);
   else {
     if (!s) {
-      memset (ps, 0, sizeof (*ps));
+      p_clear(ps, 1);
       return 0;
     }
     if (!n)
@@ -438,7 +432,7 @@ size_t utf8rtowc (wchar_t * pwc, const char *s, size_t n, mbstate_t * _ps)
 
 #endif /* !HAVE_WC_FUNCS */
 
-wchar_t replacement_char ()
+wchar_t replacement_char (void)
 {
   return Charset_is_utf8 ? 0xfffd : '?';
 }