Skip to content

Commit

Permalink
Remove stderr logging from bibutils
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Dec 4, 2019
1 parent ac72b5b commit 331aef2
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 89 deletions.
100 changes: 50 additions & 50 deletions crates/bibutils_sys/src/bibcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,20 @@ bibl_addtocorps( param *p, char *d )
void
bibl_reporterr( int err )
{
fprintf( stderr, "Bibutils: " );
switch( err ) {
case BIBL_OK:
fprintf( stderr, "No error." ); break;
case BIBL_ERR_BADINPUT:
fprintf( stderr, "Bad input." ); break;
case BIBL_ERR_MEMERR:
fprintf( stderr, "Memory error." ); break;
case BIBL_ERR_CANTOPEN:
fprintf( stderr, "Can't open." ); break;
default:
fprintf( stderr, "Cannot identify error code %d.", err ); break;
}
fprintf( stderr, "\n" );
// fprintf( stderr, "Bibutils: " );
// switch( err ) {
// case BIBL_OK:
// fprintf( stderr, "No error." ); break;
// case BIBL_ERR_BADINPUT:
// fprintf( stderr, "Bad input." ); break;
// case BIBL_ERR_MEMERR:
// fprintf( stderr, "Memory error." ); break;
// case BIBL_ERR_CANTOPEN:
// fprintf( stderr, "Can't open." ); break;
// default:
// fprintf( stderr, "Cannot identify error code %d.", err ); break;
// }
// fprintf( stderr, "\n" );
}

static int
Expand All @@ -298,17 +298,17 @@ bibl_illegaloutmode( int mode )
static void
bibl_verbose2( fields *f, char *filename, long nrefs )
{
int i, n;
n = fields_num( f );
fprintf( stderr, "======== %s %ld : converted\n", filename, nrefs );
for ( i=0; i<n; ++i ) {
fprintf( stderr, "'%s'='%s' level=%d\n",
(char*) fields_tag( f, i, FIELDS_CHRP_NOUSE ),
(char*) fields_value( f, i, FIELDS_CHRP_NOUSE ),
fields_level( f, i ) );
}
fprintf( stderr, "\n" );
fflush( stderr );
// int i, n;
// n = fields_num( f );
// fprintf( stderr, "======== %s %ld : converted\n", filename, nrefs );
// for ( i=0; i<n; ++i ) {
// fprintf( stderr, "'%s'='%s' level=%d\n",
// (char*) fields_tag( f, i, FIELDS_CHRP_NOUSE ),
// (char*) fields_value( f, i, FIELDS_CHRP_NOUSE ),
// fields_level( f, i ) );
// }
// fprintf( stderr, "\n" );
// fflush( stderr );
}

#if 0
Expand Down Expand Up @@ -818,10 +818,10 @@ convert_ref( bibl *bin, char *fname, bibl *bout, param *p )
}
if ( debug_set( p ) ) {
fflush( stdout );
fprintf( stderr, "-------------------start for convert_ref\n");
// fprintf( stderr, "-------------------start for convert_ref\n");
bibl_verbose0( bout );
fprintf( stderr, "-------------------end for convert_ref\n" );
fflush( stderr );
// fprintf( stderr, "-------------------end for convert_ref\n" );
// fflush( stderr );
}
status = uniqueify_citekeys( bout );
return status;
Expand Down Expand Up @@ -870,45 +870,45 @@ bibl_read( bibl *b, FILE *fp, char *filename, param *p )
if ( debug_set( p ) ) {
fflush( stdout );
report_params( stderr, "bibl_read", &lp );
fprintf( stderr, "-------------------raw_input start for bibl_read\n");
// fprintf( stderr, "-------------------raw_input start for bibl_read\n");
bibl_verbose0( &bin );
fprintf( stderr, "-------------------raw_input end for bibl_read\n" );
fflush( stderr );
// fprintf( stderr, "-------------------raw_input end for bibl_read\n" );
// fflush( stderr );
}

