Menu

NBIB support when Bibutils is used as a library for hs-bibutils/pandoc-citeproc

2017-10-08
2017-10-15
  • Václav Haisman

    Václav Haisman - 2017-10-08

    I have patched imported source of Bibutils 6.2 so that I could enable NBIB support in pandoc-citeproc. Only the bibutils.c patch is essential but the rest helped during debugging.

    diff --git a/bibutils/bibcore.c b/bibutils/bibcore.c
    index 35bac74..b644bd5 100644
    --- a/bibutils/bibcore.c
    +++ b/bibutils/bibcore.c
    @@ -43,6 +43,7 @@ report_params( FILE *fp, const char *f, param *p )
                    case BIBL_BIBLATEXIN:   fprintf( fp, " (BIBL_BIBLATEXIN)\n" );   break;
                    case BIBL_EBIIN:        fprintf( fp, " (BIBL_EBIIN)\n" );        break;
                    case BIBL_WORDIN:       fprintf( fp, " (BIBL_WORDIN)\n" );       break;
    +               case BIBL_NBIBIN:       fprintf( fp, " (BIBL_NBIBIN)\n" );       break;
                    default:                fprintf( fp, " (Illegal)\n" );           break;
            }
            fprintf( fp, "\tcharsetin=%d\n", p->charsetin );
    @@ -274,7 +275,7 @@ bibl_reporterr( int err )
                    case BIBL_ERR_CANTOPEN:
                            fprintf( stderr, "Can't open." ); break;
                    default:
    -                       fprintf( stderr, "Cannot identify error code."); break;
    +                       fprintf( stderr, "Cannot identify error code: %d", err); break;
            }
            fprintf( stderr, "\n" );
     }
    @@ -837,6 +838,11 @@ bibl_read( bibl *b, FILE *fp, char *filename, param *p )
            if ( !fp ) return BIBL_ERR_BADINPUT;
            if ( !p )  return BIBL_ERR_BADINPUT;
    
    +       if ( debug_set( p ) ) {
    +               fflush( stdout );
    +               report_params( stderr, "bibl_read", p );
    +       }
    +
            if ( bibl_illegalinmode( p->readformat ) ) return BIBL_ERR_BADINPUT;
    
            status = bibl_setreadparams( &lp, p );
    diff --git a/bibutils/bibutils.c b/bibutils/bibutils.c
    index d40abda..3f218a2 100644
    --- a/bibutils/bibutils.c
    +++ b/bibutils/bibutils.c
    @@ -26,6 +26,7 @@ bibl_initparams( param *p, int readmode, int writemode, char *progname )
            case BIBL_MODSIN:       modsin_initparams( p, progname ); break;
            case BIBL_RISIN:        risin_initparams( p, progname ); break;
            case BIBL_WORDIN:       wordin_initparams( p, progname ); break;
    +       case BIBL_NBIBIN:       nbibin_initparams( p, progname ); break;
            default: /* internal error */;
            }
    
     
  • Chris Putnam

    Chris Putnam - 2017-10-14

    Thanks for catching these.

    I have one important question, though. While I've added reporting the unknown error code in bibl_reporterr(), I don't think that that function should ever see an unknown error code.

    Do you remember what value for the unknown error code made its way into bibl_reporterr()? I'm worried that something internal leaked its way out to the general user.

    Thanks again.

     
    • Václav Haisman

      Václav Haisman - 2017-10-15

      I have not actually seen an unknown error being reported from that statement. I have just seen the line and it ocurred to me it should probably print the unknown error number.

       

Log in to post a comment.