summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2017-06-01 17:42:13 +0200
committerSimon Rettberg2017-06-01 17:42:13 +0200
commit0d04c01f3554d0740f3481d0e19b1de2a8508bde (patch)
tree81e414ec69c5bf3825a391994d8c903fb8d5df2b
parentMake pretty (diff)
downloadldadp-0d04c01f3554d0740f3481d0e19b1de2a8508bde.tar.gz
ldadp-0d04c01f3554d0740f3481d0e19b1de2a8508bde.tar.xz
ldadp-0d04c01f3554d0740f3481d0e19b1de2a8508bde.zip
Make print filter function output identical to usual string representation of filters
-rw-r--r--helper.c125
1 files changed, 63 insertions, 62 deletions
diff --git a/helper.c b/helper.c
index c7b4aaf..2dc907e 100644
--- a/helper.c
+++ b/helper.c
@@ -87,11 +87,11 @@ void helper_nonblock(const int fd)
static void helper_printavaInt(struct AttributeValueAssertion* a,const char* rel)
{
- printf("[%.*s %s", (int)a->desc.l, a->desc.s, rel);
+ printf("(%.*s%s", (int)a->desc.l, a->desc.s, rel);
if (a->value.l != 0 && a->value.s != NULL) {
- printf(" %.*s]", (int)a->value.l,a->value.s);
+ printf("%.*s)", (int)a->value.l,a->value.s);
} else {
- putchar(']');
+ putchar(')');
}
}
@@ -131,69 +131,70 @@ static void helper_printfilterInt(struct Filter* f)
printf("(nullfilter)");
return;
}
- switch (f->type) {
- case AND:
- printf("&(");
+ while (f != NULL) {
+ switch (f->type) {
+ case AND:
+ printf("(&");
mergesub:
- helper_printfilterInt(f->x);
- putchar(')');
- break;
- case OR:
- printf("|(");
- goto mergesub;
- case NOT:
- printf("!(");
- goto mergesub;
- case EQUAL:
- helper_printavaInt(&f->ava,"==");
- break;
- case SUBSTRING: {
- struct Substring* s=f->substrings;
- int first=1;
- printf("%.*s",(int)f->ava.desc.l,f->ava.desc.s);
- printf(" has ");
- while (s) {
- if (!first) {
- printf(" and ");
- }
- first=0;
- switch(s->substrtype) {
- case prefix:
- printf("prefix \"");
- break;
- case any:
- printf("substr \"");
- break;
- case suffix:
- printf("suffix \"");
- break;
+ helper_printfilterInt(f->x);
+ putchar(')');
+ break;
+ case OR:
+ printf("(|");
+ goto mergesub;
+ case NOT:
+ printf("(!");
+ goto mergesub;
+ case EQUAL:
+ helper_printavaInt(&f->ava,"=");
+ break;
+ case SUBSTRING: {
+ struct Substring* s=f->substrings;
+ int first=1;
+ printf("(%.*s",(int)f->ava.desc.l,f->ava.desc.s);
+ printf(" has ");
+ while (s) {
+ if (!first) {
+ printf(" and ");
+ }
+ first=0;
+ switch(s->substrtype) {
+ case prefix:
+ printf("prefix \"");
+ break;
+ case any:
+ printf("substr \"");
+ break;
+ case suffix:
+ printf("suffix \"");
+ break;
+ }
+ printf("%.*s\"",(int)s->s.l,s->s.s);
+ s=s->next;
}
- printf("%.*s",(int)s->s.l,s->s.s);
- putchar('"');
- s=s->next;
+ putchar(')');
}
- }
- break;
- case GREATEQUAL:
- helper_printavaInt(&f->ava,">=");
break;
- case LESSEQUAL:
- helper_printavaInt(&f->ava,"<=");
- break;
- case PRESENT:
- f->ava.value.l = 0;
- helper_printavaInt(&f->ava,"\\exist");
- break;
- case APPROX:
- helper_printavaInt(&f->ava,"\\approx");
- break;
- case EXTENSIBLE:
- printf("[extensible]");
- break;
- }
- if (f->next) {
- putchar(',');
- helper_printfilterInt(f->next);
+ case GREATEQUAL:
+ helper_printavaInt(&f->ava,">=");
+ break;
+ case LESSEQUAL:
+ helper_printavaInt(&f->ava,"<=");
+ break;
+ case PRESENT:
+ f->ava.value.l = 0;
+ helper_printavaInt(&f->ava,"=*");
+ break;
+ case APPROX:
+ helper_printavaInt(&f->ava,"~=");
+ break;
+ case EXTENSIBLE:
+ printf("[extensible]");
+ break;
+ default:
+ printf("????????");
+ }
+ f = f->next;
}
}