Possible compatibility problems with earlier versions marked with '*'.
---- 2.0.27 2004/10/XX
+--- 2.0.27 2004/11/01
+
+Fixed bug #148: CQL parser may leak.
+
+* A few prototypes were changed in include/yaz/cql.h.
Fixed bug #176: Dont throw diagnostics on empty SRU args.
Doxyfile.in part of dist. Doxyfile generated by configure.
Configure aborts if any of --with-xml2, --with-openssl, --enable-tcpd
-ares given and the given component does not exist.
+are given and the corresponding component does not exist.
Extend CCL documentation in YAZ reference. Describe r=r.
-/* $Id: cql.h,v 1.9 2004-10-03 22:34:07 adam Exp $
+/* $Id: cql.h,v 1.10 2004-11-01 20:13:02 adam Exp $
Copyright (C) 2002-2004
Index Data Aps
#ifndef CQL_H_INCLUDED
#define CQL_H_INCLUDED
#include <stdio.h>
-#include <yaz/yconfig.h>
+#include <yaz/nmem.h>
YAZ_BEGIN_CDECL
* This function creates a search clause node (st).
*/
YAZ_EXPORT
-struct cql_node *cql_node_mk_sc(const char *index,
- const char *relation,
- const char *term);
-
+struct cql_node *cql_node_mk_sc(NMEM nmem, const char *index,
+ const char *relation, const char *term);
/**
* This function applies a prefix+uri to "unresolved" index and relation
* is NULL.
*/
YAZ_EXPORT
-struct cql_node *cql_apply_prefix(struct cql_node *cn,
- const char *prefix,
- const char *uri);
+struct cql_node *cql_apply_prefix(NMEM nmem, struct cql_node *cn,
+ const char *prefix, const char *uri);
/**
* This function creates a boolean node.
*/
YAZ_EXPORT
-struct cql_node *cql_node_mk_boolean(const char *op);
+struct cql_node *cql_node_mk_boolean(NMEM nmem, const char *op);
/**
* Destroys a node and its children.
* Duplicate a node (returns a copy of supplied node) .
*/
YAZ_EXPORT
-struct cql_node *cql_node_dup (struct cql_node *cp);
+struct cql_node *cql_node_dup (NMEM nmem, struct cql_node *cp);
/**
* This function returns the parse tree of the most recently parsed
-/* $Id: cql.y,v 1.7 2004-10-15 00:19:00 adam Exp $
+/* $Id: cql.y,v 1.8 2004-11-01 20:13:02 adam Exp $
Copyright (C) 2002-2004
Index Data Aps
%%
top: {
- $$.rel = cql_node_mk_sc("cql.serverChoice", "scr", 0);
+ $$.rel = cql_node_mk_sc(((CQL_parser) parm)->nmem,
+ "cql.serverChoice", "scr", 0);
((CQL_parser) parm)->top = 0;
} cqlQuery1 {
cql_node_destroy($$.rel);
cqlQuery boolean modifiers {
$$.rel = $0.rel;
} searchClause {
- struct cql_node *cn = cql_node_mk_boolean($2.buf);
+ struct cql_node *cn = cql_node_mk_boolean(((CQL_parser) parm)->nmem,
+ $2.buf);
cn->u.boolean.modifiers = $3.cql;
cn->u.boolean.left = $1.cql;
}
|
searchTerm {
- struct cql_node *st = cql_node_dup ($0.rel);
- st->u.st.term = xstrdup($1.buf);
+ struct cql_node *st = cql_node_dup (((CQL_parser) parm)->nmem, $0.rel);
+ st->u.st.term = nmem_strdup(((CQL_parser)parm)->nmem, $1.buf);
$$.cql = st;
}
|
index relation modifiers {
- $$.rel = cql_node_mk_sc($1.buf, $2.buf, 0);
+ $$.rel = cql_node_mk_sc(((CQL_parser) parm)->nmem, $1.buf, $2.buf, 0);
$$.rel->u.st.modifiers = $3.cql;
} searchClause {
$$.cql = $5.cql;
| '>' searchTerm '=' searchTerm {
$$.rel = $0.rel;
} cqlQuery {
- $$.cql = cql_apply_prefix($6.cql, $2.buf, $4.buf);
+ $$.cql = cql_apply_prefix(((CQL_parser) parm)->nmem,
+ $6.cql, $2.buf, $4.buf);
}
| '>' searchTerm {
$$.rel = $0.rel;
} cqlQuery {
- $$.cql = cql_apply_prefix($4.cql, 0, $2.buf);
+ $$.cql = cql_apply_prefix(((CQL_parser) parm)->nmem,
+ $4.cql, 0, $2.buf);
}
;
modifiers: modifiers '/' searchTerm
{
- struct cql_node *mod = cql_node_mk_sc($3.buf, "=", 0);
+ struct cql_node *mod = cql_node_mk_sc(((CQL_parser)parm)->nmem,
+ $3.buf, "=", 0);
mod->u.st.modifiers = $1.cql;
$$.cql = mod;
|
modifiers '/' searchTerm mrelation searchTerm
{
- struct cql_node *mod = cql_node_mk_sc($3.buf, $4.buf, $5.buf);
+ struct cql_node *mod = cql_node_mk_sc(((CQL_parser)parm)->nmem,
+ $3.buf, $4.buf, $5.buf);
mod->u.st.modifiers = $1.cql;
$$.cql = mod;
-/* $Id: cqltransform.c,v 1.11 2004-10-03 22:34:07 adam Exp $
+/* $Id: cqltransform.c,v 1.12 2004-11-01 20:13:02 adam Exp $
Copyright (C) 2002-2004
Index Data Aps
void *client_data)
{
struct cql_prop_entry *e;
+ NMEM nmem = nmem_create();
ct->error = 0;
if (ct->addinfo)
for (e = ct->entry; e ; e = e->next)
{
if (!memcmp(e->pattern, "set.", 4))
- cql_apply_prefix(cn, e->pattern+4, e->value);
+ cql_apply_prefix(nmem, cn, e->pattern+4, e->value);
else if (!strcmp(e->pattern, "set"))
- cql_apply_prefix(cn, 0, e->value);
+ cql_apply_prefix(nmem, cn, 0, e->value);
}
cql_transform_r (ct, cn, pr, client_data);
+ nmem_destroy(nmem);
return ct->error;
}
-/* $Id: cqlutil.c,v 1.5 2004-10-03 22:34:07 adam Exp $
+/* $Id: cqlutil.c,v 1.6 2004-11-01 20:13:02 adam Exp $
Copyright (C) 2002-2004
Index Data Aps
#include <stdlib.h>
#include <string.h>
-#include <yaz/xmalloc.h>
#include <yaz/cql.h>
void cql_fputs(const char *buf, void *client_data)
fputs(buf, f);
}
-struct cql_node *cql_node_dup (struct cql_node *cp)
+struct cql_node *cql_node_dup (NMEM nmem, struct cql_node *cp)
{
struct cql_node *cn = 0;
switch (cp->which)
{
case CQL_NODE_ST:
- cn = cql_node_mk_sc(cp->u.st.index,
+ cn = cql_node_mk_sc(nmem, cp->u.st.index,
cp->u.st.relation,
cp->u.st.term);
- cn->u.st.modifiers = cql_node_dup(cp->u.st.modifiers);
+ cn->u.st.modifiers = cql_node_dup(nmem, cp->u.st.modifiers);
cn->u.st.index_uri = cp->u.st.index_uri ?
- xstrdup(cp->u.st.index_uri) : 0;
+ nmem_strdup(nmem, cp->u.st.index_uri) : 0;
cn->u.st.relation_uri = cp->u.st.relation_uri ?
- xstrdup(cp->u.st.relation_uri) : 0;
+ nmem_strdup(nmem, cp->u.st.relation_uri) : 0;
break;
case CQL_NODE_BOOL:
- cn = cql_node_mk_boolean(cp->u.boolean.value);
- cn->u.boolean.left = cql_node_dup(cp->u.boolean.left);
- cn->u.boolean.right = cql_node_dup(cp->u.boolean.right);
+ cn = cql_node_mk_boolean(nmem, cp->u.boolean.value);
+ cn->u.boolean.left = cql_node_dup(nmem, cp->u.boolean.left);
+ cn->u.boolean.right = cql_node_dup(nmem, cp->u.boolean.right);
}
return cn;
}
-struct cql_node *cql_node_mk_sc(const char *index,
+struct cql_node *cql_node_mk_sc(NMEM nmem,
+ const char *index,
const char *relation,
const char *term)
{
- struct cql_node *p = (struct cql_node *) xmalloc(sizeof(*p));
+ struct cql_node *p = (struct cql_node *) nmem_malloc(nmem, sizeof(*p));
p->which = CQL_NODE_ST;
p->u.st.index = 0;
if (index)
- p->u.st.index = xstrdup(index);
+ p->u.st.index = nmem_strdup(nmem, index);
p->u.st.index_uri = 0;
p->u.st.term = 0;
if (term)
- p->u.st.term = xstrdup(term);
+ p->u.st.term = nmem_strdup(nmem, term);
p->u.st.relation = 0;
if (relation)
- p->u.st.relation = xstrdup(relation);
+ p->u.st.relation = nmem_strdup(nmem, relation);
p->u.st.relation_uri = 0;
p->u.st.modifiers = 0;
return p;
}
-struct cql_node *cql_node_mk_boolean(const char *op)
+struct cql_node *cql_node_mk_boolean(NMEM nmem, const char *op)
{
- struct cql_node *p = (struct cql_node *) xmalloc(sizeof(*p));
+ struct cql_node *p = (struct cql_node *) nmem_malloc(nmem, sizeof(*p));
p->which = CQL_NODE_BOOL;
p->u.boolean.value = 0;
if (op)
- p->u.boolean.value = xstrdup(op);
+ p->u.boolean.value = nmem_strdup(nmem, op);
p->u.boolean.left = 0;
p->u.boolean.right = 0;
p->u.boolean.modifiers = 0;
return "info:srw/cql-context-set/1/cql-v1.1";
}
-struct cql_node *cql_apply_prefix(struct cql_node *n, const char *prefix,
+struct cql_node *cql_apply_prefix(NMEM nmem,
+ struct cql_node *n, const char *prefix,
const char *uri)
{
if (n->which == CQL_NODE_ST)
strlen(prefix) == (size_t) (cp - n->u.st.index) &&
!memcmp(n->u.st.index, prefix, strlen(prefix)))
{
- char *nval = xstrdup(cp+1);
- n->u.st.index_uri = xstrdup(uri);
- xfree (n->u.st.index);
+ char *nval = nmem_strdup(nmem, cp+1);
+ n->u.st.index_uri = nmem_strdup(nmem, uri);
n->u.st.index = nval;
}
else if (!prefix && !cp)
{
- n->u.st.index_uri = xstrdup(uri);
+ n->u.st.index_uri = nmem_strdup(nmem, uri);
}
}
if (!n->u.st.relation_uri && n->u.st.relation)
strlen(prefix) == (size_t)(cp - n->u.st.relation) &&
!memcmp(n->u.st.relation, prefix, strlen(prefix)))
{
- char *nval = xstrdup(cp+1);
- n->u.st.relation_uri = xstrdup(uri);
- xfree (n->u.st.relation);
+ char *nval = nmem_strdup(nmem, cp+1);
+ n->u.st.relation_uri = nmem_strdup(nmem, uri);
n->u.st.relation = nval;
}
}
}
else if (n->which == CQL_NODE_BOOL)
{
- cql_apply_prefix(n->u.boolean.left, prefix, uri);
- cql_apply_prefix(n->u.boolean.right, prefix, uri);
+ cql_apply_prefix(nmem, n->u.boolean.left, prefix, uri);
+ cql_apply_prefix(nmem, n->u.boolean.right, prefix, uri);
}
return n;
}
switch (cn->which)
{
case CQL_NODE_ST:
- xfree (cn->u.st.index);
- xfree (cn->u.st.relation);
- xfree (cn->u.st.term);
- xfree (cn->u.st.index_uri);
- xfree (cn->u.st.relation_uri);
cql_node_destroy(cn->u.st.modifiers);
break;
case CQL_NODE_BOOL:
- xfree (cn->u.boolean.value);
cql_node_destroy(cn->u.boolean.left);
cql_node_destroy(cn->u.boolean.right);
cql_node_destroy(cn->u.boolean.modifiers);
}
- xfree (cn);
}