Standardize missing S_define include error message

trick_print is not flexible enough for the kind of formatting I want to
do, so I added a new function, trick_formatted_print, that takes
alternating control sequences and strings to allow any kind of
formatting in the console. Like trick_print, it also prints to a file
with the control sequences removed.

Refs #436
This commit is contained in:
Derek Bankieris 2017-05-24 13:10:21 -05:00
parent 1dbeb3e2d4
commit 0bb5995397
2 changed files with 14 additions and 5 deletions

View File

@ -266,8 +266,7 @@ sub parse_s_define ($) {
}
}
if ( $found == 0 ) {
trick_print( $$sim_ref{fh}, "Warning S_define\n", "title_white", $$sim_ref{args}{v} );
trick_print( $$sim_ref{fh}, " Could not find dependency \"$object_file\"\n", "title_white", $$sim_ref{args}{v} );
trick_formatted_print($$sim_ref{fh}, "", "Warning ", "", "S_define\n", "", " Could not find dependency \"", "", "$object_file", "", "\"\n");
}
}
}
@ -849,7 +848,7 @@ sub handle_compiler_directive($$) {
($rel_file_name) = $1 ;
$file_name = find_header_file($rel_file_name , \@{$$sim_ref{inc_paths}}) ;
if ( $file_name eq "" ) {
trick_print($$sim_ref{fh}, "could not find $rel_file_name\n" , "title_red", $$sim_ref{args}{v});
trick_formatted_print($$sim_ref{fh}, "", "Error ", "", "Could not find included file \"", "", "$rel_file_name", "", "\"\n") ;
exit -1 ;
}
trick_print($$sim_ref{fh}," Found include: $file_name\n", "debug_white", $$sim_ref{args}{v}) ;

View File

@ -2,7 +2,7 @@ package trick_print ;
use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw(trick_print);
@EXPORT = qw(trick_print trick_formatted_print);
use strict ;
@ -42,7 +42,7 @@ sub trick_print($$$$) {
print $fh "$message" ;
}
}
# print the message to the screen
if ( $verbose >= $message_type{$mt}{level} ) {
$message =~ s/(\n)?$/$1/s ;
@ -50,4 +50,14 @@ sub trick_print($$$$) {
}
}
sub trick_formatted_print {
my ($file, @strings) = @_;
for (my $i = 0; $i < @strings; ++$i) {
print $strings[$i];
if ($i % 2) {
print $file $strings[$i];
}
}
}
1;