Re: [PATCH] Clean up author display for some "Last, First" cases
authorDirk Hohndel <hohndel@infradead.org>
Sat, 24 Apr 2010 16:57:40 +0000 (09:57 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:52 +0000 (09:36 -0800)
4d/4f65657c6daf28f7c70a7de993e633284ea823 [new file with mode: 0644]

diff --git a/4d/4f65657c6daf28f7c70a7de993e633284ea823 b/4d/4f65657c6daf28f7c70a7de993e633284ea823
new file mode 100644 (file)
index 0000000..77780ba
--- /dev/null
@@ -0,0 +1,115 @@
+Return-Path: <BATV+28bf489b39c899822e75+2435+infradead.org+hohndel@bombadil.srs.infradead.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 051634196F3\r
+       for <notmuch@notmuchmail.org>; Sat, 24 Apr 2010 09:57:43 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -4.2\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id v-yGGIcrJ-7W for <notmuch@notmuchmail.org>;\r
+       Sat, 24 Apr 2010 09:57:41 -0700 (PDT)\r
+Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id BDCB2431FC1\r
+       for <notmuch@notmuchmail.org>; Sat, 24 Apr 2010 09:57:41 -0700 (PDT)\r
+Received: from localhost ([::1] helo=x200.gr8dns.org)\r
+       by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux))\r
+       id 1O5ifl-00051T-93; Sat, 24 Apr 2010 16:57:41 +0000\r
+Received: by x200.gr8dns.org (Postfix, from userid 500)\r
+       id 39E92CC593; Sat, 24 Apr 2010 09:57:40 -0700 (PDT)\r
+From: Dirk Hohndel <hohndel@infradead.org>\r
+To: Carl Worth <cworth@cworth.org>, notmuch <notmuch@notmuchmail.org>\r
+Subject: Re: [PATCH] Clean up author display for some "Last, First" cases\r
+In-Reply-To: <87mxwshnqp.fsf@yoom.home.cworth.org>\r
+References: <m3633kyt5k.fsf@x200.gr8dns.org>\r
+       <87mxwshnqp.fsf@yoom.home.cworth.org>\r
+User-Agent: Notmuch/0.2-187-g7c5f017 (http://notmuchmail.org) Emacs/23.1.1\r
+       (i386-redhat-linux-gnu)\r
+Date: Sat, 24 Apr 2010 09:57:40 -0700\r
+Message-ID: <m3bpd83i0r.fsf@x200.gr8dns.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-SRS-Rewrite: SMTP reverse-path rewritten from <hohndel@infradead.org> by\r
+       bombadil.infradead.org See http://www.infradead.org/rpr.html\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 24 Apr 2010 16:57:43 -0000\r
+\r
+On Sat, 24 Apr 2010 08:30:22 -0700, Carl Worth <cworth@cworth.org> wrote:\r
+> On Wed, 21 Apr 2010 22:04:39 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:\r
+> > +/* clean up the uggly "Lastname, Firstname" format that some mail systems\r
+> > + * (most notably, Exchange) are creating to be "Firstname Lastname" \r
+> > + * To make sure that we don't change other potential situations where a \r
+> > + * comma is in the name, we check that we match one of these patterns\r
+> > + * "Last, First" <first.last@company.com>\r
+> > + * "Last, First MI" <first.mi.last@company.com>\r
+> \r
+> This is an interesting idea. We could make it a little more flexible by\r
+> doing a regexp comparison of "first.*last" against the email address,\r
+> (perhaps people have email addresses like carl_worth@example.com?)\r
+\r
+I'll look into that. We actually had some discussion about this on IRC\r
+and I was thinking of taking this feature to a new level... something\r
+like: \r
+- by default we show names as they come in (least surprise)\r
+- we offer to reverse Last, First\r
+- we offer to shorten to FirstL\r
+- we offer an alias map\r
+So I could define that mail from "cworth@cworth.org" gets the author\r
+listed as "cworth". Or as CarlW.\r
+\r
+> > +    char *cleanauthor,*testauthor;\r
+> \r
+> I'd much rather see an underscore separating two words in a single\r
+> identifier, (so clean_author, test_author).\r
+\r
+Happy to comply to your preferences in the future\r
+\r
+> > +  /* let's assemble what we think is the correct name */\r
+> > +  lname = comma - author;\r
+> > +  fname = strlen(author) - lname - 2;\r
+> > +  strncpy(cleanauthor, comma + 2, fname);\r
+> > +  *(cleanauthor+fname) = ' ';\r
+> > +  strncpy(cleanauthor + fname + 1, author, lname);\r
+> > +  *(cleanauthor+fname+1+lname) = '\0';\r
+> \r
+> The comment above, ("what we think is the correct name"), didn't help me\r
+> understand what the code is doing. And the code is hard enough to follow\r
+> that I could really use some help. Something like:\r
+> \r
+> /* Break at comma and reverse: "Last, First etc." -> "First Last etc." */\r
+\r
+Ok, I'll try to be more explicit in documenting algorithms\r
+\r
+> Lots of little additions here and there so plenty of chance for an\r
+> off-by-one. Do we have a test case for this yet?\r
+\r
+Nope. Will do.\r
+\r
+> > +  /* make a temporary copy and see if it matches the email */\r
+> > +  testauthor = xstrdup(cleanauthor);\r
+> \r
+> It would be preferable to use talloc functions consistently. (Existing\r
+> occurrences of xstrdup in the code base are for the sake of\r
+> talloc-unfriendly glib data structures like GHashTable.)\r
+> \r
+> As is, testauthor is leaking.\r
+\r
+Oops.\r
+\r
+/D\r