(Sorry for the late reply ---- I had to finish some other work before continuing on this issue.)

I have implemented a bug fix and would appreciate your advice on how to include it correctly into the official version. The new Inline.pm file can be downloaded here: http://yaakovnet.net/Inline-0.45.pm

Here is a discussion of the changes:

1) I guess I have to increment the version number from 0.44 to 0.45:

$Inline::VERSION = '0.45';
2) I removed the old checksum computation:

   require Digest::MD5;
   $o->{INLINE}{md5} = Digest::MD5::md5_hex($o->{API}{code});

3) I replaced it with a call to a new computation:

   $o->{INLINE}{md5} = $o->md5_checksum;

4) Here is the new md5_checksum method:

#==============================================================================
# compute the md5 checksum
#==============================================================================
sub md5_checksum {
   my $o=shift; my $config=$o->{CONFIG};
   require Digest::MD5;
   my $md5=Digest::MD5->new;
   for my $key (sort keys %$config) {   # include all config options
       next if $key eq "FORCE_BUILD";   # ... but skip FORCE_BUILD
       my $value=$config->{$key};
       if(ref($value) eq "ARRAY") {     # some values are arrays
           $md5->add("*$key: [EMAIL PROTECTED]");
       }
       elsif(ref($value)) {             # this should not happen
           $md5->add("*$key: ??\0");    #    this is not perfect but works
       }
       else {                           # most values are strings
           $md5->add("*$key=$value\0");
       }
   }
   $md5->add("code: ".$o->{API}{code}); # include the source code
   return $md5->hexdigest;
};


Some comments:

* I include all options from $o->{CONFIG} except FORCE_BUILD.
* Most options are strings: they are included directly in the checksum.
* Some options are arrays: they are expanded.
* If an option has another reference type, the option name is included,
  but the value is ignored.
* If an option has the value undef, a warning will appear with -w.

Somebody who knows all the configuration options of Inline might comment
on whether this is "the right thing":

* Maybe some config options are in different places.
* Maybe some optional config options are stored as hash tables.
* Maybe some config options should be excluded from the checksum.

In any of the cases, I will be happy to adjust the code accordingly.

Best regards,

Yaakov Belch

# from Eric Wilhelm
# on 01/03/2007 07:26 PM
I think you're correct that all (well, mostly all) of the config options should be checksummed somehow. Is the .inl file ever checksummed? If so, just adding LIBS there would do the trick. If not, I would be inclined to simply serialize most the config into the MD5 call.

The one exception might be FORCE_BUILD (and maybe a few others.) Adding FORCE_BUILD to the config should force a build anyway, but removing it should not.

--Eric

Reply via email to