From: Adam Dickmeiss Date: Thu, 26 Sep 2013 11:00:07 +0000 (+0200) Subject: Better check of marc leader info YAZ-691 X-Git-Tag: v4.2.69~9 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=a6a0761adac3b5760765ee90c0146edf59f9f3ec Better check of marc leader info YAZ-691 Problem is that some systems generate MARCXML/MarcXchange with funny headers. These will not work if encoded as ISO2709. Some tests produce new output, due to updated warning messages about leader content. --- diff --git a/src/marcdisp.c b/src/marcdisp.c index ff4c97e..12ecb38 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -371,53 +371,48 @@ void yaz_marc_set_leader(yaz_marc_t mt, const char *leader_c, check_ascii(mt, leader, 7, 'a'); check_ascii(mt, leader, 8, '#'); check_ascii(mt, leader, 9, '#'); - if (!atoi_n_check(leader+10, 1, indicator_length)) + if (!atoi_n_check(leader+10, 1, indicator_length) || *indicator_length == 0) { - yaz_marc_cprintf(mt, - "Indicator length at offset 10 should hold a digit." - " Assuming 2"); + yaz_marc_cprintf(mt, "Indicator length at offset 10 should" + " hold a number 1-9. Assuming 2"); leader[10] = '2'; *indicator_length = 2; } - if (!atoi_n_check(leader+11, 1, identifier_length)) + if (!atoi_n_check(leader+11, 1, identifier_length) || *identifier_length == 0) { - yaz_marc_cprintf(mt, - "Identifier length at offset 11 should hold a digit." - " Assuming 2"); + yaz_marc_cprintf(mt, "Identifier length at offset 11 should " + " hold a number 1-9. Assuming 2"); leader[11] = '2'; *identifier_length = 2; } if (!atoi_n_check(leader+12, 5, base_address)) { - yaz_marc_cprintf(mt, - "Base address at offsets 12..16 should hold a number." - " Assuming 0"); + yaz_marc_cprintf(mt, "Base address at offsets 12..16 should" + " hold a number. Assuming 0"); *base_address = 0; } check_ascii(mt, leader, 17, '#'); check_ascii(mt, leader, 18, '#'); check_ascii(mt, leader, 19, '#'); - if (!atoi_n_check(leader+20, 1, length_data_entry)) + if (!atoi_n_check(leader+20, 1, length_data_entry) || + *length_data_entry < 3) { - yaz_marc_cprintf(mt, - "Length data entry at offset 20 should hold a digit." - " Assuming 4"); + yaz_marc_cprintf(mt, "Length data entry at offset 20 should" + " hold a number 3-9. Assuming 4"); *length_data_entry = 4; leader[20] = '4'; } - if (!atoi_n_check(leader+21, 1, length_starting)) + if (!atoi_n_check(leader+21, 1, length_starting) || *length_starting < 4) { - yaz_marc_cprintf(mt, - "Length starting at offset 21 should hold a digit." - " Assuming 5"); + yaz_marc_cprintf(mt, "Length starting at offset 21 should" + " hold a number 4-9. Assuming 5"); *length_starting = 5; leader[21] = '5'; } if (!atoi_n_check(leader+22, 1, length_implementation)) { - yaz_marc_cprintf(mt, - "Length implementation at offset 22 should hold a digit." - " Assuming 0"); + yaz_marc_cprintf(mt, "Length implementation at offset 22 should" + " hold a number. Assuming 0"); *length_implementation = 0; leader[22] = '0'; } diff --git a/test/marc1.xml b/test/marc1.xml index 3d0cfaf..8d6759b 100644 --- a/test/marc1.xml +++ b/test/marc1.xml @@ -1,6 +1,6 @@ - + 00988nam0a32003011 450 9 181 423 4 diff --git a/test/marc2.xml b/test/marc2.xml index b665385..29f87c4 100644 --- a/test/marc2.xml +++ b/test/marc2.xml @@ -1,6 +1,6 @@ - + 01116nam0a32002171 450 9 182 502 3 diff --git a/test/marc3.xml b/test/marc3.xml index 2784431..2a22aae 100644 --- a/test/marc3.xml +++ b/test/marc3.xml @@ -1,6 +1,6 @@ - + 00914naa a2200337 450 a00001508 diff --git a/test/marc4.xml b/test/marc4.xml index 331553f..3d96bf5 100644 --- a/test/marc4.xml +++ b/test/marc4.xml @@ -1,9 +1,9 @@ - - + + - + 009140091a22a 22003370 diff --git a/test/tmarc1.xml b/test/tmarc1.xml index dab3674..ff98d78 100644 --- a/test/tmarc1.xml +++ b/test/tmarc1.xml @@ -1,6 +1,6 @@ - + 00988nam0a32003011 450 9 181 423 4 diff --git a/test/tmarc2.xml b/test/tmarc2.xml index 8f28780..69f11ba 100644 --- a/test/tmarc2.xml +++ b/test/tmarc2.xml @@ -1,6 +1,6 @@ - + 01116nam0a32002171 450 9 182 502 3 diff --git a/test/tmarc3.xml b/test/tmarc3.xml index 84f8bbe..3463449 100644 --- a/test/tmarc3.xml +++ b/test/tmarc3.xml @@ -1,6 +1,6 @@ - + 00914naa a2200337 450 a00001508 diff --git a/test/tmarc4.xml b/test/tmarc4.xml index dadbd7b..49034eb 100644 --- a/test/tmarc4.xml +++ b/test/tmarc4.xml @@ -1,9 +1,9 @@ - - + + - + 009140091a22a 22003370 diff --git a/test/xml2marc1.xml b/test/xml2marc1.xml index b355e9f..10abc18 100644 --- a/test/xml2marc1.xml +++ b/test/xml2marc1.xml @@ -1,2 +1,2 @@ -00988nam0a32003011 450 9 181 423 4710100anemu2002useng0axx1-4000-4596-7$14,00DBC200439SlomanLarryOn the road with Bob DylanLarry "Ratso" SlomanRevised editionThree Rivers PressNew YorkThree Rivers Press2002xv, 464 sider, tavlerLarry "Ratso" Slomans meget personlige beretning om Bob Dylans koncertturne i USA i 1975: "The Rolling Thunder revue"På omslaget: With a new introduction by Kinky FriedmanTidligere: 1. udgave. New York, Bantam, 197899.4DylanBob78.90645folkemusikfolkemusikererockmusikrockmusikererockkoncerterUSA1970-1979 +00988nam0a32003011 450 9 181 423 4710100anemu2002useng0axx1-4000-4596-7$14,00DBC200439SlomanLarryOn the road with Bob DylanLarry "Ratso" SlomanRevised editionThree Rivers PressNew YorkThree Rivers Press2002xv, 464 sider, tavlerLarry "Ratso" Slomans meget personlige beretning om Bob Dylans koncertturne i USA i 1975: "The Rolling Thunder revue"På omslaget: With a new introduction by Kinky FriedmanTidligere: 1. udgave. New York, Bantam, 197899.4DylanBob78.90645folkemusikfolkemusikererockmusikrockmusikererockkoncerterUSA1970-1979 diff --git a/test/xml2marc2.xml b/test/xml2marc2.xml index 9252e5c..ea973c4 100644 --- a/test/xml2marc2.xml +++ b/test/xml2marc2.xml @@ -1,2 +1,2 @@ -01116nam0a32002171 450 9 182 502 3710100acesf1995gbeng0sxcbefMimmsGarnetCry babyWarm and soulfulGarnet Mimms ... [et al.]Bury St. EdmundsBGO19951 cdIndspilninger publiceret 1963 (Cry baby) og 1965 (Warm and soulful)Indhold:BGOBGOCD26878.7944soulrhythm & bluesvokal1960-1969USA11Cry babyNobody but youUntil you were goneAnytime you want meSo closeFor your precious loveBaby don't you weepA ¤quiet placeCry to meDon't change your heartWanting youThe ¤truth hurtsI'll take good care of youLooking for youIt won't hurt (half as much)It was easier to hurt herThinkin'Prove it to meMore than a miracleAs long as I have youOne girlThere goes my babyIt's just a matter of timeA ¤little bit of soapLook awayI'll make it up to you4001 girl +01116nam0a32002171 450 9 182 502 3710100acesf1995gbeng0sxcbefMimmsGarnetCry babyWarm and soulfulGarnet Mimms ... [et al.]Bury St. EdmundsBGO19951 cdIndspilninger publiceret 1963 (Cry baby) og 1965 (Warm and soulful)Indhold:BGOBGOCD26878.7944soulrhythm & bluesvokal1960-1969USA11Cry babyNobody but youUntil you were goneAnytime you want meSo closeFor your precious loveBaby don't you weepA ¤quiet placeCry to meDon't change your heartWanting youThe ¤truth hurtsI'll take good care of youLooking for youIt won't hurt (half as much)It was easier to hurt herThinkin'Prove it to meMore than a miracleAs long as I have youOne girlThere goes my babyIt's just a matter of timeA ¤little bit of soapLook awayI'll make it up to you4001 girl diff --git a/test/xml2marc3.xml b/test/xml2marc3.xml index 74de296..5f9e7fa 100644 --- a/test/xml2marc3.xml +++ b/test/xml2marc3.xml @@ -1,2 +1,2 @@ -00914naa a2200337 450 a00001508ain1991xxnora9axxnoreng06Byfornyelse ved Ibsen-RingenfarvefotoplansnitByggekunst19911/241-45byfornyelsesaneringNorgeOsloTelje Torp Aasen ArkitektkontorKristian Augustsgate 7BEng, Dagfinanlund, TomKristian AugustsgatePilestredet 19aITMARK50000014519911/241-4520020111ARK01200220020111ARK01211620021002ARK011000ICLLOAD0020021122ARK01194820030618ARK011330a00001508 +00914naa a2200337 450 a00001508ain1991xxnora9axxnoreng06Byfornyelse ved Ibsen-RingenfarvefotoplansnitByggekunst19911/241-45byfornyelsesaneringNorgeOsloTelje Torp Aasen ArkitektkontorKristian Augustsgate 7BEng, Dagfinanlund, TomKristian AugustsgatePilestredet 19aITMARK50000014519911/241-4520020111ARK01200220020111ARK01211620021002ARK011000ICLLOAD0020021122ARK01194820030618ARK011330a00001508 diff --git a/test/xml2marc4.xml b/test/xml2marc4.xml index 9c5f943..9ba3a75 100644 --- a/test/xml2marc4.xml +++ b/test/xml2marc4.xml @@ -1,2 +1,2 @@ -009140091a22a 22003370 +009140091a22a 22003370 diff --git a/test/xml2tmarc1.xml b/test/xml2tmarc1.xml index f3c388e..b624136 100644 --- a/test/xml2tmarc1.xml +++ b/test/xml2tmarc1.xml @@ -1,2 +1,2 @@ -00988nam0a32003011 450 9 181 423 4710100anemu2002useng0axx1-4000-4596-7$14,00DBC200439SlomanLarryOn the road with Bob DylanLarry "Ratso" SlomanRevised editionThree Rivers PressNew YorkThree Rivers Press2002xv, 464 sider, tavlerLarry "Ratso" Slomans meget personlige beretning om Bob Dylans koncertturne i USA i 1975: "The Rolling Thunder revue"På omslaget: With a new introduction by Kinky FriedmanTidligere: 1. udgave. New York, Bantam, 197899.4DylanBob78.90645folkemusikfolkemusikererockmusikrockmusikererockkoncerterUSA1970-1979 +00988nam0a32003011 450 9 181 423 4710100anemu2002useng0axx1-4000-4596-7$14,00DBC200439SlomanLarryOn the road with Bob DylanLarry "Ratso" SlomanRevised editionThree Rivers PressNew YorkThree Rivers Press2002xv, 464 sider, tavlerLarry "Ratso" Slomans meget personlige beretning om Bob Dylans koncertturne i USA i 1975: "The Rolling Thunder revue"På omslaget: With a new introduction by Kinky FriedmanTidligere: 1. udgave. New York, Bantam, 197899.4DylanBob78.90645folkemusikfolkemusikererockmusikrockmusikererockkoncerterUSA1970-1979 diff --git a/test/xml2tmarc2.xml b/test/xml2tmarc2.xml index c2208fa..c5c7529 100644 --- a/test/xml2tmarc2.xml +++ b/test/xml2tmarc2.xml @@ -1,2 +1,2 @@ -01116nam0a32002171 450 9 182 502 3710100acesf1995gbeng0sxcbefMimmsGarnetCry babyWarm and soulfulGarnet Mimms ... [et al.]Bury St. EdmundsBGO19951 cdIndspilninger publiceret 1963 (Cry baby) og 1965 (Warm and soulful)Indhold:BGOBGOCD26878.7944soulrhythm & bluesvokal1960-1969USA11Cry babyNobody but youUntil you were goneAnytime you want meSo closeFor your precious loveBaby don't you weepA ¤quiet placeCry to meDon't change your heartWanting youThe ¤truth hurtsI'll take good care of youLooking for youIt won't hurt (half as much)It was easier to hurt herThinkin'Prove it to meMore than a miracleAs long as I have youOne girlThere goes my babyIt's just a matter of timeA ¤little bit of soapLook awayI'll make it up to you4001 girl +01116nam0a32002171 450 9 182 502 3710100acesf1995gbeng0sxcbefMimmsGarnetCry babyWarm and soulfulGarnet Mimms ... [et al.]Bury St. EdmundsBGO19951 cdIndspilninger publiceret 1963 (Cry baby) og 1965 (Warm and soulful)Indhold:BGOBGOCD26878.7944soulrhythm & bluesvokal1960-1969USA11Cry babyNobody but youUntil you were goneAnytime you want meSo closeFor your precious loveBaby don't you weepA ¤quiet placeCry to meDon't change your heartWanting youThe ¤truth hurtsI'll take good care of youLooking for youIt won't hurt (half as much)It was easier to hurt herThinkin'Prove it to meMore than a miracleAs long as I have youOne girlThere goes my babyIt's just a matter of timeA ¤little bit of soapLook awayI'll make it up to you4001 girl diff --git a/test/xml2tmarc3.xml b/test/xml2tmarc3.xml index 3d58c9d..bf921c5 100644 --- a/test/xml2tmarc3.xml +++ b/test/xml2tmarc3.xml @@ -1,2 +1,2 @@ -00914naa a2200337 450 a00001508ain1991xxnora9axxnoreng06Byfornyelse ved Ibsen-RingenfarvefotoplansnitByggekunst19911/241-45byfornyelsesaneringNorgeOsloTelje Torp Aasen ArkitektkontorKristian Augustsgate 7BEng, Dagfinanlund, TomKristian AugustsgatePilestredet 19aITMARK50000014519911/241-4520020111ARK01200220020111ARK01211620021002ARK011000ICLLOAD0020021122ARK01194820030618ARK011330a00001508 +00914naa a2200337 450 a00001508ain1991xxnora9axxnoreng06Byfornyelse ved Ibsen-RingenfarvefotoplansnitByggekunst19911/241-45byfornyelsesaneringNorgeOsloTelje Torp Aasen ArkitektkontorKristian Augustsgate 7BEng, Dagfinanlund, TomKristian AugustsgatePilestredet 19aITMARK50000014519911/241-4520020111ARK01200220020111ARK01211620021002ARK011000ICLLOAD0020021122ARK01194820030618ARK011330a00001508 diff --git a/test/xml2tmarc4.xml b/test/xml2tmarc4.xml index bd386e6..68336bf 100644 --- a/test/xml2tmarc4.xml +++ b/test/xml2tmarc4.xml @@ -1,2 +1,2 @@ -009140091a22a 22003370 +009140091a22a 22003370