X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcclptree.c;h=3ceb4871829c87fc557f04103af60c1cbe9298d7;hp=d53345b620cf467553bfa94363cd137e10223bd4;hb=2715f6522ca62ab5dbc886c21ed18945743216f0;hpb=65371f5d5f265a4c5ee43f784b2d8a6db1e0774a diff --git a/src/cclptree.c b/src/cclptree.c index d53345b..3ceb487 100644 --- a/src/cclptree.c +++ b/src/cclptree.c @@ -1,8 +1,6 @@ -/* - * Copyright (C) 1995-2008, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. - * - * $Id: cclptree.c,v 1.11 2008-01-09 21:32:27 adam Exp $ */ /** * \file cclptree.c @@ -11,11 +9,15 @@ * This source file implements functions to parse and print * a CCL node tree (as a result of parsing). */ +#if HAVE_CONFIG_H +#include +#endif #include #include -#include +#include +#include #include static void ccl_pquery_indent(WRBUF w, struct ccl_rpn_node *p, int indent); @@ -43,7 +45,7 @@ static void ccl_pquery_complex(WRBUF w, struct ccl_rpn_node *p, int indent) if (*cp == '!') { /* word order specified */ - if (isdigit(((const unsigned char *) cp)[1])) + if (yaz_isdigit(cp[1])) wrbuf_printf(w, "@prox 0 %s 1 2 k 2", cp+1); else wrbuf_printf(w, "@prox 0 1 1 2 k 2"); @@ -51,7 +53,7 @@ static void ccl_pquery_complex(WRBUF w, struct ccl_rpn_node *p, int indent) else if (*cp == '%') { /* word order not specified */ - if (isdigit(((const unsigned char *) cp)[1])) + if (yaz_isdigit(cp[1])) wrbuf_printf(w, "@prox 0 %s 0 2 k 2", cp+1); else wrbuf_printf(w, "@prox 0 1 0 2 k 2"); @@ -70,19 +72,7 @@ static void ccl_pquery_complex(WRBUF w, struct ccl_rpn_node *p, int indent) static void ccl_prterm(WRBUF w, const char *term) { - if (!*term) - wrbuf_puts(w, "\"\""); - else - { - const char *cp = term; - for (; *cp; cp++) - { - if (*cp == ' ' || *cp == '\\') - wrbuf_putc(w, '\\'); - wrbuf_putc(w, *cp); - } - } - wrbuf_puts(w, " "); + yaz_encode_pqf_term(w, term, strlen(term)); } static void ccl_pquery_indent(WRBUF w, struct ccl_rpn_node *p, int indent) @@ -160,6 +150,7 @@ void ccl_pr_tree(struct ccl_rpn_node *rpn, FILE *fd_out) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab