From: Adam Dickmeiss Date: Tue, 27 Sep 2005 17:52:46 +0000 (+0000) Subject: Added wrbuf_chlp_right X-Git-Tag: YAZ.2.1.10~46 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=323dd612ee1939e8082fa75edcd1083a238d5272;p=yaz-moved-to-github.git Added wrbuf_chlp_right --- diff --git a/include/yaz/wrbuf.h b/include/yaz/wrbuf.h index 8241d1d..44ab87e 100644 --- a/include/yaz/wrbuf.h +++ b/include/yaz/wrbuf.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: wrbuf.h,v 1.15 2005-06-25 15:46:03 adam Exp $ + * $Id: wrbuf.h,v 1.16 2005-09-27 17:52:46 adam Exp $ */ /** * \file wrbuf.h @@ -59,6 +59,8 @@ YAZ_EXPORT int wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf, YAZ_EXPORT int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd, const char *buf, int size); +YAZ_EXPORT void wrbuf_chop_right(WRBUF b); + #define wrbuf_len(b) ((b)->pos) #define wrbuf_buf(b) ((b)->buf) diff --git a/src/logrpn.c b/src/logrpn.c index 3da47d3..757105c 100644 --- a/src/logrpn.c +++ b/src/logrpn.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * All rights reserved. * - * $Id: logrpn.c,v 1.12 2005-08-22 20:34:21 adam Exp $ + * $Id: logrpn.c,v 1.13 2005-09-27 17:52:46 adam Exp $ */ /** @@ -53,126 +53,126 @@ static void attrStr (int type, int value, enum oid_value ast, char *str) case 2: rstr = relToStr(value); if (rstr) - sprintf (str, "relation=%s", rstr); + sprintf(str, "relation=%s", rstr); else - sprintf (str, "relation=%d", value); + sprintf(str, "relation=%d", value); break; case 3: switch (value) { case 1: - sprintf (str, "position=First in field"); + sprintf(str, "position=First in field"); break; case 2: - sprintf (str, "position=First in any subfield"); + sprintf(str, "position=First in any subfield"); break; case 3: - sprintf (str, "position=Any position in field"); + sprintf(str, "position=Any position in field"); break; default: - sprintf (str, "position"); + sprintf(str, "position"); } break; case 4: switch (value) { case 1: - sprintf (str, "structure=Phrase"); + sprintf(str, "structure=Phrase"); break; case 2: - sprintf (str, "structure=Word"); + sprintf(str, "structure=Word"); break; case 3: - sprintf (str, "structure=Key"); + sprintf(str, "structure=Key"); break; case 4: - sprintf (str, "structure=Year"); + sprintf(str, "structure=Year"); break; case 5: - sprintf (str, "structure=Date"); + sprintf(str, "structure=Date"); break; case 6: - sprintf (str, "structure=Word list"); + sprintf(str, "structure=Word list"); break; case 100: - sprintf (str, "structure=Date (un)"); + sprintf(str, "structure=Date (un)"); break; case 101: - sprintf (str, "structure=Name (norm)"); + sprintf(str, "structure=Name (norm)"); break; case 102: - sprintf (str, "structure=Name (un)"); + sprintf(str, "structure=Name (un)"); break; case 103: - sprintf (str, "structure=Structure"); + sprintf(str, "structure=Structure"); break; case 104: - sprintf (str, "structure=urx"); + sprintf(str, "structure=urx"); break; case 105: - sprintf (str, "structure=free-form-text"); + sprintf(str, "structure=free-form-text"); break; case 106: - sprintf (str, "structure=document-text"); + sprintf(str, "structure=document-text"); break; case 107: - sprintf (str, "structure=local-number"); + sprintf(str, "structure=local-number"); break; case 108: - sprintf (str, "structure=string"); + sprintf(str, "structure=string"); break; case 109: - sprintf (str, "structure=numeric string"); + sprintf(str, "structure=numeric string"); break; default: - sprintf (str, "structure"); + sprintf(str, "structure"); } break; case 5: switch (value) { case 1: - sprintf (str, "truncation=Right"); + sprintf(str, "truncation=Right"); break; case 2: - sprintf (str, "truncation=Left"); + sprintf(str, "truncation=Left"); break; case 3: - sprintf (str, "truncation=Left&right"); + sprintf(str, "truncation=Left&right"); break; case 100: - sprintf (str, "truncation=Do not truncate"); + sprintf(str, "truncation=Do not truncate"); break; case 101: - sprintf (str, "truncation=Process #"); + sprintf(str, "truncation=Process #"); break; case 102: - sprintf (str, "truncation=re-1"); + sprintf(str, "truncation=re-1"); break; case 103: - sprintf (str, "truncation=re-2"); + sprintf(str, "truncation=re-2"); break; case 104: - sprintf (str, "truncation=CCL"); + sprintf(str, "truncation=CCL"); break; default: - sprintf (str, "truncation"); + sprintf(str, "truncation"); } break; case 6: - switch (value) + switch(value) { case 1: - sprintf (str, "completeness=Incomplete subfield"); + sprintf(str, "completeness=Incomplete subfield"); break; case 2: - sprintf (str, "completeness=Complete subfield"); + sprintf(str, "completeness=Complete subfield"); break; case 3: - sprintf (str, "completeness=Complete field"); + sprintf(str, "completeness=Complete field"); break; default: - sprintf (str, "completeness"); + sprintf(str, "completeness"); } break; } @@ -181,9 +181,9 @@ static void attrStr (int type, int value, enum oid_value ast, char *str) break; } if (*str) - sprintf (str + strlen(str), " (%d=%d)", type, value); + sprintf(str + strlen(str), " (%d=%d)", type, value); else - sprintf (str, "%d=%d", type, value); + sprintf(str, "%d=%d", type, value); } static void wrbuf_term(WRBUF b, const char *term, int len) @@ -521,22 +521,17 @@ static void wrbuf_rpn_query(WRBUF b, Z_RPNQuery *rpn) ast = attrset->value; wrbuf_printf(b, " @attrset %s ", attrset->desc); } - else - { - ast = VAL_NONE; - wrbuf_printf (b, "Unknown:"); - } - wrbuf_structure (b,rpn->RPNStructure, ast); - + wrbuf_structure (b, rpn->RPNStructure, ast); + wrbuf_chop_right(b); } -void log_rpn_query (Z_RPNQuery *rpn) +void log_rpn_query(Z_RPNQuery *rpn) { log_rpn_query_level(YLOG_LOG, rpn); } -void log_scan_term_level (int loglevel, - Z_AttributesPlusTerm *zapt, oid_value ast) +void log_scan_term_level(int loglevel, + Z_AttributesPlusTerm *zapt, oid_value ast) { int depth = 0; if (!loglevel) @@ -551,7 +546,7 @@ void log_scan_term_level (int loglevel, zlog_attributes (zapt, depth+2, ast, loglevel); } -void log_scan_term (Z_AttributesPlusTerm *zapt, oid_value ast) +void log_scan_term(Z_AttributesPlusTerm *zapt, oid_value ast) { log_scan_term_level (YLOG_LOG, zapt, ast); } @@ -585,7 +580,7 @@ void yaz_log_zquery_level (int loglevel, Z_Query *q) void yaz_log_zquery (Z_Query *q) { - yaz_log_zquery_level(YLOG_LOG,q); + yaz_log_zquery_level(YLOG_LOG, q); } void wrbuf_put_zquery(WRBUF b, Z_Query *q) @@ -597,7 +592,7 @@ void wrbuf_put_zquery(WRBUF b, Z_Query *q) case Z_Query_type_1: case Z_Query_type_101: wrbuf_printf(b,"RPN:"); - wrbuf_rpn_query(b,q->u.type_1); + wrbuf_rpn_query(b, q->u.type_1); break; case Z_Query_type_2: wrbuf_printf(b, "CCL: %.*s", q->u.type_2->len, q->u.type_2->buf); diff --git a/src/wrbuf.c b/src/wrbuf.c index 9470477..19c2ce2 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: wrbuf.c,v 1.8 2005-06-25 15:46:06 adam Exp $ + * $Id: wrbuf.c,v 1.9 2005-09-27 17:52:46 adam Exp $ */ /** @@ -81,6 +81,15 @@ int wrbuf_puts(WRBUF b, const char *buf) return 0; } +void wrbuf_chop_right(WRBUF b) +{ + while (b->pos && b->buf[b->pos-1] == ' ') + { + (b->pos)--; + b->buf[b->pos] = '\0'; + } +} + int wrbuf_xmlputs(WRBUF b, const char *cp) { return wrbuf_xmlputs_n(b, cp, strlen(cp));