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