if ( !lp.output_raw || ( lp.output_raw & BIBL_RAW_WITHCHARCONVERT ) ) {
status = bibl_fixcharsets( &bin, &lp );
if ( status!=BIBL_OK ) return status;
if ( debug_set( p ) ) {
fprintf( stderr, "-------------------post_fixcharsets start for bibl_read\n");
// fprintf( stderr, "-------------------post_fixcharsets start for bibl_read\n");
bibl_verbose0( &bin );
fprintf( stderr, "-------------------post_fixcharsets end for bibl_read\n" );
fflush( stderr );
// fprintf( stderr, "-------------------post_fixcharsets end for bibl_read\n" );
// fflush( stderr );
}
}
if ( !lp.output_raw ) {
status = clean_ref( &bin, &lp );
if ( status!=BIBL_OK ) return status;
if ( debug_set( p ) ) {
fprintf( stderr, "-------------------post_clean_ref start for bibl_read\n");
// fprintf( stderr, "-------------------post_clean_ref start for bibl_read\n");
bibl_verbose0( &bin );
fprintf( stderr, "-------------------post_clean_ref end for bibl_read\n" );
fflush( stderr );
// fprintf( stderr, "-------------------post_clean_ref end for bibl_read\n" );
// fflush( stderr );
}
ok = convert_ref( &bin, filename, b, &lp );
if ( ok!=BIBL_OK ) return ok;
if ( debug_set( p ) ) {
fprintf( stderr, "-------------------post_convert_ref start for bibl_read\n");
// fprintf( stderr, "-------------------post_convert_ref start for bibl_read\n");
bibl_verbose0( &bin );
fprintf( stderr, "-------------------post_convert_ref end for bibl_read\n" );
fflush( stderr );
// fprintf( stderr, "-------------------post_convert_ref end for bibl_read\n" );
// fflush( stderr );
}
} else {
if ( debug_set( p ) ) {
fprintf( stderr, "-------------------here1 start for bibl_read\n");
// fprintf( stderr, "-------------------here1 start for bibl_read\n");
bibl_verbose0( &bin );
fprintf( stderr, "-------------------here1 end for bibl_read\n" );
fflush( stderr );
// fprintf( stderr, "-------------------here1 end for bibl_read\n" );
// fflush( stderr );
}
ok = bibl_copy( b, &bin );
if ( !ok ) {
Expand Down Expand Up @@ -1006,7 +1006,7 @@ bibl_writefp( FILE *fp, bibl *b, param *p )
fields_init( &out );

if ( debug_set( p ) && p->assemblef ) {
fprintf( stderr, "-------------------assemblef start for bibl_write\n");
// fprintf( stderr, "-------------------assemblef start for bibl_write\n");
}

if ( p->headerf ) p->headerf( fp, p );
Expand Down Expand Up @@ -1054,20 +1054,20 @@ bibl_write( bibl *b, FILE *fp, param *p )
}

if ( debug_set( p ) ) {
fprintf( stderr, "-------------------raw input start for bibl_write\n");
// fprintf( stderr, "-------------------raw input start for bibl_write\n");
bibl_verbose0( b );
fprintf( stderr, "-------------------raw input end for bibl_write\n" );
fflush( stderr );
// fprintf( stderr, "-------------------raw input end for bibl_write\n" );
// fflush( stderr );
}

status = bibl_fixcharsets( b, &lp );
if ( status!=BIBL_OK ) goto out;

if ( debug_set( p ) ) {
fprintf( stderr, "-------------------post-fixcharsets start for bibl_write\n");
// fprintf( stderr, "-------------------post-fixcharsets start for bibl_write\n");
bibl_verbose0( b );
fprintf( stderr, "-------------------post-fixcharsets end for bibl_write\n" );
fflush( stderr );
// fprintf( stderr, "-------------------post-fixcharsets end for bibl_write\n" );
// fflush( stderr );
}

if ( p->singlerefperfile ) status = bibl_writeeachfp( fp, b, &lp );
Expand Down
4 changes: 2 additions & 2 deletions crates/bibutils_sys/src/bibl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bibl_malloc( bibl * b )
b->maxrefs = alloc;
return 1;
} else {
fprintf( stderr, "%s: allocation error\n", __FUNCTION__ );
// fprintf( stderr, "%s: allocation error\n", __FUNCTION__ );
return 0;
}
}
Expand All @@ -43,7 +43,7 @@ bibl_realloc( bibl * b )
b->maxrefs = alloc;
return 1;
} else {
fprintf( stderr, "%s: allocation error\n", __FUNCTION__ );
// fprintf( stderr, "%s: allocation error\n", __FUNCTION__ );
return 0;
}
}
Expand Down
36 changes: 18 additions & 18 deletions crates/bibutils_sys/src/biblatexin.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ biblatex_data( const char *p, fields *bibin, slist *tokens, long nref, param *pm
}
out:
if ( nbracket!=0 ) {
fprintf( stderr, "%s: Mismatch in number of brackets in reference %ld\n", pm->progname, nref );
// fprintf( stderr, "%s: Mismatch in number of brackets in reference %ld\n", pm->progname, nref );
}
if ( nquotes!=0 ) {
fprintf( stderr, "%s: Mismatch in number of quotes in reference %ld\n", pm->progname, nref );
// fprintf( stderr, "%s: Mismatch in number of quotes in reference %ld\n", pm->progname, nref );
}
if ( str_has_value( &tok ) ) {
status = slist_add( tokens, &tok );
Expand Down Expand Up @@ -285,9 +285,9 @@ replace_strings( slist *tokens, fields *bibin, long nref, param *pm )
q++;
}
if ( !ok ) {
fprintf( stderr, "%s: Warning: Non-numeric "
"BibTeX elements should be in quotations or "
"curly brackets in reference %ld\n", pm->progname, nref );
// fprintf( stderr, "%s: Warning: Non-numeric "
// "BibTeX elements should be in quotations or "
// "curly brackets in reference %ld\n", pm->progname, nref );
}
}
}
Expand All @@ -305,20 +305,20 @@ string_concatenate( slist *tokens, fields *bibin, long nref, param *pm )
s = slist_str( tokens, i );
if ( !strcmp( str_cstr( s ), "#" ) ) {
if ( i==0 || i==tokens->n-1 ) {
fprintf( stderr, "%s: Warning: Stray string concatenation "
"('#' character) in reference %ld\n", pm->progname, nref );
// fprintf( stderr, "%s: Warning: Stray string concatenation "
// "('#' character) in reference %ld\n", pm->progname, nref );
status = slist_remove( tokens, i );
if ( status!=SLIST_OK ) return BIBL_ERR_MEMERR;
continue;
}
s = slist_str( tokens, i-1 );
if ( s->data[0]!='\"' && s->data[s->len-1]!='\"' )
fprintf( stderr, "%s: Warning: String concentation should "
"be used in context of quotations marks in reference %ld\n", pm->progname, nref );
// fprintf( stderr, "%s: Warning: String concentation should "
// "be used in context of quotations marks in reference %ld\n", pm->progname, nref );
t = slist_str( tokens, i+1 );
if ( t->data[0]!='\"' && t->data[t->len-1]!='\"' )
fprintf( stderr, "%s: Warning: String concentation should "
"be used in context of quotations marks in reference %ld\n", pm->progname, nref );
// fprintf( stderr, "%s: Warning: String concentation should "
// "be used in context of quotations marks in reference %ld\n", pm->progname, nref );
if ( ( s->data[s->len-1]=='\"' && t->data[0]=='\"') || (s->data[s->len-1]=='}' && t->data[0]=='{') ) {
str_trimend( s, 1 );
str_trimbegin( t, 1 );
Expand Down Expand Up @@ -712,11 +712,11 @@ static void
biblatexin_nocrossref( bibl *bin, long i, int n, param *p )
{
int n1 = fields_find( bin->ref[i], "REFNUM", LEVEL_ANY );
if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, "Cannot find cross-reference '%s'", bin->ref[i]->data[n].data);
if ( n1!=FIELDS_NOTFOUND )
fprintf( stderr, " for reference '%s'", bin->ref[i]->data[n1].data );
fprintf( stderr, "\n" );
// if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
// fprintf( stderr, "Cannot find cross-reference '%s'", bin->ref[i]->data[n].data);
// if ( n1!=FIELDS_NOTFOUND )
// fprintf( stderr, " for reference '%s'", bin->ref[i]->data[n1].data );
// fprintf( stderr, "\n" );
}

static int
Expand Down Expand Up @@ -1251,8 +1251,8 @@ static void
biblatexin_notag( param *p, char *tag )
{
if ( p->verbose && strcmp( tag, "INTERNAL_TYPE" ) ) {
if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, " Cannot find tag '%s'\n", tag );
// if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
// fprintf( stderr, " Cannot find tag '%s'\n", tag );
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/bibutils_sys/src/reftypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ get_reftype( const char *p, long refnum, char *progname, variants *all, int nall
*is_default = 1;

if ( chattiness==REFTYPE_CHATTY ) {
if ( progname ) fprintf( stderr, "%s: ", progname );
fprintf( stderr, "Did not recognize type '%s' of refnum %ld (%s).\n"
"\tDefaulting to %s.\n", p, refnum, tag, all[0].type );
// if ( progname ) fprintf( stderr, "%s: ", progname );
// fprintf( stderr, "Did not recognize type '%s' of refnum %ld (%s).\n"
// "\tDefaulting to %s.\n", p, refnum, tag, all[0].type );
}

return 0;
Expand Down
28 changes: 14 additions & 14 deletions crates/bibutils_sys/src/risout.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,19 @@ write_type( FILE *fp, int type )
static void
verbose_type_identified( char *element_type, param *p, int type )
{
if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, "Type from %s element: ", element_type );
// if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
// fprintf( stderr, "Type from %s element: ", element_type );
write_type( stderr, type );
fprintf( stderr, "\n" );
// fprintf( stderr, "\n" );
}

static void
verbose_type_assignment( char *tag, char *value, param *p, int type )
{
if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, "Type from tag '%s' data '%s': ", tag, value );
// if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
// fprintf( stderr, "Type from tag '%s' data '%s': ", tag, value );
write_type( stderr, type );
fprintf( stderr, "\n" );
// fprintf( stderr, "\n" );
}

typedef struct match_type {
Expand Down Expand Up @@ -364,10 +364,10 @@ get_type_issuance( fields *f, param *p )
}

if ( p->verbose ) {
if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, "Type from issuance/typeOfReference elements: " );
// if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
// fprintf( stderr, "Type from issuance/typeOfReference elements: " );
write_type( stderr, type );
fprintf( stderr, "\n" );
// fprintf( stderr, "\n" );
}

