From ef4825a7e6f74209103a34d79243c1e4f03b2a4b Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 17 Aug 2007 12:31:40 +0000 Subject: [PATCH] String-values attributes are now handled correctly in rpn2perl(), and transcribed into the tree of Perl structures that is set into the search-handler's $args->{RPN}. Previously, all string-values attributes were transcribed as the numeric value 1. --- SimpleServer.xs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/SimpleServer.xs b/SimpleServer.xs index 0275571..da613c2 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -1,5 +1,5 @@ /* - * $Id: SimpleServer.xs,v 1.68 2007-08-16 15:12:58 mike Exp $ + * $Id: SimpleServer.xs,v 1.69 2007-08-17 12:31:40 mike Exp $ * ---------------------------------------------------------------------- * * Copyright (c) 2000-2004, Index Data. @@ -32,6 +32,7 @@ #include "proto.h" #include "embed.h" #include "XSUB.h" +#include #include #include #include @@ -440,9 +441,24 @@ static SV *rpn2perl(Z_RPNStructure *s) translateOID(elem->attributeSet)); setMember(hv2, "attributeType", newSViv(*elem->attributeType)); - assert(elem->which == Z_AttributeValue_numeric); - setMember(hv2, "attributeValue", - newSViv(*elem->value.numeric)); + if (elem->which == Z_AttributeValue_numeric) { + setMember(hv2, "attributeValue", + newSViv(*elem->value.numeric)); + } else { + assert(elem->which == Z_AttributeValue_complex); + Z_ComplexAttribute *complex = elem->value.complex; + Z_StringOrNumeric *son; + /* We ignore semantic actions and multiple values */ + assert(complex->num_list > 0); + son = complex->list[0]; + if (son->which == Z_StringOrNumeric_numeric) { + setMember(hv2, "attributeValue", + newSViv(*son->u.numeric)); + } else { /*Z_StringOrNumeric_string*/ + setMember(hv2, "attributeValue", + newSVpv(son->u.string, 0)); + } + } av_push(av, tmp); } setMember(hv, "attributes", attrs); -- 1.7.10.4