Menu

Mods <titleInfo><nonSort/></titleInfo> is not preserved

matt
2020-06-29
2020-07-01
  • matt

    matt - 2020-06-29

    Hi All,

    When transforming valid mods XML to RIS (or other formats) the nonSort portion of the title is dropped. I would expect it to appear preceding the main title.

    I believe I have implemented the proper changes to make this happen. But should note that I haven't worked with C since I last contributed to this project in 2014 [1].

    Can you inform me of the process of submitting patches?

    Thanks,
    Matt

    [1] - https://sourceforge.net/p/bibutils/discussion/general/thread/cbd9e838/

     
  • matt

    matt - 2020-06-29

    Proposed patch: http://ix.io/2qvJ

    diff -Naur ./lib/adsout.c /home/matt/bibutils_6.10/lib/adsout.c
    --- ./lib/adsout.c  2020-06-29 11:40:25.777497402 -0400
    +++ /home/matt/bibutils_6.10/lib/adsout.c   2020-03-23 14:53:54.000000000 -0400
    @@ -152,22 +152,21 @@
     }
    
     static int
    -append_title( fields *in, char *nsrt, char *ttl, char *sub, char *adstag, int level, fields *out, int *status )
    +append_title( fields *in, char *ttl, char *sub, char *adstag, int level, fields *out, int *status )
     {
    -   str fulltitle, *nonsort, *title, *subtitle, *vol, *iss, *sn, *en, *ar;
    +   str fulltitle, *title, *subtitle, *vol, *iss, *sn, *en, *ar;
        int fstatus, output = 0;
    
        str_init( &fulltitle );
    
    -  nonsort   = fields_findv( in, level, FIELDS_STRP, nsrt );
    -   title     = fields_findv( in, level, FIELDS_STRP, ttl  );
    -   subtitle  = fields_findv( in, level, FIELDS_STRP, sub  );
    +   title     = fields_findv( in, level, FIELDS_STRP, ttl );
    +   subtitle  = fields_findv( in, level, FIELDS_STRP, sub );
    
        if ( str_has_value( title ) ) {
    
            output = 1;
    
    -       title_combine( &fulltitle, nonsort, title, subtitle );
    +       title_combine( &fulltitle, title, subtitle );
    
            vol = fields_findv( in, LEVEL_ANY, FIELDS_STRP, "VOLUME" );
            if ( str_has_value( vol ) ) {
    @@ -222,9 +221,9 @@
     {
        int added;
        if ( type==TYPE_ARTICLE || type==TYPE_MAGARTICLE ) {
    -       added = append_title( in, "NONSORT", "TITLE", "SUBTITLE", "%J", LEVEL_HOST, out, status );
    +       added = append_title( in, "TITLE", "SUBTITLE", "%J", LEVEL_HOST, out, status );
            if ( added==0 )
    -           (void) append_title( in, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", "%J", LEVEL_HOST, out, status );
    +           (void) append_title( in, "SHORTTITLE", "SHORTSUBTITLE", "%J", LEVEL_HOST, out, status );
        }
     }
    
    diff -Naur ./lib/biblatexout.c /home/matt/bibutils_6.10/lib/biblatexout.c
    --- ./lib/biblatexout.c 2020-06-29 11:38:30.547495470 -0400
    +++ /home/matt/bibutils_6.10/lib/biblatexout.c  2020-03-23 14:53:54.000000000 -0400
    @@ -396,18 +396,13 @@
     }
    
     static int
    -append_title_chosen( fields *in, char *bibtag, fields *out, int nnonsortttl, int nmainttl, int nsubttl )
    +append_title_chosen( fields *in, char *bibtag, fields *out, int nmainttl, int nsubttl )
     {
    -   str fulltitle, *nonsortttl = NULL, *mainttl = NULL, *subttl = NULL;
    +   str fulltitle, *mainttl = NULL, *subttl = NULL;
        int status, ret = BIBL_OK;
    
        str_init( &fulltitle );
    
    -   if ( nnonsortttl!=-1 ) {
    -       mainttl = fields_value( in, nnonsortttl, FIELDS_STRP );
    -       fields_set_used( in, nnonsortttl );
    -   }
    -
        if ( nmainttl!=-1 ) {
            mainttl = fields_value( in, nmainttl, FIELDS_STRP );
            fields_set_used( in, nmainttl );
    @@ -418,7 +413,7 @@
            fields_set_used( in, nsubttl );
        }
    
    -   title_combine( &fulltitle, nonsortttl, mainttl, subttl );
    +   title_combine( &fulltitle, mainttl, subttl );
    
        if ( str_memerr( &fulltitle ) ) {
            ret = BIBL_ERR_MEMERR;
    @@ -438,28 +433,24 @@
     static int
     append_title( fields *in, char *bibtag, int level, fields *out, int format_opts )
     {
    -   int nonsort, short_nonsort, title, short_title, subtitle, short_subtitle, use_nonsort, use_title, use_subtitle;
    +   int title, short_title, subtitle, short_subtitle, use_title, use_subtitle;
    
    -   nonsort        = fields_find( in, "NONSORT",       level );
    -   short_nonsort  = fields_find( in, "SHORTNONSORT",  level );
        title          = fields_find( in, "TITLE",         level );
        short_title    = fields_find( in, "SHORTTITLE",    level );
        subtitle       = fields_find( in, "SUBTITLE",      level );
        short_subtitle = fields_find( in, "SHORTSUBTITLE", level );
    
        if ( title==FIELDS_NOTFOUND || ( ( format_opts & BIBL_FORMAT_BIBOUT_SHORTTITLE ) && level==1 ) ) {
    -    use_nonsort = short_nonsort;
            use_title    = short_title;
            use_subtitle = short_subtitle;
        }
    
        else {
    -    use_nonsort = nonsort;
            use_title    = title;
            use_subtitle = subtitle;
        }
    
    -   return append_title_chosen( in, bibtag, out, use_nonsort, use_title, use_subtitle );
    +   return append_title_chosen( in, bibtag, out, use_title, use_subtitle );
     }
    
     static void
    diff -Naur ./lib/bibtexout.c /home/matt/bibutils_6.10/lib/bibtexout.c
    --- ./lib/bibtexout.c   2020-06-29 11:34:53.894158506 -0400
    +++ /home/matt/bibutils_6.10/lib/bibtexout.c    2020-03-23 14:53:54.000000000 -0400
    @@ -372,17 +372,13 @@
     }
    
     static int
    -append_title_chosen( fields *in, char *bibtag, fields *out,int nnonsortttl, int nmainttl, int nsubttl )
    +append_title_chosen( fields *in, char *bibtag, fields *out, int nmainttl, int nsubttl )
     {
    -   str fulltitle, *nonsortttl = NULL, *mainttl = NULL, *subttl = NULL;
    +   str fulltitle, *mainttl = NULL, *subttl = NULL;
        int status, ret = BIBL_OK;
    
        str_init( &fulltitle );
    
    -   if ( nnonsortttl !=-1 ) {
    -       nonsortttl = fields_value( in, nnonsortttl, FIELDS_STRP );
    -       fields_set_used( in, nnonsortttl );
    -   }
        if ( nmainttl!=-1 ) {
            mainttl = fields_value( in, nmainttl, FIELDS_STRP );
            fields_set_used( in, nmainttl );
    @@ -393,7 +389,7 @@
            fields_set_used( in, nsubttl );
        }
    
    -   title_combine( &fulltitle, nonsortttl, mainttl, subttl );
    +   title_combine( &fulltitle, mainttl, subttl );
    
        if ( str_memerr( &fulltitle ) ) {
            ret = BIBL_ERR_MEMERR;
    @@ -413,29 +409,24 @@
     static int
     append_title( fields *in, char *bibtag, int level, fields *out, int format_opts )
     {
    -   int nonsort, short_nonsort, title, short_title, subtitle, short_subtitle, use_nonsort, use_title, use_subtitle;
    +   int title, short_title, subtitle, short_subtitle, use_title, use_subtitle;
    
    -  
    -   nonsort        = fields_find( in, "NONSORT",       level );
    -   short_nonsort  = fields_find( in, "SHORTNONSORT",  level );
        title          = fields_find( in, "TITLE",         level );
        short_title    = fields_find( in, "SHORTTITLE",    level );
        subtitle       = fields_find( in, "SUBTITLE",      level );
        short_subtitle = fields_find( in, "SHORTSUBTITLE", level );
    
        if ( title==FIELDS_NOTFOUND || ( ( format_opts & BIBL_FORMAT_BIBOUT_SHORTTITLE ) && level==1 ) ) {
    -    use_nonsort = short_nonsort;
            use_title    = short_title;
            use_subtitle = short_subtitle;
        }
    
        else {
    -    use_nonsort = nonsort;
            use_title    = title;
            use_subtitle = subtitle;
        }
    
    -   return append_title_chosen( in, bibtag, out, use_nonsort, use_title, use_subtitle );
    +   return append_title_chosen( in, bibtag, out, use_title, use_subtitle );
     }
    
     static void
    diff -Naur ./lib/endout.c /home/matt/bibutils_6.10/lib/endout.c
    --- ./lib/endout.c  2020-06-29 11:29:37.577486506 -0400
    +++ /home/matt/bibutils_6.10/lib/endout.c   2020-03-23 14:53:54.000000000 -0400
    @@ -410,17 +410,16 @@
     }
    
     static int
    -append_title( fields *in, char *nonsort, char *full, char *sub, char *endtag,
    +append_title( fields *in, char *full, char *sub, char *endtag,
            int level, fields *out, int *status )
     {
    -   str *nonsortttl = fields_findv( in, level, FIELDS_STRP, nonsort);
        str *mainttl = fields_findv( in, level, FIELDS_STRP, full );
        str *subttl  = fields_findv( in, level, FIELDS_STRP, sub );
        str fullttl;
        int fstatus;
    
        str_init( &fullttl );
    -   title_combine( &fullttl, nonsortttl, mainttl, subttl );
    +   title_combine( &fullttl, mainttl, subttl );
    
        if ( str_memerr( &fullttl ) ) {
            *status = BIBL_ERR_MEMERR;
    @@ -659,9 +658,9 @@
    
        append_type( type, out, pm, &status );
    
    -   added = append_title( in, "NONSORT", "TITLE",      "SUBTITLE",      "%T", LEVEL_MAIN, out, &status );
    -   if ( added==0 ) append_title( in, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", "%T", LEVEL_MAIN, out, &status );
    -   else            append_title( in, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", "%!", LEVEL_MAIN, out, &status );
    +   added = append_title( in, "TITLE",      "SUBTITLE",      "%T", LEVEL_MAIN, out, &status );
    +   if ( added==0 ) append_title( in, "SHORTTITLE", "SHORTSUBTITLE", "%T", LEVEL_MAIN, out, &status );
    +   else            append_title( in, "SHORTTITLE", "SHORTSUBTITLE", "%!", LEVEL_MAIN, out, &status );
    
        append_people( in, "AUTHOR",     "%A", LEVEL_MAIN, out, &status );
        append_people( in, "EDITOR",     "%E", LEVEL_MAIN, out, &status );
    @@ -705,22 +704,22 @@
        }
    
        if ( type==TYPE_ARTICLE || type==TYPE_MAGARTICLE || type==TYPE_ELECTRONICARTICLE || type==TYPE_NEWSARTICLE ) {
    -       added = append_title( in, "NONSORT", "TITLE", "SUBTITLE", "%J", LEVEL_HOST, out, &status );
    -       if ( added==0 ) append_title( in, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", "%J", LEVEL_HOST, out, &status );
    +       added = append_title( in, "TITLE", "SUBTITLE", "%J", LEVEL_HOST, out, &status );
    +       if ( added==0 ) append_title( in, "SHORTTITLE", "SHORTSUBTITLE", "%J", LEVEL_HOST, out, &status );
        }
    
        else if ( type==TYPE_INBOOK || type==TYPE_INPROCEEDINGS ) {
    -       added = append_title( in, "NONSORT", "TITLE", "SUBTITLE", "%B", LEVEL_HOST, out, &status );
    -       if ( added==0 ) append_title( in, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", "%B", LEVEL_HOST, out, &status );
    +       added = append_title( in, "TITLE", "SUBTITLE", "%B", LEVEL_HOST, out, &status );
    +       if ( added==0 ) append_title( in, "SHORTTITLE", "SHORTSUBTITLE", "%B", LEVEL_HOST, out, &status );
        }
    
        else {
    -       added = append_title( in, "NONSORT", "TITLE", "SUBTITLE", "%S", LEVEL_HOST, out, &status );
    -       if ( added==0 ) append_title( in, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", "%S", LEVEL_HOST, out, &status );
    +       added = append_title( in, "TITLE", "SUBTITLE", "%S", LEVEL_HOST, out, &status );
    +       if ( added==0 ) append_title( in, "SHORTTITLE", "SHORTSUBTITLE", "%S", LEVEL_HOST, out, &status );
        }
    
        if ( type!=TYPE_CASE && type!=TYPE_HEARING ) {
    -       append_title( in, "SHORTNONSORT", "TITLE", "SUBTITLE", "%S", LEVEL_SERIES, out, &status );
    +       append_title( in, "TITLE", "SUBTITLE", "%S", LEVEL_SERIES, out, &status );
        }
    
        append_year    ( in, out, &status );
    diff -Naur ./lib/isiout.c /home/matt/bibutils_6.10/lib/isiout.c
    --- ./lib/isiout.c  2020-06-29 11:27:30.680817697 -0400
    +++ /home/matt/bibutils_6.10/lib/isiout.c   2020-03-23 14:53:54.000000000 -0400
    @@ -120,16 +120,15 @@
     }
    
     static void
    -append_titlecore( fields *in, char *isitag, int level, char *nonsorttag, char *maintag, char *subtag, fields *out, int *status )
    +append_titlecore( fields *in, char *isitag, int level, char *maintag, char *subtag, fields *out, int *status )
     {
    -   str *nonsortttl = fields_findv( in, level, FIELDS_STRP, nonsorttag);
        str *mainttl = fields_findv( in, level, FIELDS_STRP, maintag );
        str *subttl  = fields_findv( in, level, FIELDS_STRP, subtag );
        str fullttl;
        int fstatus;
    
        str_init( &fullttl );
    -   title_combine( &fullttl, nonsortttl, mainttl, subttl );
    +   title_combine( &fullttl, mainttl, subttl );
    
        if ( str_memerr( &fullttl ) ) {
            *status = BIBL_ERR_MEMERR;
    @@ -147,13 +146,13 @@
     static void
     append_title( fields *in, char *isitag, int level, fields *out, int *status )
     {
    -   append_titlecore( in, isitag, level, "NONSORT", "TITLE", "SUBTITLE", out, status );
    +   append_titlecore( in, isitag, level, "TITLE", "SUBTITLE", out, status );
     }
    
     static void
     append_abbrtitle( fields *in, char *isitag, int level, fields *out, int *status )
     {
    -   append_titlecore( in, isitag, level, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", out, status );
    +   append_titlecore( in, isitag, level, "SHORTTITLE", "SHORTSUBTITLE", out, status );
     }
    
     static void
    diff -Naur ./lib/modsin.c /home/matt/bibutils_6.10/lib/modsin.c
    --- ./lib/modsin.c  2020-06-29 11:01:40.737458080 -0400
    +++ /home/matt/bibutils_6.10/lib/modsin.c   2020-03-23 14:53:54.000000000 -0400
    @@ -235,14 +235,10 @@
     }
    
     static int
    -modsin_titler( xml *node, str *nonsort, str *title, str *subtitle )
    +modsin_titler( xml *node, str *title, str *subtitle )
     {
        int status = BIBL_OK;
    -
    -  if ( xml_tag_matches_has_value( node, "nonSort" ) ) {
    -    str_strcat(nonsort, xml_value( node ) );
    -       if ( str_memerr( nonsort ) ) return BIBL_ERR_MEMERR;
    -  } else if ( xml_tag_matches_has_value( node, "title" ) ) {
    +   if ( xml_tag_matches_has_value( node, "title" ) ) {
            if ( str_has_value( title ) ) str_strcatc( title, " : " );
            str_strcat( title, xml_value( node ) );
            if ( str_memerr( title ) ) return BIBL_ERR_MEMERR;
    @@ -251,53 +247,47 @@
            if ( str_memerr( subtitle ) ) return BIBL_ERR_MEMERR;
        }
        if ( node->down ) {
    -       status = modsin_titler( node->down, nonsort, title, subtitle );
    +       status = modsin_titler( node->down, title, subtitle );
            if ( status!=BIBL_OK ) return status;
        }
        if ( node->next )
    -       status = modsin_titler( node->next, nonsort, title, subtitle );
    +       status = modsin_titler( node->next, title, subtitle );
        return status;
     }
    
     static int
     modsin_title( xml *node, fields *info, int level )
     {
    -   char *titletag[3][2] = {
    -       { "NONSORT", "SHORTNONSORT" },
    +   char *titletag[2][2] = {
            { "TITLE",    "SHORTTITLE" },
            { "SUBTITLE", "SHORTSUBTITLE" },
        };
        int fstatus, status = BIBL_OK;
    -   str nonsort, title, subtitle;
    +   str title, subtitle;
        xml *dnode;
        int abbr;
    
        dnode = node->down;
        if ( !dnode ) return status;
    
    -   strs_init( &nonsort, &title, &subtitle, NULL );
    +   strs_init( &title, &subtitle, NULL );
        abbr = xml_tag_has_attribute( node, "titleInfo", "type", "abbreviated" );
    
    -   status = modsin_titler( dnode, &nonsort, &title, &subtitle );
    +   status = modsin_titler( dnode, &title, &subtitle );
        if ( status!=BIBL_OK ) goto out;
    
    -  if (str_has_value ( &nonsort ) ) {
    -       fstatus = fields_add( info, titletag[0][abbr], str_cstr( &nonsort), level );
    -       if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; }
    -  }
    -
        if ( str_has_value( &title ) ) {
    -       fstatus = fields_add( info, titletag[1][abbr], str_cstr( &title ), level );
    +       fstatus = fields_add( info, titletag[0][abbr], str_cstr( &title ), level );
            if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; }
        }
    
        if ( str_has_value( &subtitle ) ) {
    -       fstatus = fields_add( info, titletag[2][abbr], str_cstr( &subtitle ), level );
    +       fstatus = fields_add( info, titletag[1][abbr], str_cstr( &subtitle ), level );
            if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; }
        }
    
     out:
    -   strs_free( &nonsort, &title, &subtitle, NULL );
    +   strs_free( &title, &subtitle, NULL );
        return status;
     }
    
    diff -Naur ./lib/nbibout.c /home/matt/bibutils_6.10/lib/nbibout.c
    --- ./lib/nbibout.c 2020-06-29 11:17:56.394141251 -0400
    +++ /home/matt/bibutils_6.10/lib/nbibout.c  2020-03-23 14:53:54.000000000 -0400
    @@ -110,16 +110,15 @@
     }
    
     static void
    -append_titlecore( fields *in, char *nbibtag, int level, char *nonsorttag, char *maintag, char *subtag, fields *out, int *status )
    +append_titlecore( fields *in, char *nbibtag, int level, char *maintag, char *subtag, fields *out, int *status )
     {
    -  str *nonsrtttl = fields_findv(in, level, FIELDS_STRP, nonsorttag);
        str *mainttl = fields_findv( in, level, FIELDS_STRP, maintag );
        str *subttl  = fields_findv( in, level, FIELDS_STRP, subtag );
        str fullttl;
        int fstatus;
    
        str_init( &fullttl );
    -   title_combine( &fullttl, nonsrtttl, mainttl, subttl );
    +   title_combine( &fullttl, mainttl, subttl );
    
        if ( str_memerr( &fullttl ) ) {
            *status = BIBL_ERR_MEMERR;
    @@ -137,13 +136,13 @@
     static void
     append_title( fields *in, char *nbibtag, int level, fields *out, int *status )
     {
    -   append_titlecore( in, nbibtag, level, "NONSORT", "TITLE", "SUBTITLE", out, status );
    +   append_titlecore( in, nbibtag, level, "TITLE", "SUBTITLE", out, status );
     }
    
     static void
     append_abbrtitle( fields *in, char *nbibtag, int level, fields *out, int *status )
     {
    -   append_titlecore( in, nbibtag, level, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", out, status );
    +   append_titlecore( in, nbibtag, level, "SHORTTITLE", "SHORTSUBTITLE", out, status );
     }
    
     static void
    diff -Naur ./lib/risout.c /home/matt/bibutils_6.10/lib/risout.c
    --- ./lib/risout.c  2020-06-29 11:15:08.274138408 -0400
    +++ /home/matt/bibutils_6.10/lib/risout.c   2020-03-23 14:53:54.000000000 -0400
    @@ -431,9 +431,8 @@
     }
    
     static void
    -append_titlecore( fields *in, char *ristag, int level, char *nonsorttag, char *maintag, char *subtag, fields *out, int *status )
    +append_titlecore( fields *in, char *ristag, int level, char *maintag, char *subtag, fields *out, int *status )
     {
    -  str *nonsortttl = fields_findv(in, level, FIELDS_STRP, nonsorttag);
        str *mainttl = fields_findv( in, level, FIELDS_STRP, maintag );
        str *subttl  = fields_findv( in, level, FIELDS_STRP, subtag );
        str fullttl;
    @@ -441,7 +440,7 @@
    
        str_init( &fullttl );
    
    -   title_combine( &fullttl, nonsortttl, mainttl, subttl );
    +   title_combine( &fullttl, mainttl, subttl );
    
        if ( str_memerr( &fullttl ) ) {
            *status = BIBL_ERR_MEMERR;
    @@ -460,15 +459,15 @@
     static void
     append_alltitles( fields *in, int type, fields *out, int *status )
     {
    -   append_titlecore( in, "TI", 0, "NONSORT", "TITLE", "SUBTITLE", out, status );
    -   append_titlecore( in, "T2", -1, "SHORTNONSORT", "SHORTTITLE", "SHORTSUBTITLE", out, status );
    +   append_titlecore( in, "TI", 0, "TITLE", "SUBTITLE", out, status );
    +   append_titlecore( in, "T2", -1, "SHORTTITLE", "SHORTSUBTITLE", out, status );
        if ( type_is_element[ type ] ) {
            if ( type_uses_journal[ type ] )
    -           append_titlecore( in, "JO", 1, "NONSORT", "TITLE", "SUBTITLE", out, status );
    -       else append_titlecore( in, "BT", 1, "NONSORT", "TITLE", "SUBTITLE", out, status );
    -       append_titlecore( in, "T3", 2, "NONSORT", "TITLE", "SUBTITLE", out, status );
    +           append_titlecore( in, "JO", 1, "TITLE", "SUBTITLE", out, status );
    +       else append_titlecore( in, "BT", 1, "TITLE", "SUBTITLE", out, status );
    +       append_titlecore( in, "T3", 2, "TITLE", "SUBTITLE", out, status );
        } else {
    -       append_titlecore( in, "T3", 1, "NONSORT", "TITLE", "SUBTITLE", out, status );
    +       append_titlecore( in, "T3", 1, "TITLE", "SUBTITLE", out, status );
        }
     }
    
    diff -Naur ./lib/title.c /home/matt/bibutils_6.10/lib/title.c
    --- ./lib/title.c   2020-06-29 11:52:00.204175843 -0400
    +++ /home/matt/bibutils_6.10/lib/title.c    2020-03-23 14:53:54.000000000 -0400
    @@ -67,7 +67,7 @@
    
     /* title_combine()
      *
    - * Combine a non sort, main title and a subtitle into a full title.
    + * Combine a main title and a subtitle into a full title.
      *
      * Example:
      *     Main title = "A Clearing in the Distance"
    @@ -77,28 +77,15 @@
      * Main title = "What Makes a Good Team Player?"
      * Subtitle   = "Personality and Team Effectiveness"
      * Full title = "What Makes a Good Team Player? Personality and Team Effectiveness"
    - * Example:
    - *  Nonsort  =  "The "
    - *  Title    =  "Nuer"
    - *  Subtitle = "a description of the modes of livelihood and political institutions of a Nilotic people"
    - *  Full title = "The Nuer: a description of the modes of livelihood and political institutions of a Nilotic people"
    -
    - *
      */
     void
    -title_combine( str *fullttl, str *nonsortttl, str *mainttl, str *subttl )
    +title_combine( str *fullttl, str *mainttl, str *subttl )
     {
        str_empty( fullttl );
    
        if ( !mainttl ) return;
    
    -  if ( nonsortttl ) { // a nonsort precedes the main title
    -    str_strcpy( fullttl, nonsortttl);
    -    str_strcat( fullttl, mainttl );
    -  } else {
    -    str_strcpy( fullttl, mainttl );
    -  }
    -
    +   str_strcpy( fullttl, mainttl );
    
        if ( subttl ) {
            if ( str_has_value( mainttl ) ) {
    diff -Naur ./lib/title.h /home/matt/bibutils_6.10/lib/title.h
    --- ./lib/title.h   2020-06-29 11:11:48.894135046 -0400
    +++ /home/matt/bibutils_6.10/lib/title.h    2020-03-23 14:53:54.000000000 -0400
    @@ -15,6 +15,6 @@
     #include "fields.h"
    
     int  title_process( fields *info, const char *tag, const char *value, int level, unsigned char nosplittitle );
    -void title_combine( str *fullttl, str *nonsortttl, str *mainttl, str *subttl );
    +void title_combine( str *fullttl, str *mainttl, str *subttl );
    
     #endif
    diff -Naur ./lib/wordout.c /home/matt/bibutils_6.10/lib/wordout.c
    --- ./lib/wordout.c 2020-06-29 12:00:29.834184403 -0400
    +++ /home/matt/bibutils_6.10/lib/wordout.c  2020-03-23 14:53:54.000000000 -0400
    @@ -294,10 +294,9 @@
     }
    
     static void
    -output_titlebits( const char *nonsortttl, const char *mainttl, const char *subttl, FILE *outptr )
    +output_titlebits( const char *mainttl, const char *subttl, FILE *outptr )
     {
    -  if ( nonsortttl ) fprintf( outptr, "%s", nonsortttl);
    -   if ( mainttl )    fprintf( outptr, "%s", mainttl );
    +   if ( mainttl ) fprintf( outptr, "%s", mainttl );
        if ( subttl ) {
            if ( mainttl ) {
                if ( mainttl[ strlen( mainttl ) - 1 ] != '?' )
    @@ -309,11 +308,11 @@
     }
    
     static void
    -output_titleinfo( const char *nonsortttl, const char *mainttl, const char *subttl, FILE *outptr, const char *tag, int level )
    +output_titleinfo( const char *mainttl, const char *subttl, FILE *outptr, const char *tag, int level )
     {
        if ( mainttl || subttl ) {
            fprintf( outptr, "<%s>", tag );
    -       output_titlebits( nonsortttl, mainttl, subttl, outptr );
    +       output_titlebits( mainttl, subttl, outptr );
            fprintf( outptr, "</%s>\n", tag );
        }
     }
    @@ -321,45 +320,41 @@
     static void
     output_generaltitle( fields *info, FILE *outptr, const char *tag, int level )
     {
    -  const char *nsrt      = fields_findv( info, level, FIELDS_CHRP, "NONSORT" ); 
    -  const char *shrtnsrt  = fields_findv( info, level, FIELDS_CHRP, "SHORTNONSORT" );
        const char *ttl       = fields_findv( info, level, FIELDS_CHRP, "TITLE" );
        const char *subttl    = fields_findv( info, level, FIELDS_CHRP, "SUBTITLE" );
        const char *shrttl    = fields_findv( info, level, FIELDS_CHRP, "SHORTTITLE" );
        const char *shrsubttl = fields_findv( info, level, FIELDS_CHRP, "SHORTSUBTITLE" );
    
        if ( ttl ) {
    -       output_titleinfo( nsrt, ttl, subttl, outptr, tag, level );
    +       output_titleinfo( ttl, subttl, outptr, tag, level );
        }
        else if ( shrttl ) {
    -       output_titleinfo( shrtnsrt, shrttl, shrsubttl, outptr, tag, level );
    +       output_titleinfo( shrttl, shrsubttl, outptr, tag, level );
        }
     }
    
     static void
     output_maintitle( fields *info, FILE *outptr, int level )
     {
    -  const char *nsrt      = fields_findv( info, level, FIELDS_CHRP, "NONSORT" ); 
    -  const char *shrtnsrt  = fields_findv( info, level, FIELDS_CHRP, "SHORTNONSORT" );
        const char *ttl       = fields_findv( info, level, FIELDS_CHRP, "TITLE" );
        const char *subttl    = fields_findv( info, level, FIELDS_CHRP, "SUBTITLE" );
        const char *shrttl    = fields_findv( info, level, FIELDS_CHRP, "SHORTTITLE" );
        const char *shrsubttl = fields_findv( info, level, FIELDS_CHRP, "SHORTSUBTITLE" );
    
        if ( ttl ) {
    -       output_titleinfo( nsrt, ttl, subttl, outptr, "b:Title", level );
    +       output_titleinfo( ttl, subttl, outptr, "b:Title", level );
    
            /* output shorttitle if it's different from normal title */
            if ( shrttl ) {
                if ( !ttl || ( strcmp( shrttl, ttl ) || subttl ) ) {
                    fprintf( outptr,  " <b:ShortTitle>" );
    -               output_titlebits( shrtnsrt, shrttl, shrsubttl, outptr );
    +               output_titlebits( shrttl, shrsubttl, outptr );
                    fprintf( outptr, "</b:ShortTitle>\n" );
                }
            }
        }
        else if ( shrttl ) {
    -       output_titleinfo( shrtnsrt, shrttl, shrsubttl, outptr, "b:Title", level );
    +       output_titleinfo( shrttl, shrsubttl, outptr, "b:Title", level );
        }
     }
    
     
  • Chris Putnam

    Chris Putnam - 2020-07-01

    This is a fine way to get patches to me. And your modifications look really good in general.

    So I've never seen a MODS file with a nonSort tag in the title. (I'd love to see an example.)

    Based on the way you've written this patch, you are maintaining nonSort titles as a separate entity and it looks like it's just a special form of a title prefix.

    If this is correct, I think the one change I'll make to your patch is to call the nonSort internally a "title prefix", which is the more general concept and reduces the "leakage" of MODS-specific things into the rest of the code.

    One thing that I noticed in the output: it appears that no whitespace is added between the nonSort title and the main title. Is this correct? Should whitespace be added if the last character of the nonSort title isn't whitespace? Again, I don't have any nonSort examples.

    Thanks for all of your effort on this.

    Chris.

    P.S. I'll put this in the queue for the next release, but I have a bit of churn that's currently going on that needs to get finished first.

     
  • matt

    matt - 2020-07-01

    Hi Chris,

    Thanks for your feedback. I'll adress your comments below inline :)

    So I've never seen a MODS file with a nonSort tag in the title. (I'd love to see an example.)

    https://lccn.loc.gov/a40003181/mods

    Based on the way you've written this patch, you are maintaining nonSort titles as a separate entity and it looks like it's just a special form of a title prefix.

    Essentially my understanding as well. They are used to as a control of sorts, and are designed to be ignored in the sort process. You may be interested in the documentation on the nonSort element [1]

    If this is correct, I think the one change I'll make to your patch is to call the nonSort internally a "title prefix", which is the more general concept and reduces the "leakage" of MODS-specific things into the rest of the code.

    Fair enough.

    One thing that I noticed in the output: it appears that no whitespace is added between the nonSort title and the main title. Is this correct? Should whitespace be added if the last character of the nonSort title isn't whitespace? Again, I don't have any nonSort examples.

    Yes this is accurate and to spec. [1] You do not want to add whitespaces between the two.

    specifically:

    Punctuation may or may not be included within the non-sort value depending upon whether it is part of the sorting or non-sorting data. For instance, "The" as an initial article is input with space following the characters, while other data might not require a space (e.g. "L'").

    <nonSort>The </nonSort><title>Trial</title>
    <nonSort>L'</nonSort><title>Enfant</title>

    I'll put this in the queue for the next release, but I have a bit of churn that's currently going on that needs to get finished first.

    Thanks, no rush. I appreciate it.

    I should note that the userguide I linked to has other parts included in the title. For example, <partNumber> and <partName>. The documentation includes examples of each. This can be left as a todo, but our records do not make use of these tags. Additionally, this will only work for xml2* and not anything to xml. So RIS to MODS for example will not attempt to parse the title in such a way as to create the nonSort element.

    Best,
    Matt

    [1] - https://www.loc.gov/standards/mods/userguide/titleinfo.html#nonSort

     

Log in to post a comment.