Пример #1
0
/* copac names appear to always start with last name first, but don't
 * always seem to have a comma after the name
 *
 * editors seem to be stuck in as authors with the tag "[Editor]" in it
 */
static int
copacin_person( fields *bibin, newstr *intag, newstr *invalue, int level, param *pm, char *outtag, fields *bibout )
{
	char *usetag = outtag, editor[]="EDITOR";
	newstr usename, *s;
	list tokens;
	int comma = 0, i, ok;

	if ( list_find( &(pm->asis), invalue->data ) !=-1  ||
	     list_find( &(pm->corps), invalue->data ) !=-1 ) {
		ok = name_add( bibout, outtag, invalue->data, level, &(pm->asis), &(pm->corps) );
		if ( ok ) return BIBL_OK;
		else return BIBL_ERR_MEMERR;
	}

	list_init( &tokens );
	newstr_init( &usename );

	list_tokenize( &tokens, invalue, " ", 1 );
	for ( i=0; i<tokens.n; ++i ) {
		s = list_get( &tokens, i );
		if ( !strcmp( s->data, "[Editor]" ) ) {
			usetag = editor;
			newstr_strcpy( s, "" );
		} else if ( s->len && s->data[s->len-1]==',' ) {
			comma++;
		}
	}

	if ( comma==0 && tokens.n ) {
		s = list_get( &tokens, 0 );
		newstr_addchar( s, ',' );
	}

	for ( i=0; i<tokens.n; ++i ) {
		s = list_get( &tokens, i );
		if ( s->len==0 ) continue;
		if ( i ) newstr_addchar( &usename, ' ' );
		newstr_newstrcat( &usename, s );
	}

	list_free( &tokens );

	ok = name_add( bibout, usetag, usename.data, level, &(pm->asis), &(pm->corps) );

	newstr_free( &usename );

	if ( ok ) return BIBL_OK;
	else return BIBL_ERR_MEMERR;
}
Пример #2
0
/*
 * process_names( info, newtag, field, level);
 *
 * split names in author list separated by and's (use '|' character)
 * and add names
 */
static void
process_names( fields *info, char *tag, newstr *data, int level, list *asis,
	list *corps )
{
	newstr_findreplace( data, " and ", "|" );
	name_add( info, tag, data->data, level, asis, corps );
}
Пример #3
0
/* copac names appear to always start with last name first, but don't
 * always seem to have a comma after the name
 *
 * editors seem to be stuck in as authors with the tag "[Editor]" in it
 */
