projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cql2pqf: option -S for strict mode
[yaz-moved-to-github.git]
/
util
/
cql2pqf.c
diff --git
a/util/cql2pqf.c
b/util/cql2pqf.c
index
5c33b5a
..
13c62b0
100644
(file)
--- a/
util/cql2pqf.c
+++ b/
util/cql2pqf.c
@@
-1,7
+1,10
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) 1995-2013 Index Data
* See the file LICENSE for details.
*/
* See the file LICENSE for details.
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
@@
-12,7
+15,8
@@
static void usage(void)
{
static void usage(void)
{
- fprintf(stderr, "usage\n cql2pqf [-n <n>] [-r] <properties> [<query>]\n");
+ fprintf(stderr, "usage\n cql2pqf [-n <n>] [-r] [-S] <properties> "
+ "[<query>]\n");
exit(1);
}
exit(1);
}
@@
-23,11
+27,13
@@
int main(int argc, char **argv)
char *query = 0;
char *fname = 0;
int reverse = 0;
char *query = 0;
char *fname = 0;
int reverse = 0;
+ int verbose = 1;
+ int do_strict = 0;
int ret;
char *arg;
int ret;
char *arg;
- while ((ret = options("n:r", argv, argc, &arg)) != -2)
+ while ((ret = options("n:rSv", argv, argc, &arg)) != -2)
{
switch (ret)
{
{
switch (ret)
{
@@
-37,18
+43,28
@@
int main(int argc, char **argv)
else
query = arg;
break;
else
query = arg;
break;
- case 'r':
- reverse = 1;
case 'n':
iterations = atoi(arg);
break;
case 'n':
iterations = atoi(arg);
break;
+ case 'r':
+ reverse = 1;
+ break;
+ case 'S':
+ do_strict = 1;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
default:
usage();
}
}
if (!fname)
usage();
default:
usage();
}
}
if (!fname)
usage();
- ct = cql_transform_open_fname(fname);
+ if (!strcmp(fname, "-"))
+ ct = cql_transform_create();
+ else
+ ct = cql_transform_open_fname(fname);
if (!ct)
{
fprintf(stderr, "failed to read properties %s\n", fname);
if (!ct)
{
fprintf(stderr, "failed to read properties %s\n", fname);
@@
-68,11
+84,11
@@
int main(int argc, char **argv)
{
fprintf(stderr, "PQF syntax error\n");
}
{
fprintf(stderr, "PQF syntax error\n");
}
- else
+ else
{
int ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
stdout, rpn);
{
int ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
stdout, rpn);
-
+
if (ret)
{
const char *addinfo;
if (ret)
{
const char *addinfo;
@@
-90,15
+106,18
@@
int main(int argc, char **argv)
{
CQL_parser cp = cql_parser_create();
int r = 0;
{
CQL_parser cp = cql_parser_create();
int r = 0;
-
+
+ cql_parser_strict(cp, do_strict);
if (query)
{
if (query)
{
+ if (verbose)
+ printf("Parsing CQL %s\n", query);
for (i = 0; i<iterations; i++)
r = cql_parser_string(cp, query);
}
else
r = cql_parser_stdio(cp, stdin);
for (i = 0; i<iterations; i++)
r = cql_parser_string(cp, query);
}
else
r = cql_parser_stdio(cp, stdin);
-
+
if (r)
fprintf(stderr, "Syntax error\n");
else
if (r)
fprintf(stderr, "Syntax error\n");
else
@@
-127,6
+146,7
@@
int main(int argc, char **argv)
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab