]> granicus.if.org Git - neomutt/commitdiff
factor out ICONV_CONST from headers
authorRichard Russon <rich@flatcap.org>
Wed, 22 Nov 2017 22:45:12 +0000 (22:45 +0000)
committerRichard Russon <rich@flatcap.org>
Mon, 27 Nov 2017 00:04:29 +0000 (00:04 +0000)
charset.c
charset.h
handler.c
ncrypt/gnupgparse.c
rfc2047.c
sendlib.c

index 8530469e6d65c23e405f3d012f948a7c92d4202b..01b152157c20cd032a1126b97742a988983dd711 100644 (file)
--- a/charset.c
+++ b/charset.c
@@ -366,19 +366,18 @@ iconv_t mutt_iconv_open(const char *tocode, const char *fromcode, int flags)
  * If you're supplying inrepls, the source charset should be stateless;
  * if you're supplying an outrepl, the target charset should be.
  */
-size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
-                  char **outbuf, size_t *outbytesleft,
-                  ICONV_CONST char **inrepls, const char *outrepl)
+size_t mutt_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
+                  size_t *outbytesleft, const char **inrepls, const char *outrepl)
 {
   size_t rc = 0, ret1;
-  ICONV_CONST char *ib = *inbuf;
+  const char *ib = *inbuf;
   size_t ibl = *inbytesleft;
   char *ob = *outbuf;
   size_t obl = *outbytesleft;
 
   while (true)
   {
-    ret1 = iconv(cd, &ib, &ibl, &ob, &obl);
+    ret1 = iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);
     if (ret1 != (size_t) -1)
       rc += ret1;
     if (ibl && obl && errno == EILSEQ)
@@ -386,14 +385,14 @@ size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
       if (inrepls)
       {
         /* Try replacing the input */
-        ICONV_CONST char **t = NULL;
+        const char **t = NULL;
         for (t = inrepls; *t; t++)
         {
-          ICONV_CONST char *ib1 = *t;
+          const char *ib1 = *t;
           size_t ibl1 = strlen(*t);
           char *ob1 = ob;
           size_t obl1 = obl;
-          iconv(cd, &ib1, &ibl1, &ob1, &obl1);
+          iconv(cd, (ICONV_CONST char **) &ib1, &ibl1, &ob1, &obl1);
           if (!ibl1)
           {
             ib++;
@@ -410,7 +409,7 @@ size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
       /* Replace the output */
       if (!outrepl)
         outrepl = "?";
-      iconv(cd, 0, 0, &ob, &obl);
+      iconv(cd, NULL, NULL, &ob, &obl);
       if (obl)
       {
         int n = strlen(outrepl);
@@ -425,7 +424,7 @@ size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
         ob += n;
         obl -= n;
         rc++;
-        iconv(cd, 0, 0, 0, 0); /* for good measure */
+        iconv(cd, NULL, NULL, NULL, NULL); /* for good measure */
         continue;
       }
     }
@@ -446,7 +445,7 @@ size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
 int mutt_convert_string(char **ps, const char *from, const char *to, int flags)
 {
   iconv_t cd;
-  ICONV_CONST char *repls[] = { "\357\277\275", "?", 0 };
+  const char *repls[] = { "\357\277\275", "?", 0 };
   char *s = *ps;
 
   if (!s || !*s)
@@ -455,10 +454,10 @@ int mutt_convert_string(char **ps, const char *from, const char *to, int flags)
   if (to && from && (cd = mutt_iconv_open(to, from, flags)) != (iconv_t) -1)
   {
     int len;
-    ICONV_CONST char *ib = NULL;
+    const char *ib = NULL;
     char *buf = NULL, *ob = NULL;
     size_t ibl, obl;
-    ICONV_CONST char **inrepls = NULL;
+    const char **inrepls = NULL;
     char *outrepl = NULL;
 
     if (mutt_is_utf8(to))
@@ -507,7 +506,7 @@ struct FgetConv
   char *ob;
   char *ib;
   size_t ibl;
-  ICONV_CONST char **inrepls;
+  const char **inrepls;
 };
 
 /**
@@ -529,7 +528,7 @@ FGETCONV *fgetconv_open(FILE *file, const char *from, const char *to, int flags)
 {
   struct FgetConv *fc = NULL;
   iconv_t cd = (iconv_t) -1;
-  static ICONV_CONST char *repls[] = { "\357\277\275", "?", 0 };
+  static const char *repls[] = { "\357\277\275", "?", 0 };
 
   if (from && to)
     cd = mutt_iconv_open(to, from, flags);
@@ -613,8 +612,7 @@ int fgetconv(FGETCONV *_fc)
   if (fc->ibl)
   {
     size_t obl = sizeof(fc->bufo);
-    mutt_iconv(fc->cd, (ICONV_CONST char **) &fc->ib, &fc->ibl, &fc->ob, &obl,
-               fc->inrepls, 0);
+    mutt_iconv(fc->cd, (const char **) &fc->ib, &fc->ibl, &fc->ob, &obl, fc->inrepls, 0);
     if (fc->p < fc->ob)
       return (unsigned char) *(fc->p)++;
   }
index 61725ef4244203718c2290113dd85370b27c3ed8..2576c1a479b035f9e7e6aa254eb4e1014ac8a0fb 100644 (file)
--- a/charset.h
+++ b/charset.h
@@ -30,9 +30,8 @@
 int mutt_convert_string(char **ps, const char *from, const char *to, int flags);
 
 iconv_t mutt_iconv_open(const char *tocode, const char *fromcode, int flags);
-size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
-                  char **outbuf, size_t *outbytesleft,
-                  ICONV_CONST char **inrepls, const char *outrepl);
+size_t mutt_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
+                  size_t *outbytesleft, const char **inrepls, const char *outrepl);
 
 typedef void *FGETCONV;
 
index d07842ae1415cc45a86e010482e23548e7456c56..eae529880773029dd49c060fb4ffb6a6afa51c98 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -92,7 +92,7 @@ static void print_part_line(struct State *s, struct Body *b, int n)
 static void convert_to_state(iconv_t cd, char *bufi, size_t *l, struct State *s)
 {
   char bufo[BUFO_SIZE];
-  ICONV_CONST char *ib = NULL;
+  const char *ib = NULL;
   char *ob = NULL;
   size_t ibl, obl;
 
@@ -101,7 +101,7 @@ static void convert_to_state(iconv_t cd, char *bufi, size_t *l, struct State *s)
     if (cd != (iconv_t)(-1))
     {
       ob = bufo, obl = sizeof(bufo);
-      iconv(cd, 0, 0, &ob, &obl);
+      iconv(cd, NULL, NULL, &ob, &obl);
       if (ob != bufo)
         state_prefix_put(bufo, ob - bufo, s);
     }
index 510a249406be1cf45f5c979a40d2f29de608d053..7277d722439796be0fd750aa53c28bb3897e3859 100644 (file)
@@ -94,7 +94,7 @@ static void fix_uid(char *uid)
   {
     int n = s - uid + 1; /* chars available in original buffer */
     char *buf = NULL;
-    ICONV_CONST char *ib = NULL;
+    const char *ib = NULL;
     char *ob = NULL;
     size_t ibl, obl;
 
@@ -103,7 +103,7 @@ static void fix_uid(char *uid)
     ibl = d - uid + 1;
     ob = buf;
     obl = n;
-    iconv(cd, &ib, &ibl, &ob, &obl);
+    iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);
     if (!ibl)
     {
       if (ob - buf < n)
index 1effca00b0ef4a4a7388734a58321d41756e683c..367c9edbecc254a9de3daf68de5ef849f3057a42 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -53,9 +53,9 @@
 
 extern char RFC822Specials[];
 
-typedef size_t (*encoder_t)(char *s, ICONV_CONST char *d, size_t dlen, const char *tocode);
+typedef size_t (*encoder_t)(char *s, const char *d, size_t dlen, const char *tocode);
 
-static size_t convert_string(ICONV_CONST char *f, size_t flen, const char *from,
+static size_t convert_string(const char *f, size_t flen, const char *from,
                              const char *to, char **t, size_t *tlen)
 {
   iconv_t cd;
@@ -68,8 +68,8 @@ static size_t convert_string(ICONV_CONST char *f, size_t flen, const char *from,
     return (size_t)(-1);
   obl = 4 * flen + 1;
   ob = buf = mutt_mem_malloc(obl);
-  n = iconv(cd, &f, &flen, &ob, &obl);
-  if (n == (size_t)(-1) || iconv(cd, 0, 0, &ob, &obl) == (size_t)(-1))
+  n = iconv(cd, (ICONV_CONST char **) &f, &flen, &ob, &obl);
+  if (n == (size_t)(-1) || iconv(cd, NULL, NULL, &ob, &obl) == (size_t)(-1))
   {
     e = errno;
     FREE(&buf);
@@ -189,7 +189,7 @@ char *mutt_choose_charset(const char *fromcode, const char *charsets, char *u,
   return tocode;
 }
 
-static size_t b_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *tocode)
+static size_t b_encoder(char *s, const char *d, size_t dlen, const char *tocode)
 {
   char *s0 = s;
 
@@ -219,7 +219,7 @@ static size_t b_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *t
   return s - s0;
 }
 
-static size_t q_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *tocode)
+static size_t q_encoder(char *s, const char *d, size_t dlen, const char *tocode)
 {
   static const char hex[] = "0123456789ABCDEF";
   char *s0 = s;
@@ -250,7 +250,7 @@ static size_t q_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *t
 }
 
 /**
- * try_block - Attempt to convert a block ot text
+ * try_block - Attempt to convert a block of text
  * @param d        String to convert
  * @param dlen     Length of string
  * @param fromcode Original encoding
@@ -267,12 +267,12 @@ static size_t q_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *t
  * tocode, unless fromcode is 0, in which case the data is assumed to
  * be already in tocode, which should be 8-bit and stateless.
  */
-static size_t try_block(ICONV_CONST char *d, size_t dlen, const char *fromcode,
+static size_t try_block(const char *d, size_t dlen, const char *fromcode,
                         const char *tocode, encoder_t *encoder, size_t *wlen)
 {
   char buf1[ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 1];
   iconv_t cd;
-  ICONV_CONST char *ib = NULL;
+  const char *ib = NULL;
   char *ob = NULL;
   size_t ibl, obl;
   int count, len, len_b, len_q;
@@ -285,8 +285,8 @@ static size_t try_block(ICONV_CONST char *d, size_t dlen, const char *fromcode,
     ibl = dlen;
     ob = buf1;
     obl = sizeof(buf1) - strlen(tocode);
-    if (iconv(cd, &ib, &ibl, &ob, &obl) == (size_t)(-1) ||
-        iconv(cd, 0, 0, &ob, &obl) == (size_t)(-1))
+    if (iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl) == (size_t)(-1) ||
+        iconv(cd, NULL, NULL, &ob, &obl) == (size_t)(-1))
     {
       assert(errno == E2BIG);
       iconv_close(cd);
@@ -353,7 +353,7 @@ static size_t encode_block(char *s, char *d, size_t dlen, const char *fromcode,
 {
   char buf1[ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 1];
   iconv_t cd;
-  ICONV_CONST char *ib = NULL;
+  const char *ib = NULL;
   char *ob = NULL;
   size_t ibl, obl, n1, n2;
 
@@ -365,8 +365,8 @@ static size_t encode_block(char *s, char *d, size_t dlen, const char *fromcode,
     ibl = dlen;
     ob = buf1;
     obl = sizeof(buf1) - strlen(tocode);
-    n1 = iconv(cd, &ib, &ibl, &ob, &obl);
-    n2 = iconv(cd, 0, 0, &ob, &obl);
+    n1 = iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);
+    n2 = iconv(cd, NULL, NULL, &ob, &obl);
     assert(n1 != (size_t)(-1) && n2 != (size_t)(-1));
     iconv_close(cd);
     return (*encoder)(s, buf1, ob - buf1, tocode);
@@ -425,7 +425,7 @@ static size_t choose_block(char *d, size_t dlen, int col, const char *fromcode,
  * The input data is assumed to be a single line starting at column col;
  * if col is non-zero, the preceding character was a space.
  */
-static int rfc2047_encode(ICONV_CONST char *d, size_t dlen, int col, const char *fromcode,
+static int rfc2047_encode(const char *d, size_t dlen, int col, const char *fromcode,
                           const char *charsets, char **e, size_t *elen, char *specials)
 {
   int rc = 0;
index dbdacfbff469bb164e0a889dfc60ad1d33256a5a..c0a3cacb61dd8a796d2deb17fd2c5bee09a6a55f 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -684,7 +684,7 @@ static size_t convert_file_to(FILE *file, const char *fromcode, int ncodes,
 {
   iconv_t cd1, *cd = NULL;
   char bufi[256], bufu[512], bufo[4 * sizeof(bufi)];
-  ICONV_CONST char *ib = NULL, *ub = NULL;
+  const char *ib = NULL, *ub = NULL;
   char *ob = NULL;
   size_t ibl, obl, ubl, ubl1, n, ret;
   struct Content *infos = NULL;
@@ -724,7 +724,7 @@ static size_t convert_file_to(FILE *file, const char *fromcode, int ncodes,
     ib = bufi;
     ob = bufu;
     obl = sizeof(bufu);
-    n = iconv(cd1, ibl ? &ib : 0, &ibl, &ob, &obl);
+    n = iconv(cd1, (ICONV_CONST char **) (ibl ? &ib : 0), &ibl, &ob, &obl);
     assert(n == (size_t)(-1) || !n);
     if (n == (size_t)(-1) && ((errno != EINVAL && errno != E2BIG) || ib == bufi))
     {
@@ -743,7 +743,7 @@ static size_t convert_file_to(FILE *file, const char *fromcode, int ncodes,
         ubl = ubl1;
         ob = bufo;
         obl = sizeof(bufo);
-        n = iconv(cd[i], (ibl || ubl) ? &ub : 0, &ubl, &ob, &obl);
+        n = iconv(cd[i], (ICONV_CONST char **) ((ibl || ubl) ? &ub : 0), &ubl, &ob, &obl);
         if (n == (size_t)(-1))
         {
           assert(errno == E2BIG || (BUGGY_ICONV && (errno == EILSEQ || errno == ENOENT)));