# if we produced an interface file "no matter what",
# print what we got on stderr (ToDo: honor -ohi flag)
if ( $HiOnStdout ) {
- system("$Cat $new_hi 1>&2") if $Verbose;
+ system("$Cat $new_hi 1>&2"); # if $Verbose;
} else {
&run_something("$Cmp -s $hifile_target $new_hi || ( $Rm $hifile_target && $Cp $new_hi $hifile_target )",
"Replace .$HiSuffix file, if changed");
next if /\{-# GHC_PRAGMA INTERFACE VERSION 20 #-\}/;
# avoid pre-1.3 interfaces
-#print STDERR "now_in:$now_in:$_";
+ #print STDERR "now_in:$now_in:$_";
if ( /\{-# GHC_PRAGMA INTERFACE VERSION . #-\}/ ) {
$HiExists{$mod} = 0;
last hi_line;
} elsif ( /^_([a-z_]+)_$/ ) {
$now_in = $1;
- } elsif ( $now_in eq 'usages' && /^(\S+)\s+(\d+)\s+:: (.*)/ ) {
+ } elsif ( $now_in eq 'usages' && /^(\S+)\s+(!\s+)?(\d+)\s+::(.*)/ ) {
$Stuff{"$mod:usages"} .= $_; # save the whole thing
} elsif ( $now_in =~ /^(exports|instance_modules|instances|fixities)$/ ) {
$Stuff{"$mod:$1"} .= $_; # just save it up
+ } elsif ( /^--.*/ ) { # silently ignore comment lines.
+ ;
} elsif ( $now_in eq 'declarations' ) { # relatively special treatment needed...
# We're in a declaration
$_ = $2;
}
- if ( /^(\S+)\s+::\s+/ ) {
+ if ( /^(\S+)\s+_:_\s+/ ) {
$current_name = $1;
$Decl{"$mod:$current_name"} = $_;
if ($mod eq "old") { $OldVersion{$current_name} = $version; }
$Decl{"$mod:$current_name"} = $_;
if ($mod eq "old") { $OldVersion{$current_name} = $version; }
- } elsif ( /class\s+(.*\s+=>\s+)?(\S+)\s+.*where\s+\{.*\};/ ) {
+ } elsif ( /^class\s+(\{[^{}]*\}\s+=>\s+)?(\S+)\s+/ ) {
# must be wary of => bit matching after "where"...
- $current_name = $2;
- $Decl{"$mod:$current_name"} = $_;
- if ($mod eq "old") { $OldVersion{$current_name} = $version; }
-
- } elsif ( /class\s+(.*\s+=>\s+)?(\S+)\s+/ ) {
+ # ..hence the [^{}] part
+ # NB: a class decl may not have a where part at all
$current_name = $2;
$Decl{"$mod:$current_name"} = $_;
if ($mod eq "old") { $OldVersion{$current_name} = $version; }
sub printNewItemVersion {
local($hifile, $item, $mod_version, $show_hi_diffs) = @_;
local($idecl) = $Decl{"new:$item"};
+
if (! defined($Decl{"old:$item"})) { # Old decl doesn't exist
if ($show_hi_diffs) {print STDERR "new: $item\n";}
print $hifile "$mod_version "; # Use module version
- } elsif ($idecl ne $Decl{"old:$item"}) { # Old decl differs from new decl
- local($odecl) = $Decl{"old:$item"};
- if ($show_hi_diffs) {print STDERR "changed: $item\nOld: $odecl\nNew: $idecl\n";}
- print $hifile "$mod_version "; # Use module version
-
} elsif (! defined($OldVersion{"$item"}) ) {
if ($show_hi_diffs) {print STDERR "$item: no old version?!\n";}
print $hifile "$mod_version "; # Use module version
+ } elsif ($idecl ne $Decl{"old:$item"}) { # Old decl differs from new decl
+ local($odecl) = $Decl{"old:$item"};
+ if ($show_hi_diffs) {print STDERR "changed: $item\nOld: $odecl", "New: $idecl";}
+ print $hifile "--old: ", $OldVersion{"$item"}, " $odecl"
+ if $Keep_HiDiffs; # show old in interface file
+ print $hifile "$mod_version "; # Use module version
+
} else { # Identical decls, so use old version number
- if ($show_hi_diffs) {print STDERR "$item: unchanged\n";}
+ #if ($show_hi_diffs) {print STDERR "$item: unchanged\n";}
print $hifile $OldVersion{"$item"}, " ";
}
return;