Changeset 22925 for src

Show
Ignore:
Timestamp:
11/08/08 10:49:11 (2 months ago)
Author:
azawawi
Message:

[STD_syntax_highlight] refactored error writing routine
[STD_syntax_highlight] catching CTRL-C is not needed with backticks

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/perl6/spec_highlight

    r22922 r22925  
    8686        $fail++; 
    8787     
    88         # catch those pesky CTRL-Cs 
    89         if($CHILD_ERROR &= 127) { 
    90             say "CTRL-C detected... bye bye"; 
    91             last; 
    92         } 
    93          
    9488        # let us write something useful into those htmls 
    9589        # when an error occurs 
    96         my $error_html = <<"ERROR"; 
    97 <html><title>Error</title><body><pre> 
     90        write_error_html($simple_html, $file, $log, 1); 
     91        write_error_html($snippet_html, $file, $log, 0); 
     92        write_error_html($full_html, $file, $log, 1); 
     93 
     94        say "error"; 
     95    } else { 
     96            $success++; 
     97            say "ok"; 
     98    } 
     99} 
     100 
     101# write the error log in the html file provied 
     102sub write_error_html { 
     103    my ($html_file, $file, $log, $is_full) = @ARG; 
     104 
     105    my $error_html = ""; 
     106    if($is_full) { 
     107        $error_html = "<html><title>Error</title><body>"; 
     108    } 
     109 
     110    $error_html .= <<"ERROR"; 
     111<pre> 
    98112 
    99113An error has occured while processing this file: 
     
    103117Reason: 
    104118    $log 
    105 </pre></body></html> 
     119</pre> 
    106120ERROR 
    107         open SIMPLE_HTML, ">$simple_html" 
    108             or die "Could not open $simple_html for writing: $OS_ERROR\n"; 
    109         print SIMPLE_HTML $error_html;        
    110         close SIMPLE_HTML; 
    111         open FULL_HTML, ">$full_html" 
    112             or die "Could not open $full_html for writing: $OS_ERROR\n"; 
    113         print FULL_HTML $error_html; 
    114         close FULL_HTML; 
    115         say "error"; 
    116     } else { 
    117             $success++; 
    118             say "ok"; 
     121 
     122    if($is_full) { 
     123        $error_html .= "<body></html>"; 
    119124    } 
     125 
     126    open FILE, ">$html_file" 
     127        or die "Could not open $html_file for writing: $OS_ERROR\n"; 
     128    print FILE $error_html;        
     129    close FILE; 
    120130} 
    121131