]> granicus.if.org Git - neomutt/commitdiff
bool: convert extern variable in mbyte.h 798/head
authorAnton Rieger <seishinryohosha@jikken.de>
Thu, 28 Sep 2017 19:32:10 +0000 (21:32 +0200)
committerRichard Russon <rich@flatcap.org>
Fri, 29 Sep 2017 12:56:17 +0000 (13:56 +0100)
* Charset_is_utf8
* mutt_hcache_restore()
* mutt_set_charset()

Charset_is_utf8 affects `convert` in mutt_set_charset() and mutt_hcache_restore()
-> affects several static functions in hcache/hcache.c

* dump_address()
* dump_body()
* dump_buffer()
* dump_char()
* dump_char_size()
* dump_envelope()
* dump_parameter()
* dump_stailq()

* restore_address()
* restore_body()
* restore_buffer()
* restore_char()
* restore_envelope()
* restore_parameter()
* restore_stailq()

hcache/hcache.c
mbyte.c
mbyte.h

index 4f20cd5ab58c4c6d697986f00f13939034d94113..e6b3bd830a902a259021ea21cac28acab1b59e46 100644 (file)
@@ -181,7 +181,7 @@ static inline bool is_ascii(const char *p, size_t len)
 }
 
 static unsigned char *dump_char_size(char *c, unsigned char *d, int *off,
-                                     ssize_t size, int convert)
+                                     ssize_t size, bool convert)
 {
   char *p = c;
 
@@ -213,12 +213,12 @@ static unsigned char *dump_char_size(char *c, unsigned char *d, int *off,
   return d;
 }
 
-static unsigned char *dump_char(char *c, unsigned char *d, int *off, int convert)
+static unsigned char *dump_char(char *c, unsigned char *d, int *off, bool convert)
 {
   return dump_char_size(c, d, off, mutt_strlen(c) + 1, convert);
 }
 
-static void restore_char(char **c, const unsigned char *d, int *off, int convert)
+static void restore_char(char **c, const unsigned char *d, int *off, bool convert)
 {
   unsigned int size;
   restore_int(&size, d, off);
@@ -246,7 +246,7 @@ static void restore_char(char **c, const unsigned char *d, int *off, int convert
   *off += size;
 }
 
-static unsigned char *dump_address(struct Address *a, unsigned char *d, int *off, int convert)
+static unsigned char *dump_address(struct Address *a, unsigned char *d, int *off, bool convert)
 {
   unsigned int counter = 0;
   unsigned int start_off = *off;
@@ -256,7 +256,7 @@ static unsigned char *dump_address(struct Address *a, unsigned char *d, int *off
   while (a)
   {
     d = dump_char(a->personal, d, off, convert);
-    d = dump_char(a->mailbox, d, off, 0);
+    d = dump_char(a->mailbox, d, off, false);
     d = dump_int(a->group, d, off);
     a = a->next;
     counter++;
@@ -267,7 +267,7 @@ static unsigned char *dump_address(struct Address *a, unsigned char *d, int *off
   return d;
 }
 
-static void restore_address(struct Address **a, const unsigned char *d, int *off, int convert)
+static void restore_address(struct Address **a, const unsigned char *d, int *off, bool convert)
 {
   unsigned int counter;
 
@@ -277,7 +277,7 @@ static void restore_address(struct Address **a, const unsigned char *d, int *off
   {
     *a = rfc822_new_address();
     restore_char(&(*a)->personal, d, off, convert);
-    restore_char(&(*a)->mailbox, d, off, 0);
+    restore_char(&(*a)->mailbox, d, off, false);
     restore_int((unsigned int *) &(*a)->group, d, off);
     a = &(*a)->next;
     counter--;
@@ -286,7 +286,7 @@ static void restore_address(struct Address **a, const unsigned char *d, int *off
   *a = NULL;
 }
 
-static unsigned char *dump_stailq(struct ListHead *l, unsigned char *d, int *off, int convert)
+static unsigned char *dump_stailq(struct ListHead *l, unsigned char *d, int *off, bool convert)
 {
   unsigned int counter = 0;
   unsigned int start_off = *off;
@@ -305,7 +305,7 @@ static unsigned char *dump_stailq(struct ListHead *l, unsigned char *d, int *off
   return d;
 }
 
-static void restore_stailq(struct ListHead *l, const unsigned char *d, int *off, int convert)
+static void restore_stailq(struct ListHead *l, const unsigned char *d, int *off, bool convert)
 {
   unsigned int counter;
 
@@ -320,7 +320,7 @@ static void restore_stailq(struct ListHead *l, const unsigned char *d, int *off,
   }
 }
 
-static unsigned char *dump_buffer(struct Buffer *b, unsigned char *d, int *off, int convert)
+static unsigned char *dump_buffer(struct Buffer *b, unsigned char *d, int *off, bool convert)
 {
   if (!b)
   {
@@ -338,7 +338,7 @@ static unsigned char *dump_buffer(struct Buffer *b, unsigned char *d, int *off,
   return d;
 }
 
-static void restore_buffer(struct Buffer **b, const unsigned char *d, int *off, int convert)
+static void restore_buffer(struct Buffer **b, const unsigned char *d, int *off, bool convert)
 {
   unsigned int used;
   unsigned int offset;
@@ -359,7 +359,8 @@ static void restore_buffer(struct Buffer **b, const unsigned char *d, int *off,
   (*b)->destroy = used;
 }
 
-static unsigned char *dump_parameter(struct Parameter *p, unsigned char *d, int *off, int convert)
+static unsigned char *dump_parameter(struct Parameter *p, unsigned char *d,
+                                     int *off, bool convert)
 {
   unsigned int counter = 0;
   unsigned int start_off = *off;
@@ -368,7 +369,7 @@ static unsigned char *dump_parameter(struct Parameter *p, unsigned char *d, int
 
   while (p)
   {
-    d = dump_char(p->attribute, d, off, 0);
+    d = dump_char(p->attribute, d, off, false);
     d = dump_char(p->value, d, off, convert);
     p = p->next;
     counter++;
@@ -379,7 +380,8 @@ static unsigned char *dump_parameter(struct Parameter *p, unsigned char *d, int
   return d;
 }
 
-static void restore_parameter(struct Parameter **p, const unsigned char *d, int *off, int convert)
+static void restore_parameter(struct Parameter **p, const unsigned char *d,
+                              int *off, bool convert)
 {
   unsigned int counter;
 
@@ -388,7 +390,7 @@ static void restore_parameter(struct Parameter **p, const unsigned char *d, int
   while (counter)
   {
     *p = safe_malloc(sizeof(struct Parameter));
-    restore_char(&(*p)->attribute, d, off, 0);
+    restore_char(&(*p)->attribute, d, off, false);
     restore_char(&(*p)->value, d, off, convert);
     p = &(*p)->next;
     counter--;
@@ -397,7 +399,7 @@ static void restore_parameter(struct Parameter **p, const unsigned char *d, int
   *p = NULL;
 }
 
-static unsigned char *dump_body(struct Body *c, unsigned char *d, int *off, int convert)
+static unsigned char *dump_body(struct Body *c, unsigned char *d, int *off, bool convert)
 {
   struct Body nb;
 
@@ -415,8 +417,8 @@ static unsigned char *dump_body(struct Body *c, unsigned char *d, int *off, int
   memcpy(d + *off, &nb, sizeof(struct Body));
   *off += sizeof(struct Body);
 
-  d = dump_char(nb.xtype, d, off, 0);
-  d = dump_char(nb.subtype, d, off, 0);
+  d = dump_char(nb.xtype, d, off, false);
+  d = dump_char(nb.subtype, d, off, false);
 
   d = dump_parameter(nb.parameter, d, off, convert);
 
@@ -428,13 +430,13 @@ static unsigned char *dump_body(struct Body *c, unsigned char *d, int *off, int
   return d;
 }
 
-static void restore_body(struct Body *c, const unsigned char *d, int *off, int convert)
+static void restore_body(struct Body *c, const unsigned char *d, int *off, bool convert)
 {
   memcpy(c, d + *off, sizeof(struct Body));
   *off += sizeof(struct Body);
 
-  restore_char(&c->xtype, d, off, 0);
-  restore_char(&c->subtype, d, off, 0);
+  restore_char(&c->xtype, d, off, false);
+  restore_char(&c->subtype, d, off, false);
 
   restore_parameter(&c->parameter, d, off, convert);
 
@@ -444,7 +446,7 @@ static void restore_body(struct Body *c, const unsigned char *d, int *off, int c
   restore_char(&c->d_filename, d, off, convert);
 }
 
-static unsigned char *dump_envelope(struct Envelope *e, unsigned char *d, int *off, int convert)
+static unsigned char *dump_envelope(struct Envelope *e, unsigned char *d, int *off, bool convert)
 {
   d = dump_address(e->return_path, d, off, convert);
   d = dump_address(e->from, d, off, convert);
@@ -463,27 +465,27 @@ static unsigned char *dump_envelope(struct Envelope *e, unsigned char *d, int *o
   else
     d = dump_int(-1, d, off);
 
-  d = dump_char(e->message_id, d, off, 0);
-  d = dump_char(e->supersedes, d, off, 0);
-  d = dump_char(e->date, d, off, 0);
+  d = dump_char(e->message_id, d, off, false);
+  d = dump_char(e->supersedes, d, off, false);
+  d = dump_char(e->date, d, off, false);
   d = dump_char(e->x_label, d, off, convert);
 
   d = dump_buffer(e->spam, d, off, convert);
 
-  d = dump_stailq(&e->references, d, off, 0);
-  d = dump_stailq(&e->in_reply_to, d, off, 0);
+  d = dump_stailq(&e->references, d, off, false);
+  d = dump_stailq(&e->in_reply_to, d, off, false);
   d = dump_stailq(&e->userhdrs, d, off, convert);
 
 #ifdef USE_NNTP
-  d = dump_char(e->xref, d, off, 0);
-  d = dump_char(e->followup_to, d, off, 0);
+  d = dump_char(e->xref, d, off, false);
+  d = dump_char(e->followup_to, d, off, false);
   d = dump_char(e->x_comment_to, d, off, convert);
 #endif
 
   return d;
 }
 
-static void restore_envelope(struct Envelope *e, const unsigned char *d, int *off, int convert)
+static void restore_envelope(struct Envelope *e, const unsigned char *d, int *off, bool convert)
 {
   int real_subj_off;
 
@@ -505,20 +507,20 @@ static void restore_envelope(struct Envelope *e, const unsigned char *d, int *of
   else
     e->real_subj = NULL;
 
-  restore_char(&e->message_id, d, off, 0);
-  restore_char(&e->supersedes, d, off, 0);
-  restore_char(&e->date, d, off, 0);
+  restore_char(&e->message_id, d, off, false);
+  restore_char(&e->supersedes, d, off, false);
+  restore_char(&e->date, d, off, false);
   restore_char(&e->x_label, d, off, convert);
 
   restore_buffer(&e->spam, d, off, convert);
 
-  restore_stailq(&e->references, d, off, 0);
-  restore_stailq(&e->in_reply_to, d, off, 0);
+  restore_stailq(&e->references, d, off, false);
+  restore_stailq(&e->in_reply_to, d, off, false);
   restore_stailq(&e->userhdrs, d, off, convert);
 
 #ifdef USE_NNTP
-  restore_char(&e->xref, d, off, 0);
-  restore_char(&e->followup_to, d, off, 0);
+  restore_char(&e->xref, d, off, false);
+  restore_char(&e->followup_to, d, off, false);
   restore_char(&e->x_comment_to, d, off, convert);
 #endif
 }
@@ -647,7 +649,7 @@ static void *hcache_dump(header_cache_t *h, struct Header *header, int *off,
 {
   unsigned char *d = NULL;
   struct Header nh;
-  int convert = !Charset_is_utf8;
+  bool convert = !Charset_is_utf8;
 
   *off = 0;
   d = lazy_malloc(sizeof(union Validate));
@@ -704,7 +706,7 @@ struct Header *mutt_hcache_restore(const unsigned char *d)
 {
   int off = 0;
   struct Header *h = mutt_new_header();
-  int convert = !Charset_is_utf8;
+  bool convert = !Charset_is_utf8;
 
   /* skip validate */
   off += sizeof(union Validate);
diff --git a/mbyte.c b/mbyte.c
index f3ef3d7b2f436d4808253b55254ca1084db80e98..4f99cd4690b0ece24a77905ccee3db53dd3d9bd8 100644 (file)
--- a/mbyte.c
+++ b/mbyte.c
@@ -40,7 +40,7 @@
 #define EILSEQ EINVAL
 #endif
 
-int Charset_is_utf8 = 0;
+bool Charset_is_utf8 = false;
 
 void mutt_set_charset(char *charset)
 {
@@ -48,10 +48,10 @@ void mutt_set_charset(char *charset)
 
   mutt_canonical_charset(buffer, sizeof(buffer), charset);
 
-  Charset_is_utf8 = 0;
+  Charset_is_utf8 = false;
 
   if (mutt_is_utf8(buffer))
-    Charset_is_utf8 = 1;
+    Charset_is_utf8 = true;
 
 #if defined(HAVE_BIND_TEXTDOMAIN_CODESET) && defined(ENABLE_NLS)
   bind_textdomain_codeset(PACKAGE, buffer);
diff --git a/mbyte.h b/mbyte.h
index 12e45e3f1550b6ad6741679a0cefad787ff84971..4bc47fbd06fad7f0fc366d5aa4a50afd4f07cba3 100644 (file)
--- a/mbyte.h
+++ b/mbyte.h
@@ -26,7 +26,7 @@
 #include <wchar.h>
 
 void mutt_set_charset(char *charset);
-extern int Charset_is_utf8;
+extern bool Charset_is_utf8;
 wchar_t replacement_char(void);
 bool is_display_corrupting_utf8(wchar_t wc);
 int mutt_filter_unprintable(char **s);