From: Adam Dickmeiss Date: Thu, 15 Jan 2004 13:31:30 +0000 (+0000) Subject: X-Path attribute expressions with spaces in them is now handled. X-Git-Tag: ZEBRA.1.3.15~1 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=881b9293d6699c85195142af3f4a957f4982e6e2;p=idzebra-moved-to-github.git X-Path attribute expressions with spaces in them is now handled. --- diff --git a/CHANGELOG b/CHANGELOG index e9061c2..44a3ad5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ +Fix bug. X-Path attribute expressions with spaces in them now works. + Fix base address for MARC output. --- 1.3.14 2003/11/29 diff --git a/include/zebraapi.h b/include/zebraapi.h index 203a73a..b83f79e 100644 --- a/include/zebraapi.h +++ b/include/zebraapi.h @@ -1,4 +1,4 @@ -/* $Id: zebraapi.h,v 1.10 2003-08-21 10:30:04 adam Exp $ +/* $Id: zebraapi.h,v 1.11 2004-01-15 13:31:31 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -141,7 +141,7 @@ YAZ_EXPORT int zebra_search_PQF (ZebraHandle zh, const char *pqf_query, /* Search using RPN Query */ YAZ_EXPORT int zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query, - const char *setname, int *hits); + const char *setname, int *hits); /* Retrieve record(s) */ YAZ_EXPORT int zebra_records_retrieve (ZebraHandle zh, ODR stream, diff --git a/index/zrpn.c b/index/zrpn.c index 6e11e9b..f09278d 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,5 +1,5 @@ -/* $Id: zrpn.c,v 1.134 2003-09-05 10:51:17 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 +/* $Id: zrpn.c,v 1.135 2004-01-15 13:31:31 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -2312,18 +2312,25 @@ static RSET rpn_search_xpath (ZebraHandle zh, xpath[level].predicate->which == XPATH_PREDICATE_RELATION && xpath[level].predicate->u.relation.name[0]) { - char predicate_str[128]; - - strcpy (predicate_str, - xpath[level].predicate->u.relation.name+1); + WRBUF wbuf = wrbuf_alloc(); + wrbuf_puts(wbuf, xpath[level].predicate->u.relation.name+1); if (xpath[level].predicate->u.relation.value) { - strcat (predicate_str, "="); - strcat (predicate_str, - xpath[level].predicate->u.relation.value); + const char *cp = xpath[level].predicate->u.relation.value; + wrbuf_putc(wbuf, '='); + + while (*cp) + { + if (strchr(REGEX_CHARS, *cp)) + wrbuf_putc(wbuf, '\\'); + wrbuf_putc(wbuf, *cp); + cp++; + } } + wrbuf_puts(wbuf, ""); rset_attr = xpath_trunc ( - zh, stream, '0', predicate_str, 3, curAttributeSet); + zh, stream, '0', wrbuf_buf(wbuf), 3, curAttributeSet); + wrbuf_free(wbuf, 1); } else { diff --git a/test/xpath/Makefile.am b/test/xpath/Makefile.am index cd36ae5..194cd31 100644 --- a/test/xpath/Makefile.am +++ b/test/xpath/Makefile.am @@ -1,8 +1,8 @@ -# $Id: Makefile.am,v 1.4 2003-05-21 14:39:23 adam Exp $ +# $Id: Makefile.am,v 1.5 2004-01-15 13:31:31 adam Exp $ -check_SCRIPTS = test1.sh test2.sh test3.sh simple1.sh +check_SCRIPTS = simple1.sh test1.sh test2.sh test3.sh test4.sh TESTS = $(check_SCRIPTS) -EXTRA_DIST = zebra.cfg rec.xml simple1.xml $(check_SCRIPTS) +EXTRA_DIST = zebra.cfg rec.xml simple1.xml rec4.xml $(check_SCRIPTS) diff --git a/test/xpath/rec4.xml b/test/xpath/rec4.xml new file mode 100644 index 0000000..3deac13 --- /dev/null +++ b/test/xpath/rec4.xml @@ -0,0 +1,7 @@ + + + content + content + + content + diff --git a/test/xpath/test4.sh b/test/xpath/test4.sh new file mode 100755 index 0000000..1932565 --- /dev/null +++ b/test/xpath/test4.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# $Id: test4.sh,v 1.1 2004-01-15 13:31:31 adam Exp $ +LOG=test4.log +TMP1=test4-1.tmp +TMP2=test4-2.tmp +TMP3=test4-3.tmp +TMP4=test4-4.tmp +TMP5=test4-5.tmp +rm -f $LOG +rm -f $TMP +../../index/zebraidx -l $LOG init || exit 1 +../../index/zebraidx -l $LOG -t grs.sgml update rec4.xml || exit 2 +test -f dict*.mf || exit 1 +../../index/zebrasrv -l $LOG -S unix:socket & +sleep 1 +test -f zebrasrv.pid || exit 2 +../api/testclient unix:socket '@attr 1=/root content' >$TMP1 +../api/testclient unix:socket '@attr 1=/root/first content' >$TMP2 +../api/testclient unix:socket "@attr {1=/root/first[@attr='danish']} content" >$TMP3 +../api/testclient unix:socket "@attr {1=/root/second[@attr='danish lake']} content" >$TMP4 +../api/testclient unix:socket "@attr {1=/root/third[@attr='dansk sø']} content" >$TMP5 +echo 'Killing server' >>$LOG +kill `cat zebrasrv.pid` || exit 3 +cat $TMP1 $TMP2 $TMP3 $TMP4 $TMP5 >>$LOG +echo 'Checking that result count is 1' >>$LOG +grep "^Result count: 1$" $TMP1 >/dev/null || exit 4 +echo 'Checking that result count is 1' >>$LOG +grep "^Result count: 1$" $TMP2 >/dev/null || exit 5 +echo 'Checking that result count is 1' >>$LOG +grep "^Result count: 1$" $TMP3 >/dev/null || exit 6 +echo 'Checking that result count is 1' >>$LOG +grep "^Result count: 1$" $TMP4 >/dev/null || exit 7 +echo 'Checking that result count is 1' >>$LOG +grep "^Result count: 1$" $TMP5 >/dev/null || exit 8 +echo 'Test OK' >>$LOG +exit 0 +