Factoring

mako132 on 2002-10-29T20:12:51

Doing more work on the repeated code tools. My grand idea was a tool which took repeated code out of a script and put it into a library file.

I doubt I could get it completely automated. My goal is make a tool that helps build this library file. I would probably have to leave repeated code (for context sake) in the original file (commented out).

As a start, I wrote a separate script which took the output of my repeated-code detector and marked up the file with lines such as, >>> 435 ## Gets the starting time >>> 436 $decode_start_time = timelocal( 0, $minutes{$decode_start_minute} , $hours{$decode_start_hour} , $sys_day , $sys_months{$sys_month} , $sys_year); >>> 438 my $current_time = scalar(localtime( $time )); >>> 439 my $decode_sess_start_time = scalar(localtime( $decode_start_time )); >>> 440 my $decode_sess_end_time = $decode_start_time + $seconds{$seconds_decode} + ( $minutes{$minutes_decode} * 60 ) + ( $hours{$hours_decode} * 60 * 60); >>> 441 $decode_sess_end_time = scalar(localtime( $decode_sess_end_time ));

The numbers above are the line numbers of the first occurrence of the same code. For example ">>> 435" means this exact line (not counting whitespace) appeared earlier on line 435.