From 266cfeafc17930bfa6fb7eed92f80b8c751f43b4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 13 Nov 2012 13:45:09 +0100 Subject: [PATCH] rpn2cql: less quotes in generated terms Semantics unchanged, but it's prettier this way. --- src/rpn2cql.c | 12 ++++++-- test/test_rpn2cql.c | 84 +++++++++++++++++++++++++-------------------------- 2 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/rpn2cql.c b/src/rpn2cql.c index c59ca90..25ee138 100644 --- a/src/rpn2cql.c +++ b/src/rpn2cql.c @@ -218,10 +218,17 @@ static int rpn2cql_simple(cql_transform_t ct, if (trunc <= 3 || trunc == 100 || trunc == 102 || trunc == 104) { + int quote_it = 0; for (i = 0 ; i < lterm; i++) if (strchr(" ()=>\"1980\"")); - YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=2 1980", "dc.date<=\"1980\"")); - YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=4 1980", "dc.date>=\"1980\"")); + YAZ_CHECK(compare(ct, "@attr 2=1 @attr 1=30 1980", "dc.date<1980")); + YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=3 1980", "dc.date=1980")); + YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=5 1980", "dc.date>1980")); + YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=2 1980", "dc.date<=1980")); + YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=4 1980", "dc.date>=1980")); /* Truncation */ - YAZ_CHECK(compare(ct, "@attr 5=1 water", "\"water*\"")); - YAZ_CHECK(compare(ct, "@attr 5=2 water", "\"*water\"")); - YAZ_CHECK(compare(ct, "@attr 5=3 water", "\"*water*\"")); - YAZ_CHECK(compare(ct, "@attr 5=100 water", "\"water\"")); - YAZ_CHECK(compare(ct, "@attr 5=102 water", "\"water\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 water", "\"water\"")); - - YAZ_CHECK(compare(ct, "@attr 5=102 wat.*er", "\"wat*er\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 wat?er", "\"wat*er\"")); - - YAZ_CHECK(compare(ct, "@attr 5=102 wat.er", "\"wat?er\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 wat#er", "\"wat?er\"")); - YAZ_CHECK(compare(ct, "@attr 5=102 wat?er", "\"wat\\?er\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 wat*er", "\"wat\\*er\"")); - YAZ_CHECK(compare(ct, "@attr 5=102 wat#er", "\"wat#er\"")); + YAZ_CHECK(compare(ct, "@attr 5=1 water", "water*")); + YAZ_CHECK(compare(ct, "@attr 5=2 water", "*water")); + YAZ_CHECK(compare(ct, "@attr 5=3 water", "*water*")); + YAZ_CHECK(compare(ct, "@attr 5=100 water", "water")); + YAZ_CHECK(compare(ct, "@attr 5=102 water", "water")); + YAZ_CHECK(compare(ct, "@attr 5=104 water", "water")); + + YAZ_CHECK(compare(ct, "@attr 5=102 wat.*er", "wat*er")); + YAZ_CHECK(compare(ct, "@attr 5=104 wat?er", "wat*er")); + + YAZ_CHECK(compare(ct, "@attr 5=102 wat.er", "wat?er")); + YAZ_CHECK(compare(ct, "@attr 5=104 wat#er", "wat?er")); + YAZ_CHECK(compare(ct, "@attr 5=102 wat?er", "wat\\?er")); + YAZ_CHECK(compare(ct, "@attr 5=104 wat*er", "wat\\*er")); + YAZ_CHECK(compare(ct, "@attr 5=102 wat#er", "wat#er")); /* \. is 'eaten' by PQF parser */ - YAZ_CHECK(compare(ct, "@attr 5=102 wat\\.er", "\"wat?er\"")); + YAZ_CHECK(compare(ct, "@attr 5=102 wat\\.er", "wat?er")); /* Escape sequences */ /* note: escape sequences that survive after PQF parse below */ - YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\?er", "\"wat\\?er\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\?er", "\"wat\\?er\"")); + YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\?er", "wat\\?er")); + YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\?er", "wat\\?er")); - YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\*er", "\"wat\\*er\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\*er", "\"wat\\*er\"")); + YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\*er", "wat\\*er")); + YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\*er", "wat\\*er")); - YAZ_CHECK(compare(ct, "wat\\\\#er", "\"wat#er\"")); - YAZ_CHECK(compare(ct, "@attr 5=100 wat\\\\#er", "\"wat#er\"")); - YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\#er", "\"wat#er\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\#er", "\"wat#er\"")); - YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\.er", "\"wat.er\"")); - YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\.er", "\"wat.er\"")); + YAZ_CHECK(compare(ct, "wat\\\\#er", "wat#er")); + YAZ_CHECK(compare(ct, "@attr 5=100 wat\\\\#er", "wat#er")); + YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\#er", "wat#er")); + YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\#er", "wat#er")); + YAZ_CHECK(compare(ct, "@attr 5=102 wat\\\\.er", "wat.er")); + YAZ_CHECK(compare(ct, "@attr 5=104 wat\\\\.er", "wat.er")); /* Quoting */ YAZ_CHECK(compare(ct, "@attr 5=100 \"\"", "\"\"")); @@ -144,7 +144,7 @@ static void tst2(void) YAZ_CHECK(compare(ct, "@attr 5=3 \"water basket\"", "\"*water basket*\"")); /* Other */ - YAZ_CHECK(compare(ct, "@attr 2=103 @attr 1=_ALLRECORDS 1", "cql.allRecords=\"1\"")); + YAZ_CHECK(compare(ct, "@attr 2=103 @attr 1=_ALLRECORDS 1", "cql.allRecords=1")); YAZ_CHECK(compare(ct, "@attr 1=500 abc", 0)); cql_transform_close(ct); wrbuf_destroy(w); -- 1.7.10.4