/* 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; }
/* 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; }