--- trunk/all2xml.pl 2003/07/13 22:29:14 98 +++ trunk/all2xml.pl 2003/10/29 22:46:49 136 @@ -160,13 +160,9 @@ } if ($filter) { no strict 'refs'; - $display_data .= join($delimiter,&$filter($display)); + $display_data .= $delimiter.&$filter($display); } else { - if ($display_data) { - $display_data .= $delimiter.$display; - } else { - $display_data .= $display; - } + $display_data .= $delimiter.$display; } } @@ -181,8 +177,8 @@ if (@index_data) { if ($index_filter) { no strict 'refs'; - foreach my $d (&$index_filter(@index_data)) { - $index->insert($field, $d, $path); + foreach my $d (@index_data) { + $index->insert($field, &$index_filter($d), $path); } } else { foreach my $d (@index_data) { @@ -294,7 +290,7 @@ # output current progress indicator my $last_p = 0; sub progress { - # XXX return if ($show_progress ne ""); + return if (! $show_progress); my $current = shift; my $total = shift || 1; my $p = int($current * 100 / $total); @@ -306,6 +302,7 @@ my $fake_dir = 1; sub fakeprogress { + return if (! $show_progress); my $current = shift @_; my @ind = ('-','\\','|','/','-','\\','|','/', '-'); @@ -327,8 +324,56 @@ $import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); my $db = OpenIsis::open( $isis_db ); + # check if .txt database for OpenIsis is zero length, + # if so, erase it and re-open database + sub check_txt_db { + my $isis_db = shift || die "need isis database name"; + my $reopen = 0; + + if (-e $isis_db.".TXT") { + print STDERR "WARNING: removing $isis_db.TXT OpenIsis database...\n"; + unlink $isis_db.".TXT" || warn "FATAL: unlink error on '$isis_db.TXT': $!"; + $reopen++; + } + if (-e $isis_db.".PTR") { + print STDERR "WARNING: removing $isis_db.PTR OpenIsis database...\n"; + unlink $isis_db.".PTR" || warn "FATAL: unlink error on '$isis_db.PTR': $!"; + $reopen++; + } + return OpenIsis::open( $isis_db ) if ($reopen); + } + + # EOF error + if ($db == -1) { + $db = check_txt_db($isis_db); + if ($db == -1) { + print STDERR "FATAL: OpenIsis can't open zero size file $isis_db\n"; + next; + } + } + + # OpenIsis::ERR_BADF + if ($db == -4) { + print STDERR "FATAL: OpenIsis can't find file $isis_db\n"; + next; + # OpenIsis::ERR_IO + } elsif ($db == -5) { + print STDERR "FATAL: OpenIsis can't access file $isis_db\n"; + next; + } elsif ($db < 0) { + print STDERR "FATAL: OpenIsis unknown error $db with file $isis_db\n"; + next; + } + my $max_rowid = OpenIsis::maxRowid( $db ); + # if 0 records, try to rease isis .txt database + if ($max_rowid == 0) { + # force removal of database + $db = check_txt_db($isis_db); + $max_rowid = OpenIsis::maxRowid( $db ); + } + print STDERR "Reading database: $isis_db [$max_rowid rows]\n"; my $path = $database; @@ -350,6 +395,10 @@ } } } + # for this to work with current version of OpenIsis (0.9.0) + # you might need my patch from + # http://www.rot13.org/~dpavlin/projects/openisis-0.9.0-perl_close.diff + OpenIsis::close($db); print STDERR "\n"; } elsif ($type_base eq "excel") {