Re: [PATCH] send-email: extract email-parsing code into a subroutine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2017-12-11 22:12 GMT+01:00 Matthieu Moy <matthieu.moy@xxxxxxxxxxxxx>:

> "PAYRE NATHAN p1508475" <nathan.payre@xxxxxxxxxxxxxxxxx> wrote:
>> +     my %parsed_email;
>> +     $parsed_email{'body'} = '';
>> +     while (my $line = <$c>) {
>> +             next if $line =~ m/^GIT:/;
>> +             parse_header_line($line, \%parsed_email);
>> +             if ($line =~ /^$/) {
>> +                     $parsed_email{'body'} = filter_body($c);
>>               }
>> -             print $c2 $_;
>
> I didn't notice this at first, but you're modifying the behavior here:
> the old code used to print to $c2 anything that didn't match any of
> the if/else if branches.
>
> To keep this behavior, you need to keep all these extra headers in
> $parsed_email (you do, in this version) and print them after taking
> care of all the known headers (AFAICT, you don't).

This case is not that easy to correct because:
- It's could weigh the code.
- The refactoring may not be legitimate anymore.

I've found two way to resolve this:
.1) After every if($parsed_email{'key'}) remove the corresponding key
and just before closing $c2 create a new loop which add all the
remaining parts.

.2) Making a mix between the old and new code. Some parts of
my patch can improve the old code (like the removing of
$need_8bit_cte) then it will be kept and the while loop will be
similar the old code

I think that the first version will look like better than the second
one, easy to read, but it will change the order of the email header.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux