From 4cdabec84822b8b4f52907b6c69b3aedd199bf5a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 29 Oct 2013 10:52:56 +0100 Subject: [PATCH] query_transform: any size for PQF result + minor refactor --- src/yaz-cql2rpn.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/yaz-cql2rpn.cpp b/src/yaz-cql2rpn.cpp index dfbcd4b..711d49d 100644 --- a/src/yaz-cql2rpn.cpp +++ b/src/yaz-cql2rpn.cpp @@ -7,6 +7,7 @@ #include #endif #include +#include #include #include @@ -50,18 +51,17 @@ int Yaz_cql2rpn::query_transform(const char *cql_query, int r = cql_parser_string(cp, cql_query); if (r) { - r = 10; + r = YAZ_SRW_QUERY_SYNTAX_ERROR; } else { - char rpn_buf[10240]; - r = cql_transform_buf(m_transform, cql_parser_result(cp), - rpn_buf, sizeof(rpn_buf)-1); + WRBUF w = wrbuf_alloc(); + r = cql_transform(m_transform, cql_parser_result(cp), wrbuf_vp_puts, w); if (!r) { YAZ_PQF_Parser pp = yaz_pqf_create(); - *rpnquery = yaz_pqf_parse(pp, o, rpn_buf); + *rpnquery = yaz_pqf_parse(pp, o, wrbuf_cstr(w)); if (!*rpnquery) { size_t off; @@ -75,12 +75,10 @@ int Yaz_cql2rpn::query_transform(const char *cql_query, { r = cql_transform_error(m_transform, &addinfo); } + wrbuf_destroy(w); } cql_parser_destroy(cp); - if (addinfo) - *addinfop = odr_strdup(o, addinfo); - else - *addinfop = 0; + *addinfop = odr_strdup_null(o, addinfo); return r; } /* -- 1.7.10.4