From: Adam Dickmeiss Date: Tue, 29 Oct 2013 09:52:56 +0000 (+0100) Subject: query_transform: any size for PQF result + minor refactor X-Git-Tag: v1.5.1~1^2~1 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=4cdabec84822b8b4f52907b6c69b3aedd199bf5a;p=yazpp-moved-to-github.git query_transform: any size for PQF result + minor refactor --- 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; } /*