From 54d86198eef7cbcaa17547d78d429ddc0abd03bf Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 23 Apr 2005 16:31:54 +0000 Subject: [PATCH] Fixed bug #282: xml tag named 'var'. Also made the grs.sgml filter ignore sections so they are not treated as regular elements. --- data1/d1_read.c | 54 +++++++++++++++++++++++++++++++++++++++-------------- data1/d1_varset.c | 4 ++-- include/data1.h | 9 +++------ 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/data1/d1_read.c b/data1/d1_read.c index fa7f241..3f87878 100644 --- a/data1/d1_read.c +++ b/data1/d1_read.c @@ -1,4 +1,4 @@ -/* $Id: d1_read.c,v 1.8.2.1 2005-01-17 22:12:51 adam Exp $ +/* $Id: d1_read.c,v 1.8.2.2 2005-04-23 16:31:54 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -692,8 +692,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, { data1_xattr *xattr; - char tag[64]; - char args[256]; + char tag[256]; int null_tag = 0; int end_tag = 0; size_t i = 0; @@ -704,6 +703,33 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, end_tag = 1; c = ampr (get_byte, fh, &); } + else if (amp == 0 && c == '?') + { + int quote_mode = 0; + while ((c = ampr(get_byte, fh, &))) + { + if (amp) + continue; + if (quote_mode == 0) + { + if (c == '"') + quote_mode = c; + else if (c == '\'') + quote_mode = c; + else if (c == '>') + { + c = ampr(get_byte, fh, &); + break; + } + } + else + { + if (amp == 0 && c == quote_mode) + quote_mode = 0; + } + } + continue; + } else if (amp == 0 && c == '!') { int c0, amp0; @@ -771,7 +797,6 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, } tag[i] = '\0'; xattr = data1_read_xattr (dh, m, get_byte, fh, wrbuf, &c, &); - args[0] = '\0'; if (amp == 0 && c == '/') { /* or */ null_tag = 1; @@ -824,17 +849,18 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, } continue; } - else if (!strcmp(tag, "var")) + else if (!strcmp(tag, "var") + && xattr && xattr->next && xattr->next->next + && xattr->value == 0 + && xattr->next->value == 0 + && xattr->next->next->value == 0) { - char tclass[DATA1_MAX_SYMBOL], type[DATA1_MAX_SYMBOL]; + /* */ + const char *tclass = xattr->name; + const char *type = xattr->next->name; + const char *value = xattr->next->name; data1_vartype *tp; - int val_offset; - - if (sscanf(args, "%s %s %n", tclass, type, &val_offset) != 2) - { - yaz_log(LOG_WARN, "Malformed variant triple at '%s'", tag); - continue; - } + if (!(tp = data1_getvartypebyct(dh, parent->root->u.root.absyn->varset, @@ -864,7 +890,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, res = data1_mk_node2 (dh, m, DATA1N_variant, parent); res->u.variant.type = tp; res->u.variant.value = - data1_insert_string (dh, res, m, args + val_offset); + data1_insert_string (dh, res, m, value); } } else diff --git a/data1/d1_varset.c b/data1/d1_varset.c index 4369cd8..642ecc6 100644 --- a/data1/d1_varset.c +++ b/data1/d1_varset.c @@ -1,4 +1,4 @@ -/* $Id: d1_varset.c,v 1.2 2002-10-22 13:19:50 adam Exp $ +/* $Id: d1_varset.c,v 1.2.2.1 2005-04-23 16:31:54 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -28,7 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include data1_vartype *data1_getvartypebyct (data1_handle dh, data1_varset *set, - char *zclass, char *type) + const char *zclass, const char *type) { data1_varclass *c; data1_vartype *t; diff --git a/include/data1.h b/include/data1.h index 0e335db..af72db7 100644 --- a/include/data1.h +++ b/include/data1.h @@ -1,4 +1,4 @@ -/* $Id: data1.h,v 1.10 2004-08-04 08:35:23 adam Exp $ +/* $Id: data1.h,v 1.9.2.1 2005-04-23 16:31:55 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -31,7 +31,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include -#include #include #include #include @@ -360,7 +359,8 @@ YAZ_EXPORT data1_datatype data1_maptype(data1_handle dh, char *t); YAZ_EXPORT data1_varset *data1_read_varset(data1_handle dh, const char *file); YAZ_EXPORT data1_vartype *data1_getvartypebyct(data1_handle dh, data1_varset *set, - char *zclass, char *type); + const char *zclass, + const char *type); YAZ_EXPORT Z_Espec1 *data1_read_espec1(data1_handle dh, const char *file); YAZ_EXPORT int data1_doespec1(data1_handle dh, data1_node *n, Z_Espec1 *e); YAZ_EXPORT data1_esetname *data1_getesetbyname(data1_handle dh, @@ -424,9 +424,6 @@ YAZ_EXPORT data1_node *data1_mk_root (data1_handle dh, NMEM nmem, YAZ_EXPORT void data1_set_root(data1_handle dh, data1_node *res, NMEM nmem, const char *name); -YAZ_EXPORT data1_node *data1_mk_tag_data_zint (data1_handle dh, data1_node *at, - const char *tag, zint num, - NMEM nmem); YAZ_EXPORT data1_node *data1_mk_tag_data_int (data1_handle dh, data1_node *at, const char *tag, int num, NMEM nmem); -- 1.7.10.4