Fix CCL->RPN code for attribute strings.
[yaz-moved-to-github.git] / zutil / yaz-ccl.c
index 45eeb37..8ed2177 100644 (file)
@@ -1,13 +1,14 @@
 /*
- * Copyright (c) 1996-2002, Index Data.
+ * Copyright (c) 1996-2003, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: yaz-ccl.c,v 1.16 2002-12-28 12:13:03 adam Exp $
+ * $Id: yaz-ccl.c,v 1.21 2003-06-23 12:38:39 adam Exp $
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 
 #include <yaz/yaz-ccl.h>
 #include <yaz/pquery.h>
@@ -20,7 +21,6 @@ Z_RPNQuery *ccl_rpn_query (ODR o, struct ccl_rpn_node *p)
 
     ccl_pquery(wr, p);
 
-    printf ("pqf=%s\n", wrbuf_buf(wr));
     q = yaz_pqf_parse(parser, o, wrbuf_buf(wr));
 
     wrbuf_free(wr, 1);
@@ -117,8 +117,18 @@ void ccl_pquery (WRBUF w, struct ccl_rpn_node *p)
                wrbuf_puts (w, att->set);
                wrbuf_puts (w, " ");
            }
-           sprintf(tmpattr, "%d=%d ", att->type, att->value);
-           wrbuf_puts (w, tmpattr);
+           switch(att->kind)
+           {
+           case CCL_RPN_ATTR_NUMERIC:
+               sprintf(tmpattr, "%d=%d ", att->type, att->value.numeric);
+               wrbuf_puts (w, tmpattr);
+               break;
+           case CCL_RPN_ATTR_STRING:
+               sprintf(tmpattr, "%d=", att->type);
+               wrbuf_puts (w, tmpattr);
+               wrbuf_puts(w, att->value.str);
+               break;
+           }
        }
        for (cp = p->u.t.term; *cp; cp++)
        {