static int
copacin_addname( fields *info, char *tag, newstr *name, int level, list *asis,
	list *corps )
{
	char *usetag = tag, editor[]="EDITOR";
	newstr usename, *s;
	list tokens;
	int comma = 0, i, ok;

	if ( list_find( asis, name->data ) !=-1  ||
	     list_find( corps, name->data ) !=-1 ) {
		ok = name_add( info, tag, name->data, level, asis, corps );
		if ( ok ) return BIBL_OK;
		else return BIBL_ERR_MEMERR;
	}

	list_init( &tokens );
	newstr_init( &usename );

	list_tokenize( &tokens, name, " ", 1 );
	for ( i=0; i<tokens.n; ++i ) {
		s = list_get( &tokens, i );
		if ( !strcmp( s->data, "[Editor]" ) ) {
			usetag = editor;
			newstr_strcpy( s, "" );
		} else if ( s->len && s->data[s->len-1]==',' ) {
			comma++;
		}
	}

	if ( comma==0 && tokens.n ) {
		s = list_get( &tokens, 0 );
		newstr_addchar( s, ',' );
	}

	for ( i=0; i<tokens.n; ++i ) {
		if ( i ) newstr_addchar( &usename, ' ' );
		newstr_newstrcat( &usename, list_get( &tokens, i ) );
	}

	list_free( &tokens );

	ok = name_add( info, usetag, usename.data, level, asis, corps );
	if ( ok ) return BIBL_OK;
	else return BIBL_ERR_MEMERR;
}
Пример #4
0
void
endin_convertf( fields *endin, fields *info, int reftype, param *p, variants *all, int nall )
{
	newstr *d;
	int  i, level, n, process;
	char *newtag, *t;
	for ( i=0; i<endin->nfields; ++i ) {
		/* Ensure that data exists */
		d = &( endin->data[i] );
		if ( !(d->data) || d->len==0 ) continue;
		/*
		 * All refer format tags start with '%'.  If we have one
		 * that doesn't, assume that it comes from endx2xml
		 * and just copy and paste to output
		 */
		t = endin->tag[i].data;
		if ( t[0]!='%' ) {
			fields_add( info, t, d->data, endin->level[i] );
			continue;
		}
		n = process_findoldtag( t, reftype, all, nall );
		if ( n==-1 ) {
			endin_notag( p, t, d->data );
			continue;
		}
		process = ((all[reftype]).tags[n]).processingtype;
		if ( process == ALWAYS ) continue; /* add these later */
		level = ((all[reftype]).tags[n]).level;
		newtag = ((all[reftype]).tags[n]).newstr;
		if ( process==SIMPLE )
			fields_add( info, newtag, d->data, level );
		else if ( process==TYPE )
			addtype( info, d->data, level );
		else if ( process==TITLE )
			title_process( info, newtag, d->data, level );
		else if ( process==PERSON )
			name_add( info, newtag, d->data, level, &(p->asis), 
					&(p->corps) );
		else if ( process==DATE )
			adddate( info, t, newtag,d->data,level);
		else if ( process==PAGES )
			addpage( info, d->data, level );
		else if ( process==SERIALNO )
			addsn( info, d->data, level );
		else if ( process==NOTES )
			addnotes( info, newtag, d->data, level );
		else {
/*				fprintf(stderr,"%s: internal error -- illegal process %d\n", r->progname, process );
*/
		}
	}
}
Пример #5
0
void
risin_convertf( fields *risin, fields *info, int reftype, param *p, variants *all, int nall )
{
	newstr *t, *d;
	int process, level, i, n;
	char *newtag;
	for ( i=0; i<risin->nfields; ++i ) {
		t = &( risin->tag[i] );
		d = &( risin->data[i] );
		n = process_findoldtag( t->data, reftype, all, nall );
		if ( n==-1 ) {
			risin_report_notag( p, t->data );
			continue;
		}
		process = ((all[reftype]).tags[n]).processingtype;
		level   = ((all[reftype]).tags[n]).level;
		newtag  = ((all[reftype]).tags[n]).newstr;
		if ( process==SIMPLE )
			fields_add( info, newtag, d->data, level );
		else if ( process==PERSON )
			name_add( info, newtag, d->data, level, &(p->asis), 
					&(p->corps) );
		else if ( process==TITLE )
			title_process( info, newtag, d->data, level );
		else if ( process==DATE )
			adddate( info, newtag, d->data, level );
		else if ( process==SERIALNO )
			addsn( info, d->data, level );
		else if ( process==NOTES )
			notes_add( info, newtag, d, level );
		else { /* do nothing */ }
	}
	/* look for thesis-type hint */
	if ( !strcasecmp( all[reftype].type, "THES" ) ) {
		for ( i=0; i<risin->nfields; ++i ) {
			if ( strcasecmp(risin->tag[i].data, "U1") )
				continue;
			if ( !strcasecmp(risin->data[i].data,"Ph.D. Thesis")||
			     !strcasecmp(risin->data[i].data,"Masters Thesis")||
			     !strcasecmp(risin->data[i].data,"Diploma Thesis")||
			     !strcasecmp(risin->data[i].data,"Doctoral Thesis")||
			     !strcasecmp(risin->data[i].data,"Habilitation Thesis"))
				fields_add( info, "GENRE", risin->data[i].data,
					0 );
		}
	}
}
Пример #6
0
/* copac names appear to always start with last name first, but don't
 * always seem to have a comma after the name
 *
 * editors seem to be stuck in as authors with the tag "[Editor]" in it
 */
