> Comment (by kevin8t8):
> 
>  Thank you Vincent!  I'm attaching a patch as just discussed.  I have
>  tested it, along with sending using the SMTPUTF8 extension, and it seems
>  to be working as expected.
> 
>  chdiza, would you mind testing this patch just to make sure it takes care
>  of your warnings.

Whoops, trac is having some sort of problem.  I'm attaching the patch to
this email instead.

-Kevin
# HG changeset patch
# User Kevin McCarthy <ke...@8t8.us>
# Date 1448497703 28800
#      Wed Nov 25 16:28:23 2015 -0800
# Node ID d0e3d7977189e42721634562d12061b6d6589996
# Parent  94186a96ca17f4d348fd563e4b2ded3386180bad
Clean up address_uses_unicode() (closes #3794)

Pull the null check out of the loop.  Use a bit comparison to detect if
the high bit is set: this avoids a warning for platforms where char is
implicitly signed (where comparing < 128 is always true).

diff --git a/smtp.c b/smtp.c
--- a/smtp.c
+++ b/smtp.c
@@ -237,31 +237,38 @@
     return r;
 
   return 0;
 }
 
 
 /* Returns 1 if a contains at least one 8-bit character, 0 if none do.
  */
-static int
-address_uses_unicode(const char * a) {
-  while(a && *a > 0 && *a < 128)
+static int address_uses_unicode(const char *a)
+{
+  if (! a)
+    return 0;
+
+  while (*a)
+  {
+    if ((unsigned char) *a & (1<<7))
+      return 1;
     a++;
-  if(a && *a)
-    return 1;
+  }
+
   return 0;
 }
 
 
 /* Returns 1 if any address in a contains at least one 8-bit
  * character, 0 if none do.
  */
 static int
-addresses_use_unicode(const ADDRESS* a) {
+addresses_use_unicode(const ADDRESS* a)
+{
   while (a)
   {
     if(a->mailbox && !a->group && address_uses_unicode(a->mailbox))
       return 1;
     a = a->next;
   }
   return 0;
 }

Attachment: signature.asc
Description: PGP signature

Reply via email to