Skip to content

Commit

Permalink
fix #43 (path ending with semicolon)
Browse files Browse the repository at this point in the history
  • Loading branch information
fungs committed Apr 6, 2016
1 parent a805682 commit aa28b87
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions taxknife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,25 @@ int main( int argc, char** argv ) {
taxid = boost::lexical_cast< TaxonID >( *field_it );
node = interface.getNode( taxid );
cout << buffer.str();

const TaxonNode* root = interface.getRoot();
for ( Taxonomy::CPathDownIterator it( root, node ); it != node; ++it ) {
if ( allnodes || it->data->mark_special ) {
if( it->data->annotation ) cout << it->data->annotation->name << ';';
else cout << "node_without_annotation;";
Taxonomy::CPathDownIterator it( root, node );
while(true) {
if (allnodes || it->data->mark_special) {
if( it->data->annotation ) cout << it->data->annotation->name;
else cout << "node_without_annotation";
break;
}
if(it == node) break;
++it;
}
if ( allnodes || node->data->mark_special ) cout << node->data->annotation->name << ';';
if ( ! (++field_it)->empty() ) cout << default_field_separator << *field_it;
while ( it != node ) {
++it;
if ( allnodes || it->data->mark_special ) {
if( it->data->annotation ) cout << ';' << it->data->annotation->name;
else cout << ";node_without_annotation";
}
};
cout << endl;

} catch ( TaxonNotFound& ) {
Expand Down Expand Up @@ -341,12 +351,21 @@ int main( int argc, char** argv ) {
taxid = boost::lexical_cast< TaxonID >( *field_it );
node = interface.getNode( taxid );
cout << buffer.str();

const TaxonNode* root = interface.getRoot();
for ( Taxonomy::CPathDownIterator it( root, node ); it != node; ++it ) {
if ( allnodes || it->data->mark_special ) cout << it->data->taxid << ';';
Taxonomy::CPathDownIterator it( root, node );
while(true) {
if (allnodes || it->data->mark_special) {
cout << it->data->taxid;
break;
}
if(it == node) break;
++it;
}
if ( allnodes || node->data->mark_special ) cout << node->data->taxid << ';';
if ( ! (++field_it)->empty() ) cout << default_field_separator << *field_it;
while ( it != node ) {
++it;
if ( allnodes || it->data->mark_special ) cout << ';' << it->data->taxid;
};
cout << endl;

} catch ( TaxonNotFound& ) {
Expand Down

0 comments on commit aa28b87

Please sign in to comment.