From 745892fbddea56040139108277e728b53fd8fc11 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 28 May 2020 03:03:21 +0000 Subject: CTAN sync 202005280303 --- support/texlab/crates/bibutils_sys/src/risout.c | 793 ------------------------ 1 file changed, 793 deletions(-) delete mode 100644 support/texlab/crates/bibutils_sys/src/risout.c (limited to 'support/texlab/crates/bibutils_sys/src/risout.c') diff --git a/support/texlab/crates/bibutils_sys/src/risout.c b/support/texlab/crates/bibutils_sys/src/risout.c deleted file mode 100644 index 03106afc2c..0000000000 --- a/support/texlab/crates/bibutils_sys/src/risout.c +++ /dev/null @@ -1,793 +0,0 @@ -/* - * risout.c - * - * Copyright (c) Chris Putnam 2003-2019 - * - * Source code released under the GPL version 2 - * - */ -#include -#include -#include -#include "bibformats.h" -#include "fields.h" -#include "generic.h" -#include "name.h" -#include "str.h" -#include "title.h" -#include "url.h" -#include "utf8.h" -#include "msvc_fix.h" - -/***************************************************** - PUBLIC: int risout_initparams() -*****************************************************/ - -static int risout_write( fields *info, FILE *fp, param *p, unsigned long refnum ); -static int risout_assemble( fields *in, fields *out, param *pm, unsigned long refnum ); - -int -risout_initparams( param *pm, const char *progname ) -{ - pm->writeformat = BIBL_RISOUT; - pm->format_opts = 0; - pm->charsetout = BIBL_CHARSET_DEFAULT; - pm->charsetout_src = BIBL_SRC_DEFAULT; - pm->latexout = 0; - pm->utf8out = BIBL_CHARSET_UTF8_DEFAULT; - pm->utf8bom = BIBL_CHARSET_BOM_DEFAULT; - pm->xmlout = BIBL_XMLOUT_FALSE; - pm->nosplittitle = 0; - pm->verbose = 0; - pm->addcount = 0; - pm->singlerefperfile = 0; - - if ( pm->charsetout == BIBL_CHARSET_UNICODE ) { - pm->utf8out = pm->utf8bom = 1; - } - - pm->headerf = generic_writeheader; - pm->footerf = NULL; - pm->assemblef = risout_assemble; - pm->writef = risout_write; - - if ( !pm->progname ) { - if ( progname==NULL ) pm->progname = NULL; - else { - pm->progname = strdup( progname ); - if ( !pm->progname ) return BIBL_ERR_MEMERR; - } - } - - return BIBL_OK; -} - -/***************************************************** - PUBLIC: int risout_assemble() -*****************************************************/ - -enum { - TYPE_UNKNOWN = 0, - TYPE_STD, /* standard/generic (1) */ - TYPE_ABSTRACT, /* abstract (2) */ - TYPE_ARTICLE, /* article (3) */ - TYPE_BOOK, /* book (4) */ - TYPE_CASE, /* case (5) */ - TYPE_INBOOK, /* chapter (6) */ - TYPE_CONF, /* conference (7) */ - TYPE_ELEC, /* electronic (8) */ - TYPE_HEAR, /* hearing (9) */ - TYPE_MAGARTICLE, /* magazine article (10) */ - TYPE_NEWSPAPER, /* newspaper (11) */ - TYPE_MPCT, /* mpct (12) */ - TYPE_PAMPHLET, /* pamphlet (13) */ - TYPE_PATENT, /* patent (14) */ - TYPE_PCOMM, /* personal communication (15) */ - TYPE_PROGRAM, /* program (16) */ - TYPE_REPORT, /* report (17) */ - TYPE_STATUTE, /* statute (18) */ - TYPE_THESIS, /* thesis (19) */ - TYPE_LICENTIATETHESIS, /* thesis (20) */ - TYPE_MASTERSTHESIS, /* thesis (21) */ - TYPE_PHDTHESIS, /* thesis (22) */ - TYPE_DIPLOMATHESIS, /* thesis (23) */ - TYPE_DOCTORALTHESIS, /* thesis (24) */ - TYPE_HABILITATIONTHESIS, /* thesis (25) */ - TYPE_MAP, /* map, cartographic data (26) */ - TYPE_UNPUBLISHED, /* unpublished (27) */ - NUM_TYPES /* (28) */ -}; - -static int type_is_element[ NUM_TYPES ] = { - // Patch: Fix compilation on MSVC - // [ 0 ... NUM_TYPES-1 ] = 0, - [ 0 ] = 0, - [ 1 ] = 0, - [ 2 ] = 0, - [ 3 ] = 0, - [ 4 ] = 0, - [ 5 ] = 0, - [ 6 ] = 0, - [ 7 ] = 0, - [ 8 ] = 0, - [ 9 ] = 0, - [ 10 ] = 0, - [ 11 ] = 0, - [ 12 ] = 0, - [ 13 ] = 0, - [ 14 ] = 0, - [ 15 ] = 0, - [ 16 ] = 0, - [ 17 ] = 0, - [ 18 ] = 0, - [ 19 ] = 0, - [ 20 ] = 0, - [ 21 ] = 0, - [ 22 ] = 0, - [ 23 ] = 0, - [ 24 ] = 0, - [ 25 ] = 0, - [ 26 ] = 0, - [ 27 ] = 0, - [ TYPE_ARTICLE ] = 1, - [ TYPE_INBOOK ] = 1, - [ TYPE_MAGARTICLE ] = 1, - [ TYPE_NEWSPAPER ] = 1, - [ TYPE_ABSTRACT ] = 1, - [ TYPE_CONF ] = 1, -}; - -static int type_uses_journal[ NUM_TYPES ] = { - // Patch: Fix compilation on MSVC - // [ 0 ... NUM_TYPES-1 ] = 0, - [ 0 ] = 0, - [ 1 ] = 0, - [ 2 ] = 0, - [ 3 ] = 0, - [ 4 ] = 0, - [ 5 ] = 0, - [ 6 ] = 0, - [ 7 ] = 0, - [ 8 ] = 0, - [ 9 ] = 0, - [ 10 ] = 0, - [ 11 ] = 0, - [ 12 ] = 0, - [ 13 ] = 0, - [ 14 ] = 0, - [ 15 ] = 0, - [ 16 ] = 0, - [ 17 ] = 0, - [ 18 ] = 0, - [ 19 ] = 0, - [ 20 ] = 0, - [ 21 ] = 0, - [ 22 ] = 0, - [ 23 ] = 0, - [ 24 ] = 0, - [ 25 ] = 0, - [ 26 ] = 0, - [ 27 ] = 0, - [ TYPE_ARTICLE ] = 1, - [ TYPE_MAGARTICLE ] = 1, -}; - -static void -write_type( FILE *fp, int type ) -{ - const char *typenames[ NUM_TYPES ] = { - [ TYPE_UNKNOWN ] = "TYPE_UNKNOWN", - [ TYPE_STD ] = "TYPE_STD", - [ TYPE_ABSTRACT ] = "TYPE_ABSTRACT", - [ TYPE_ARTICLE ] = "TYPE_ARTICLE", - [ TYPE_BOOK ] = "TYPE_BOOK", - [ TYPE_CASE ] = "TYPE_CASE", - [ TYPE_INBOOK ] = "TYPE_INBOOK", - [ TYPE_CONF ] = "TYPE_CONF", - [ TYPE_ELEC ] = "TYPE_ELEC", - [ TYPE_HEAR ] = "TYPE_HEAR", - [ TYPE_MAGARTICLE ] = "TYPE_MAGARTICLE", - [ TYPE_NEWSPAPER ] = "TYPE_NEWSPAPER", - [ TYPE_MPCT ] = "TYPE_MPCT", - [ TYPE_PAMPHLET ] = "TYPE_PAMPHLET", - [ TYPE_PATENT ] = "TYPE_PATENT", - [ TYPE_PCOMM ] = "TYPE_PCOMM", - [ TYPE_PROGRAM ] = "TYPE_PROGRAM", - [ TYPE_REPORT ] = "TYPE_REPORT", - [ TYPE_STATUTE ] = "TYPE_STATUTE", - [ TYPE_THESIS ] = "TYPE_THESIS", - [ TYPE_LICENTIATETHESIS ] = "TYPE_LICENTIATETHESIS", - [ TYPE_MASTERSTHESIS ] = "TYPE_MASTERSTHESIS", - [ TYPE_PHDTHESIS ] = "TYPE_PHDTHESIS", - [ TYPE_DIPLOMATHESIS ] = "TYPE_DIPLOMATHESIS", - [ TYPE_DOCTORALTHESIS ] = "TYPE_DOCTORALTHESIS", - [ TYPE_HABILITATIONTHESIS ] = "TYPE_HABILITATIONTHESIS", - [ TYPE_MAP ] = "TYPE_MAP", - [ TYPE_UNPUBLISHED ] = "TYPE_UNPUBLISHED", - }; - - if ( type < 0 || type >= NUM_TYPES ) fprintf( fp, "Error - type not in enum" ); - else fprintf( fp, "%s", typenames[ 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 ); - write_type( stderr, type ); - 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 ); - write_type( stderr, type ); - fprintf( stderr, "\n" ); -} - -typedef struct match_type { - char *name; - int type; -} match_type; - -/* Try to determine type of reference from - * - */ -static int -get_type_genre( fields *f, param *p ) -{ - match_type match_genres[] = { - { "academic journal", TYPE_ARTICLE }, - { "article", TYPE_ARTICLE }, - { "journal article", TYPE_ARTICLE }, - { "magazine", TYPE_MAGARTICLE }, - { "conference publication", TYPE_CONF }, - { "newspaper", TYPE_NEWSPAPER }, - { "legislation", TYPE_STATUTE }, - { "communication", TYPE_PCOMM }, - { "hearing", TYPE_HEAR }, - { "electronic", TYPE_ELEC }, - { "legal case and case notes", TYPE_CASE }, - { "book chapter", TYPE_INBOOK }, - { "Ph.D. thesis", TYPE_PHDTHESIS }, - { "Licentiate thesis", TYPE_LICENTIATETHESIS }, - { "Masters thesis", TYPE_MASTERSTHESIS }, - { "Diploma thesis", TYPE_DIPLOMATHESIS }, - { "Doctoral thesis", TYPE_DOCTORALTHESIS }, - { "Habilitation thesis", TYPE_HABILITATIONTHESIS }, - { "report", TYPE_REPORT }, - { "technical report", TYPE_REPORT }, - { "abstract or summary", TYPE_ABSTRACT }, - { "patent", TYPE_PATENT }, - { "unpublished", TYPE_UNPUBLISHED }, - { "manuscript", TYPE_UNPUBLISHED }, - { "map", TYPE_MAP }, - }; - int nmatch_genres = sizeof( match_genres ) / sizeof( match_genres[0] ); - char *tag, *value; - int type, i, j; - - type = TYPE_UNKNOWN; - - for ( i=0; iverbose ) verbose_type_assignment( tag, value, p, type ); - if ( type==TYPE_UNKNOWN ) { - if ( !strcasecmp( value, "periodical" ) ) - type = TYPE_ARTICLE; - else if ( !strcasecmp( value, "thesis" ) ) - type = TYPE_THESIS; - else if ( !strcasecmp( value, "book" ) ) { - if ( fields_level( f, i )==0 ) type=TYPE_BOOK; - else type=TYPE_INBOOK; - } - else if ( !strcasecmp( value, "collection" ) ) { - if ( fields_level( f, i )==0 ) type=TYPE_BOOK; - else type=TYPE_INBOOK; - } - } - - } - - if ( p->verbose ) verbose_type_identified( "genre", p, type ); - - return type; -} - -/* Try to determine type of reference from - * - */ -static int -get_type_resource( fields *f, param *p ) -{ - match_type match_res[] = { - { "software, multimedia", TYPE_PROGRAM }, - { "cartographic", TYPE_MAP }, - }; - int nmatch_res = sizeof( match_res ) / sizeof( match_res[0] ); - vplist_index i; - int type, j; - char *value; - vplist a; - - type = TYPE_UNKNOWN; - - vplist_init( &a ); - fields_findv_each( f, LEVEL_ANY, FIELDS_CHRP, &a, "RESOURCE" ); - - for ( i=0; iverbose ) verbose_type_assignment( "RESOURCE", value, p, type ); - } - - if ( p->verbose ) verbose_type_identified( "resource", p, type ); - - vplist_free( &a ); - return type; -} - -/* Try to determine type of reference from and */ -/* */ -static int -get_type_issuance( fields *f, param *p ) -{ - int type = TYPE_UNKNOWN; - int i, monographic = 0, monographic_level = 0; -// int text = 0; - for ( i=0; in; ++i ) { - if ( !strcasecmp( (char *) fields_tag( f, i, FIELDS_CHRP_NOUSE ), "issuance" ) && - !strcasecmp( (char *) fields_value( f, i, FIELDS_CHRP_NOUSE ), "MONOGRAPHIC" ) ){ - monographic = 1; - monographic_level = f->level[i]; - } -// if ( !strcasecmp( (char *) fields_tag( f, i, FIELDS_CHRP_NOUSE ), "typeOfResource" ) && -// !strcasecmp( (char *) fields_value( f, i, FIELDS_CHRP_NOUSE ), "text" ) ) { -// text = 1; -// } - } -// if ( monographic && text ) { - if ( monographic ) { - if ( monographic_level==0 ) type=TYPE_BOOK; - else if ( monographic_level>0 ) type=TYPE_INBOOK; - } - - if ( p->verbose ) { - if ( p->progname ) fprintf( stderr, "%s: ", p->progname ); - fprintf( stderr, "Type from issuance/typeOfReference elements: " ); - write_type( stderr, type ); - fprintf( stderr, "\n" ); - } - - return type; -} - -static int -get_type( fields *f, param *p ) -{ - int type; - type = get_type_genre( f, p ); - if ( type==TYPE_UNKNOWN ) type = get_type_resource( f, p ); - if ( type==TYPE_UNKNOWN ) type = get_type_issuance( f, p ); - if ( type==TYPE_UNKNOWN ) { - if ( fields_maxlevel( f ) > 0 ) type = TYPE_INBOOK; - else type = TYPE_STD; - } - - if ( p->verbose ) { - if ( p->progname ) fprintf( stderr, "%s: ", p->progname ); - fprintf( stderr, "Final type: " ); - write_type( stderr, type ); - fprintf( stderr, "\n" ); - } - - - return type; -} - -static void -append_type( int type, param *p, fields *out, int *status ) -{ - char *typenames[ NUM_TYPES ] = { - [ TYPE_STD ] = "STD", - [ TYPE_ABSTRACT ] = "ABST", - [ TYPE_ARTICLE ] = "JOUR", - [ TYPE_BOOK ] = "BOOK", - [ TYPE_CASE ] = "CASE", - [ TYPE_INBOOK ] = "CHAP", - [ TYPE_CONF ] = "CONF", - [ TYPE_ELEC ] = "ELEC", - [ TYPE_HEAR ] = "HEAR", - [ TYPE_MAGARTICLE ] = "MGZN", - [ TYPE_NEWSPAPER ] = "NEWS", - [ TYPE_MPCT ] = "MPCT", - [ TYPE_PAMPHLET ] = "PAMP", - [ TYPE_PATENT ] = "PAT", - [ TYPE_PCOMM ] = "PCOMM", - [ TYPE_PROGRAM ] = "COMP", - [ TYPE_REPORT ] = "RPRT", - [ TYPE_STATUTE ] = "STAT", - [ TYPE_THESIS ] = "THES", - [ TYPE_MASTERSTHESIS ] = "THES", - [ TYPE_PHDTHESIS ] = "THES", - [ TYPE_DIPLOMATHESIS ] = "THES", - [ TYPE_DOCTORALTHESIS ] = "THES", - [ TYPE_HABILITATIONTHESIS ] = "THES", - [ TYPE_MAP ] = "MAP", - [ TYPE_UNPUBLISHED ] = "UNPB", - }; - 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 ); - type = TYPE_STD; - } - - fstatus = fields_add( out, "TY", typenames[ type ], LEVEL_MAIN ); - if ( fstatus!=FIELDS_OK ) *status = BIBL_ERR_MEMERR; -} - -static void -append_people( fields *f, char *tag, char *ristag, int level, fields *out, int *status ) -{ - vplist_index i; - str oneperson; - vplist people; - int fstatus; - - str_init( &oneperson ); - vplist_init( &people ); - fields_findv_each( f, level, FIELDS_CHRP, &people, tag ); - for ( i=0; in; ++i ) { - tag = fields_tag ( out, i, FIELDS_CHRP ); - value = fields_value( out, i, FIELDS_CHRP ); - fprintf( fp, "%s - %s\n", tag, value ); - } - - fprintf( fp, "ER - \n" ); - fflush( fp ); - return BIBL_OK; -} -- cgit v1.2.3