git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] send-email: Fix Pine address book parsing

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 26, 2008, 04:58 UTC
Message-ID
<7vod03hyna.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1227668100-5563-1-git-send-email-tpiepho@freescale.com>
Trent Piepho <tpiepho@freescale.com> writes:
Show 9 quoted lines
> See:  http://www.washington.edu/pine/tech-notes/low-level.html
>
> Entries with a fcc or comment field after the address weren't parsed
> correctly.
>
> Continuation lines, identified by leading spaces, were also not handled.
>
> Distribution lists which had ( ) around a list of addresses did not have
> the parenthesis removed.
Show 5 quoted lines
> +	pine => sub { my $fh = shift; my $f='\t[^\t]*';
> +	        for (my $x = ''; defined($x); $x = $_) {
> +			chomp $x;
> +		        $x .= $1 while(defined($_ = <$fh>) && /^ +(.*)$/);
> +			$x =~ /^(\S+)$f\t\(?([^\t]+?)\)?(:?$f){0,2}$/ or next;

Hmm, so you chomp each continuation line with /^ +(.*)$/ and concatenate that to the hold buffer ($x) as long as you see continuation lines, a non-continuation line that you read ahead is given to the next round (the third part of for(;;) control), checked if you hit an EOF and then chomped. Which means the complicated regexp about the parentheses is applied to a logical single line in $x that does not have any newline in it, right?

I wonder what this does:
	$x .= $1 while (defined($_ = <$fh>) && /^ +(.*)$/);

when you have "a b" in $x and feed " c\n d\ne\n" to it. When it leaves the loop, you would have "e\n" in $_ for the next round, and "a bcd" (note that "bcd" becomes one word) in $x, which I suspect may not be what you want.

But I do not use Pine nor its aliases file.
Previous: Trent PiephoNext: Trent Piepho
Message 2 of 6 in “send-email: Fix Pine address book parsing”
  1. send-email: Fix Pine address book parsingTrent Piepho, Nov 26, 2008
  2. Junio C HamanoNov 26, 2008
  3. Trent PiephoNov 26, 2008
  4. Junio C HamanoNov 26, 2008
  5. Trent PiephoNov 26, 2008
  6. Junio C HamanoNov 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.