34 sub destructive_merge_mangle {
35 my($destination_ref, $source_ref, $comparison, $mangler) = @_;
49 my @inserted_indices = ();
50 my @source = @$source_ref;
51 my $src_head = shift @source;
52 my $current_splice_pos = 0;
53 my $dest_items_left = scalar(@$destination_ref);
54 my $next_dest = $$destination_ref[$current_splice_pos];
55 while($src_head && $dest_items_left) {
56 if(&$comparison($next_dest, $src_head) == 1) {
58 splice @$destination_ref, $current_splice_pos, 0, $src_head;
59 push @inserted_indices, $current_splice_pos;
60 &$mangler($destination_ref, $current_splice_pos, 1)
if $mangler;
61 $src_head = shift @source;
62 $current_splice_pos++;
64 &$mangler($destination_ref, $current_splice_pos, 0)
if $mangler;
65 $current_splice_pos++;
66 $next_dest = $$destination_ref[$current_splice_pos];
71 push @$destination_ref, $src_head, @source;
73 foreach $tail ($src_head, @source) {
74 &$mangler($destination_ref, $current_splice_pos, 1)
if $mangler;
75 push @inserted_indices, $current_splice_pos;
76 $current_splice_pos++;
80 while ($dest_items_left) {
81 &$mangler($destination_ref, $current_splice_pos, 0)
if $mangler;
82 $current_splice_pos++;
86 return \@inserted_indices;
89 sub destructive_remove_mangle {
90 my($destination_ref, $source_ref, $comparison, $mangler) = @_;
107 my @removed_indices = ();
108 my $old_position = 0;
109 my @source = @$source_ref;
110 my $src_head = shift @source;
111 my $current_splice_pos = 0;
112 my $dest_items_left = scalar(@$destination_ref);
113 my $next_dest = $$destination_ref[$current_splice_pos];
114 while($src_head && $dest_items_left) {
115 if(&$comparison($next_dest, $src_head)) {
117 splice @$destination_ref, $current_splice_pos, 1;
118 &$mangler(1, $destination_ref, $current_splice_pos, $src_head)
120 $src_head = shift @source;
121 push @removed_indices, $old_position;
123 &$mangler(0, $destination_ref, $current_splice_pos)
if $mangler;
124 $current_splice_pos++;
128 $next_dest = $$destination_ref[$current_splice_pos];
132 "Warning: source items left after destructive_remove_mangle\n";
134 if($mangler && $dest_items_left) {
135 while($dest_items_left) {
136 &$mangler(0, $destination_ref, $current_splice_pos);
137 $current_splice_pos++;
141 return \@removed_indices;
145 my($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime(time);
147 $month =
"0" . $month
if $month < 10;
148 $mday =
"0" . $mday
if $mday < 10;
149 $hour =
"0" . $hour
if $hour < 10;
150 $min =
"0" . $min
if $min < 10;
151 $sec =
"0" . $sec
if $sec < 10;
154 return(
"$year-$month-$mday-$hour-$min-$sec");
158 $CBB::version =
"Version <not_installed>";
159 ($CBB::junk, $CBB::version_num, $CBB::junk) = split(/ +/, $CBB::version);
164 return sprintf(
"%02d", $_[0]);
173 $pos = rindex($file,
"/");
175 return substr($file, 0, ($pos + 1));
187 $pos = rindex($file,
"/");
188 return substr($file, ($pos + 1));
197 $pos = rindex($file,
".");
198 return substr($file, 0, $pos);
207 $pos = rindex($file,
".");
208 return substr($file, ($pos + 1));
216 my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
222 return(sprintf(
"%04d", 1900 + $year) .
223 sprintf(
"%02d", $mon + 1) .
224 sprintf(
"%02d", $mday));
236 my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
238 return ¢ury() . &pad($year) . &pad($mon+1) . &pad($mday);
254 my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
259 if ( $idate =~ /^\d{8}$/ ) {
261 } elsif ($idate =~ /^-\d{1,2}m$/ ) {
263 $value = substr($idate, 1, 3);
264 if ($value >= $mon) {
265 $year = $year - 1 - int( ($value - $mon) / 12 );
266 $value = ($value % 12 );
268 $mon = $mon - $value;
270 $value = $value + 12;
272 $odate = ¢ury() . &pad($year) . &pad($mon) . &pad(1);
274 } elsif ($idate =~ /^-\d{1,3}d$/ ) {
276 $value = substr($idate, 1, 4);
277 if ($value >= $yday) {
278 $year = $year - 1 - int( ($value - $yday) / 360 );
279 $value = ( $value % 360 );
281 if ($value >= $mday) {
282 $mon = $mon - 1 - int( ($value - $mday) / 30 );
286 $value = ( $value % 30 );
288 $mday = $mday - $value;
292 $odate = ¢ury() . &pad($year) . &pad($mon) . &pad($mday);
294 } elsif ( $idate =~ /^\d{1,2}\/\d{1,2}\/\d{2,4}$/ ) {
296 ($mon, $mday, $year) = split(/\//, $idate);
300 $value = $year / 100;
302 $odate = &pad($value) . &pad($year) . &pad($mon) . &pad($mday);
304 } elsif ( $idate =~ /^\d{1,2}\.\d{1,2}\.\d{2,4}$/ ) {
306 ($mday, $mon, $year) = split(/\./, $idate);
310 $value = $year / 100;
312 $odate = &pad($value) . &pad($year) . &pad($mon) . &pad($mday);
324 my($unix_date, $year, $century, $junk);
326 $unix_date = localtime;
327 ($junk, $junk, $junk, $junk, $year) = split(/\s+/, $unix_date);
328 $century = substr($year, 0, 2);