From 331aef2c59d71925ae493bfca3ea5a8030e32934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20F=C3=B6rster?= Date: Wed, 4 Dec 2019 13:48:12 +0100 Subject: [PATCH] Remove stderr logging from bibutils --- crates/bibutils_sys/src/bibcore.c | 100 ++++++++++++------------- crates/bibutils_sys/src/bibl.c | 4 +- crates/bibutils_sys/src/biblatexin.c | 36 ++++----- crates/bibutils_sys/src/reftypes.c | 6 +- crates/bibutils_sys/src/risout.c | 28 +++---- crates/bibutils_sys/src/str.c | 2 +- crates/bibutils_sys/src/xml_encoding.c | 2 +- 7 files changed, 89 insertions(+), 89 deletions(-) diff --git a/crates/bibutils_sys/src/bibcore.c b/crates/bibutils_sys/src/bibcore.c index eeab58194..c7847533a 100644 --- a/crates/bibutils_sys/src/bibcore.c +++ b/crates/bibutils_sys/src/bibcore.c @@ -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 @@ -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; iassemblef ) { - fprintf( stderr, "-------------------assemblef start for bibl_write\n"); + // fprintf( stderr, "-------------------assemblef start for bibl_write\n"); } if ( p->headerf ) p->headerf( fp, p ); @@ -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 ); diff --git a/crates/bibutils_sys/src/bibl.c b/crates/bibutils_sys/src/bibl.c index 8862f6ea4..311ea9da3 100644 --- a/crates/bibutils_sys/src/bibl.c +++ b/crates/bibutils_sys/src/bibl.c @@ -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; } } @@ -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; } } diff --git a/crates/bibutils_sys/src/biblatexin.c b/crates/bibutils_sys/src/biblatexin.c index cbec80ba3..acd34c462 100644 --- a/crates/bibutils_sys/src/biblatexin.c +++ b/crates/bibutils_sys/src/biblatexin.c @@ -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 ); @@ -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 ); } } } @@ -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 ); @@ -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 @@ -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 ); } } diff --git a/crates/bibutils_sys/src/reftypes.c b/crates/bibutils_sys/src/reftypes.c index 0826c252c..b8863aca2 100644 --- a/crates/bibutils_sys/src/reftypes.c +++ b/crates/bibutils_sys/src/reftypes.c @@ -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; diff --git a/crates/bibutils_sys/src/risout.c b/crates/bibutils_sys/src/risout.c index 03106afc2..2f2f8af6d 100644 --- a/crates/bibutils_sys/src/risout.c +++ b/crates/bibutils_sys/src/risout.c @@ -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 { @@ -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; @@ -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" ); } @@ -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; } diff --git a/crates/bibutils_sys/src/str.c b/crates/bibutils_sys/src/str.c index 75b76bce7..64342f891 100644 --- a/crates/bibutils_sys/src/str.c +++ b/crates/bibutils_sys/src/str.c @@ -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'; diff --git a/crates/bibutils_sys/src/xml_encoding.c b/crates/bibutils_sys/src/xml_encoding.c index 135821528..ef4c58699 100644 --- a/crates/bibutils_sys/src/xml_encoding.c +++ b/crates/bibutils_sys/src/xml_encoding.c @@ -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 ); } } }