<<< Date Index >>>     <<< Thread Index >>>

Re: mutt Bug #2802 - stupid usage of strcat (fwd)



On 2007-03-12 10:05:40 -0700, Brendan Cully wrote:

> These patches look sane to me. I've applied them.

Mostly... Some comments below.


> > +  if (!ascii_strcasecmp (name, "utf-8")) {
> > +    strfcpy (dest, name, dlen);
> > +    goto found_utf8;
> > +  }
> > +
> >    /* catch some common iso-8859-something misspellings */
> >    if (!ascii_strncasecmp (name, "8859", 4) && name[4] != '-')
> >      snprintf (scratch, sizeof (scratch), "iso-8859-%s", name +4);
> > @@ -267,6 +272,7 @@ void mutt_canonical_charset (char *dest,
> >  
> >    strfcpy (dest, scratch, dlen);
> >  
> > +found_utf8:
> >    /* for cosmetics' sake, transform to lowercase. */
> >    for (p = dest; *p; p++)
> >      *p = ascii_tolower (*p);

The "goto found_utf8" strikes me as, well, nasty.  Why not just
strfcpy "utf-8" (in the right case), and return?

The rest makes sense.
-- 
Thomas Roessler   <roessler@xxxxxxxxxxxxxxxxxx>




% hg export 4974:00af582e34a5
# HG changeset patch
# User Thomas Roessler <roessler@xxxxxxxxxxxxxxxxxx>
# Date 1173721667 -3600
# Node ID 00af582e34a5418ecbe57eec3386a810d6fd73e5
# Parent  83ca0fb6e36a681d23d403bcadfa23773b89c8de
Cleanup performance enhancing patch.

diff -r 83ca0fb6e36a -r 00af582e34a5 ChangeLog
--- a/ChangeLog Mon Mar 12 10:32:35 2007 -0700
+++ b/ChangeLog Mon Mar 12 18:47:47 2007 +0100
@@ -1,3 +1,12 @@ 2007-03-12 10:03 -0700  Sami Farin  <saf
+2007-03-12 10:32 -0700  Brendan Cully  <brendan@xxxxxxxxxx>  (83ca0fb6e36a)
+
+       * imap/util.c: Substitute INBOX for empty mailbox _after_ cleanup
+       (closes: #2841)
+
+2007-03-12 10:32 -0700  Brendan Cully  <brendan@xxxxxxxxxx>  (69e7d6143bd2)
+
+       * ChangeLog: More changelog cleanup
+
 2007-03-12 10:03 -0700  Sami Farin  <safari-mutt@xxxxxxxxxxxxx>  (42016ef5ee21)
 
        * ChangeLog, charset.c, copy.c, rfc822.c, rfc822.h: Improve strcat
diff -r 83ca0fb6e36a -r 00af582e34a5 charset.c
--- a/charset.c Mon Mar 12 10:32:35 2007 -0700
+++ b/charset.c Mon Mar 12 18:47:47 2007 +0100
@@ -245,9 +245,10 @@ void mutt_canonical_charset (char *dest,
   char *p;
   char scratch[LONG_STRING];
 
-  if (!ascii_strcasecmp (name, "utf-8")) {
-    strfcpy (dest, name, dlen);
-    goto found_utf8;
+  if (!ascii_strcasecmp (name, "utf-8")) 
+  {
+    strfcpy (dest, "utf-8", dlen);
+    return;
   }
 
   /* catch some common iso-8859-something misspellings */
@@ -272,7 +273,6 @@ void mutt_canonical_charset (char *dest,
 
   strfcpy (dest, scratch, dlen);
 
-found_utf8:
   /* for cosmetics' sake, transform to lowercase. */
   for (p = dest; *p; p++)
     *p = ascii_tolower (*p);