static void
copacin_addname( fields *info, char *tag, newstr *name, int level, list *asis,
	list *corps )
{
	char *usetag = tag, editor[]="EDITOR", *p;
	int comma = 0;
	if ( strstr( name->data,"[Editor]" ) ) {
		newstr_findreplace( name, "[Editor]", "" );
		usetag = editor;
	}
	p = skip_ws( name->data );
	while ( *p && !is_ws( *p ) ) {
		if ( *p==',' ) comma++;
		p++;
	}
	if ( !comma && is_ws( *p ) ) *p = ',';
	name_add( info, usetag, name->data, level, asis, corps );
}
Пример #7
0
void
isiin_convertf( fields *isiin, fields *info, int reftype, param *p, variants *all, int nall )
{
	newstr *t, *d;
	int process, level, i, n;
	char *newtag;

	isiin_addauthors( isiin, info, reftype, all, nall, &(p->asis), 
			&(p->corps) );

	for ( i=0; i<isiin->nfields; ++i ) {
		t = &( isiin->tag[i] );
		if ( !strcasecmp( t->data, "AU" ) || !strcasecmp( t->data, "AF" ) )
			continue;
		d = &( isiin->data[i] );
		n = process_findoldtag( t->data, reftype, all, nall );
		if ( n==-1 ) {
			isiin_report_notag( p, t->data );
			continue;
		}
		process = ((all[reftype]).tags[n]).processingtype;
		level = ((all[reftype]).tags[n]).level;
		newtag = all[reftype].tags[n].newstr;
		if ( process == SIMPLE || process == DATE )
			fields_add( info, newtag, d->data, level );
		else if ( process == PERSON )
			name_add( info, newtag, d->data, level, &(p->asis), 
					&(p->corps) );
		else if ( process == TITLE )
			title_process( info, newtag, d->data, level );
		else if ( process == ISI_KEYWORD )
			keyword_process( info, newtag, d->data, level );
		else if ( process == SERIALNO )
			addsn( info, d->data, level );
		/* do nothing if process==TYPE || process==ALWAYS */
	}
}
Пример #8
0
/* pull off authors first--use AF before AU */
static void
isiin_addauthors( fields *isiin, fields *info, int reftype, variants *all, int nall, list *asis, list *corps )
{
	newstr *t, *d;
	char *newtag, *authortype, use_af[]="AF", use_au[]="AU";
	int level, i, n, has_af=0, has_au=0;
	for ( i=0; i<isiin->nfields && has_af==0; ++i ) {
		t = &( isiin->tag[i] );
		if ( !strcasecmp( t->data, "AU" ) ) has_au++;
		if ( !strcasecmp( t->data, "AF" ) ) has_af++;
	}
	if ( has_af ) authortype = use_af;
	else authortype = use_au;
	for ( i=0; i<isiin->nfields; ++i ) {
		t = &( isiin->tag[i] );
		if ( !strcasecmp( t->data, "AU" ) ) has_au++;
		if ( strcasecmp( t->data, authortype ) ) continue;
		d = &( isiin->data[i] );
		n = process_findoldtag( authortype, reftype, all, nall );
		level = ((all[reftype]).tags[n]).level;
		newtag = all[reftype].tags[n].newstr;
		name_add( info, newtag, d->data, level, asis, corps );
	}
}
Пример #9
0
int
endin_convertf( fields *endin, fields *info, int reftype, param *p, variants *all, int nall )
{
	int i, level, n, process, nfields, ok;
	char *newtag, *t;
	newstr *d;

	nfields = fields_num( endin );
	for ( i=0; i<nfields; ++i ) {
		/* Ensure that data exists */
		d = fields_value( endin, i, FIELDS_STRP_NOUSE );
		if ( d->len == 0 ) {
			fields_setused( endin, i );
			continue;
		}
		/*
		 * All refer format tags start with '%'.  If we have one
		 * that doesn't, assume that it comes from endx2xml
		 * and just copy and paste to output
		 */
		t = fields_tag( endin, i, FIELDS_CHRP );
		if ( t[0]!='%' ) {
			fields_add( info, t, d->data, endin->level[i] );
			continue;
		}

		n = translate_oldtag( t, reftype, all, nall, &process, &level, &newtag );
		if ( n==-1 ) {
			endin_notag( p, t, d->data );
			continue;
		}
		if ( process == ALWAYS ) continue; /* add these later */

		fields_setused( endin, i );

		switch ( process ) {

		case SIMPLE:
			ok = fields_add( info, newtag, d->data, level );
			break;

		case TYPE:
			ok = endin_addtype( info, d->data, level );
			break;

		case TITLE:
			ok = title_process( info, newtag, d->data, level, p->nosplittitle );
			break;

		case PERSON:
			ok = name_add( info, newtag, d->data, level, &(p->asis), &(p->corps) );
			break;

		case DATE:
			ok = endin_adddate( info, t, newtag,d->data,level);
			break;

		case PAGES:
			ok = endin_addpage( info, d->data, level );
			break;

		case SERIALNO:
			ok = addsn( info, d->data, level );
			break;

		case NOTES:
			ok = endin_addnotes( info, newtag, d->data, level );
			break;

		default:
			fprintf(stderr,"%s: internal error -- illegal process number %d\n", p->progname, process );
			ok = 1;
			break;
		}

		if ( !ok ) return BIBL_ERR_MEMERR;

	}

	return BIBL_OK;
}