[Refdb-cvs] CVS: refdb/src xmlhandler.c,1.22.2.3,1.22.2.4
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2004-07-26 20:40:12
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27137 Modified Files: Tag: Release_0_9_5_stable xmlhandler.c Log Message: simplified some get_ancestor_attr() to get_attr() calls; fixed segfault if PUBTYPE TYPE is not set;increment ref not found counter Index: xmlhandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/xmlhandler.c,v retrieving revision 1.22.2.3 retrieving revision 1.22.2.4 diff -u -U2 -r1.22.2.3 -r1.22.2.4 --- xmlhandler.c 23 Jul 2004 02:03:56 -0000 1.22.2.3 +++ xmlhandler.c 26 Jul 2004 20:39:56 -0000 1.22.2.4 @@ -124,5 +124,7 @@ if (strcmp(el, "PUBTYPE") == 0) { /* create new entry in database. PUBTYPE has only one attribute TYPE, the value of which is therefore in attr[1], if at all */ - if (ptr_attr[1] && *(ptr_attr[1])) { + /* NB ptr_attr == NULL is not permitted by the DTD but + we better check */ + if (ptr_attr && ptr_attr[1] && *(ptr_attr[1])) { strcat(sql_command, ptr_attr[1]); } @@ -331,5 +333,5 @@ /* first authorlist */ else if (strcmp((ptr_asdata->ptr_first)->elname, "AUTHORLIST") == 0) { - ptr_attr = get_ancestor_attr(ptr_asdata->ptr_first, "AUTHORLIST", "ROLE"); + ptr_attr = get_attr(ptr_asdata->ptr_first, "ROLE"); if (!ptr_attr || strcmp(ptr_attr, "PRIMARY") == 0) { strcpy(concat, "AUTHORLIST"); @@ -362,5 +364,5 @@ /* second pubdate */ else if (strcmp((ptr_asdata->ptr_first)->elname, "PUBDATE") == 0) { - ptr_attr = get_ancestor_attr(ptr_asdata->ptr_first, "PUBDATE", "ROLE"); + ptr_attr = get_attr(ptr_asdata->ptr_first, "ROLE"); if (!ptr_attr || strcmp(ptr_attr, "PRIMARY") == 0) { strcpy(concat, "PUBDATE"); @@ -390,5 +392,5 @@ /* third title */ else if (strcmp((ptr_asdata->ptr_first)->elname, "TITLE") == 0) { - ptr_attr = get_ancestor_attr(ptr_asdata->ptr_first, "TITLE", "ROLE"); + ptr_attr = get_attr(ptr_asdata->ptr_first, "ROLE"); if (!ptr_attr || strcmp(ptr_attr, "PRIMARY") == 0) { strcpy(concat, "TITLE"); @@ -419,5 +421,5 @@ } else if (strcmp((ptr_asdata->ptr_first)->elname, "USERDEF") == 0) { - ptr_attr = get_ancestor_attr(ptr_asdata->ptr_first, "USERDEF", "ROLE"); + ptr_attr = get_attr(ptr_asdata->ptr_first, "ROLE"); if (strcmp(ptr_attr, "1") == 0) { strcpy(concat, "USERDEF1"); @@ -451,5 +453,5 @@ } else if (strcmp((ptr_asdata->ptr_first)->elname, "MISC") == 0) { - ptr_attr = get_ancestor_attr(ptr_asdata->ptr_first, "MISC", "ROLE"); + ptr_attr = get_attr(ptr_asdata->ptr_first, "ROLE"); if (strcmp(ptr_attr, "1") == 0) { strcpy(concat, "MISC1"); @@ -477,5 +479,5 @@ } else if (strcmp((ptr_asdata->ptr_first)->elname, "LINK") == 0) { - ptr_attr = get_ancestor_attr(ptr_asdata->ptr_first, "LINK", "ROLE"); + ptr_attr = get_attr(ptr_asdata->ptr_first, "ROLE"); if (strcmp(ptr_attr, "1") == 0) { strcpy(concat, "LINK1"); @@ -573,5 +575,5 @@ if (is_descendant_of(ptr_asdata->ptr_first, "PUBTYPE")) { - strcpy(pubtype, get_ancestor_attr(ptr_asdata->ptr_first, "PUBTYPE", "TYPE")); + strcpy(pubtype, get_attr(ptr_asdata->ptr_first, "TYPE")); } else if (is_descendant_of(ptr_asdata->ptr_first, "INTEXTDEF")) { @@ -600,5 +602,5 @@ strcpy(table_name, "REFSTYLE"); strcpy(column_name, concat_elnames(ptr_asdata->ptr_first, "PUBTYPE", concat)); - strcpy(pubtype, get_ancestor_attr(ptr_asdata->ptr_first, "PUBTYPE", "TYPE")); + strcpy(pubtype, get_attr(ptr_asdata->ptr_first, "TYPE")); n_chardata = 1; n_attrdata = 1; @@ -661,5 +663,5 @@ strcpy(table_name, "REFSTYLE"); strcpy(column_name, concat_elnames(ptr_asdata->ptr_first, "PUBTYPE", concat)); - strcpy(pubtype, get_ancestor_attr(ptr_asdata->ptr_first, "PUBTYPE", "TYPE")); + strcpy(pubtype, get_attr(ptr_asdata->ptr_first, "TYPE")); } else if (is_descendant_of(ptr_asdata->ptr_first, "INTEXTDEF")) { @@ -697,5 +699,5 @@ if (is_descendant_of(ptr_asdata->ptr_first, "PUBTYPE")) { strcpy(column_name, concat_elnames(ptr_asdata->ptr_first, "PUBTYPE", concat)); - strcpy(pubtype, get_ancestor_attr(ptr_asdata->ptr_first, "PUBTYPE", "TYPE")); + strcpy(pubtype, get_attr(ptr_asdata->ptr_first, "TYPE")); } else if (is_descendant_of(ptr_asdata->ptr_first, "INTEXTDEF")) { @@ -722,5 +724,5 @@ if (is_descendant_of(ptr_asdata->ptr_first, "PUBTYPE")) { strcpy(column_name, concat_elnames(ptr_asdata->ptr_first, "PUBTYPE", concat)); - strcpy(pubtype, get_ancestor_attr(ptr_asdata->ptr_first, "PUBTYPE", "TYPE")); + strcpy(pubtype, get_attr(ptr_asdata->ptr_first, "TYPE")); } else if (is_descendant_of(ptr_asdata->ptr_first, "INTEXTDEF")) { @@ -766,5 +768,5 @@ if (is_descendant_of(ptr_asdata->ptr_first, "PUBTYPE")) { strcpy(column_name, concat_elnames(ptr_asdata->ptr_first, "PUBTYPE", concat)); - strcpy(pubtype, get_ancestor_attr(ptr_asdata->ptr_first, "PUBTYPE", "TYPE")); + strcpy(pubtype, get_attr(ptr_asdata->ptr_first, "TYPE")); } else if (is_descendant_of(ptr_asdata->ptr_first, "INTEXTDEF")) { @@ -1675,4 +1677,9 @@ } } + else { + /* requested ref is not in the database */ + (*(ptr_gbdata->ptr_ndb_notfound))++; + } + free(sql_command); } |