2 // binary-source-file.cc
5 #include <limits.h> // INT_MAX
12 #include "sourcefile.hh"
13 #include "binary-source-file.hh"
15 Binary_source_file::Binary_source_file( String& filename_str )
16 : Source_file( filename_str )
20 Binary_source_file::~Binary_source_file()
25 Binary_source_file::error_str( char const* pos_ch_c_l )
28 if ( !in_b( pos_ch_c_l ) )
31 char const* begin_ch_c_l = pos_ch_c_l - 8 >? ch_c_l();
32 char const* end_ch_c_l = pos_ch_c_l + 7 <? ch_c_l() + length_off();
34 String pre_str( (Byte const*)begin_ch_c_l, pos_ch_c_l - begin_ch_c_l );
35 pre_str = StringConversion::bin2hex_str( pre_str );
36 for ( int i = 2; i < pre_str.length_i(); i += 3 )
37 pre_str = pre_str.left( i ) + " " + pre_str.mid( i + 1, INT_MAX );
38 String post_str( (Byte const*)pos_ch_c_l, end_ch_c_l - pos_ch_c_l );
39 post_str = StringConversion::bin2hex_str( post_str );
40 for ( int i = 2; i < post_str.length_i(); i += 3 )
41 post_str = post_str.left( i ) + " " + post_str.mid( i + 1, INT_MAX );
45 + String( ' ', pre_str.length_i() + 1 )
51 Binary_source_file::line_i( char const* pos_ch_c_l )
53 if ( !in_b( pos_ch_c_l ) )
56 return pos_ch_c_l - ch_c_l();