return type;
Expand All @@ -386,10 +386,10 @@ get_type( fields *f, param *p )
}

if ( p->verbose ) {
if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, "Final type: " );
// if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
// fprintf( stderr, "Final type: " );
write_type( stderr, type );
fprintf( stderr, "\n" );
// fprintf( stderr, "\n" );
}


Expand Down Expand Up @@ -430,8 +430,8 @@ append_type( int type, param *p, fields *out, int *status )
int fstatus;

if ( type < 0 || type >= NUM_TYPES ) {
if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, "Internal error: Cannot recognize type %d, switching to TYPE_STD %d\n", type, TYPE_STD );
// if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
// fprintf( stderr, "Internal error: Cannot recognize type %d, switching to TYPE_STD %d\n", type, TYPE_STD );
type = TYPE_STD;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bibutils_sys/src/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ str_initalloc( str *s, unsigned long minsize )
if ( minsize > str_initlen ) size = minsize;
s->data = (char *) malloc( sizeof( *(s->data) ) * size );
if ( !s->data ) {
fprintf(stderr,"Error. Cannot allocate memory in str_initalloc, requested %lu characters.\n", size );
// fprintf(stderr,"Error. Cannot allocate memory in str_initalloc, requested %lu characters.\n", size );
exit( EXIT_FAILURE );
}
s->data[0]='\0';
Expand Down
2 changes: 1 addition & 1 deletion crates/bibutils_sys/src/xml_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ xml_getencodingr( xml *node )
n = CHARSET_GB18030;
else n = charset_find( t );
if ( n==CHARSET_UNKNOWN ) {
fprintf( stderr, "Warning: did not recognize encoding '%s'\n", t );
// fprintf( stderr, "Warning: did not recognize encoding '%s'\n", t );
}
}
}
Expand Down

0 comments on commit 331aef2

Please sign in to comment.