diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-14 19:00:52 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-14 19:33:15 +0300 |
commit | f83e3229ea5c917dfb1bd1a59b1768fdcb882f9a (patch) | |
tree | 1032eebedf5bb28b1b7fdd2e2da5918e0e0225fb | |
parent | 3b336240d9ac05bac621568b95086dbff2371acd (diff) | |
download | grecs-f83e3229ea5c917dfb1bd1a59b1768fdcb882f9a.tar.gz grecs-f83e3229ea5c917dfb1bd1a59b1768fdcb882f9a.tar.bz2 |
Wildcard look-ups (initial implementation).
* src/grecs-gram.y (union)<ident>: New field.
(IDENT): Change type to <ident>. All uses changed.
* src/grecs-lex.l (ident): Initialize ident.locus.
* src/grecs.h (GRECS_NODE_FLAG_NODESCEND): New flag.
(grecs_match_buf_t): New data type.
(grecs_match_first,grecs_match_next)
(grecs_match_buf_free): New protos.
(grecs_tree_first_node,grecs_next_node): New protos.
* src/format.c (grecs_format_node): Handle GRECS_NODE_FLAG_NODESCEND flag.
* src/lookup.c (grecs_match_buf): New struct.
(grecs_match_first,grecs_match_next)
(grecs_match_buf_free): New functions.
(split_cfg_path): Fill in array of values, if given.
(parse_tag): Remove. All uses updated.
(node_finder): Use grecs_match_buf.
* src/tree.c (grecs_tree_reduce): Fill config_keywords with 0s.
(grecs_tree_first_node, grecs_next_node): New functions.
* tests/.gitignore: Add gcfenum
* tests/enum.at: New file.
* tests/glob00.at: New file.
* tests/glob01.at: New file.
* tests/glob02.at: New file.
* tests/gcfenum.c: New file.
* tests/Makefile.am: Build gcfenum. Add enum.at test.
* tests/testsuite.at: Include enum.at.
* tests/gcfpeek.c: Implement -match option.
-rw-r--r-- | src/format.c | 12 | ||||
-rw-r--r-- | src/grecs-gram.y | 23 | ||||
-rw-r--r-- | src/grecs-lex.l | 3 | ||||
-rw-r--r-- | src/grecs.h | 12 | ||||
-rw-r--r-- | src/lookup.c | 252 | ||||
-rw-r--r-- | src/tree.c | 28 | ||||
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 7 | ||||
-rw-r--r-- | tests/enum.at | 44 | ||||
-rw-r--r-- | tests/gcfenum.c | 78 | ||||
-rw-r--r-- | tests/gcfpeek.c | 34 | ||||
-rw-r--r-- | tests/glob00.at | 27 | ||||
-rw-r--r-- | tests/glob01.at | 27 | ||||
-rw-r--r-- | tests/glob02.at | 25 | ||||
-rw-r--r-- | tests/testsuite.at | 6 |
15 files changed, 480 insertions, 99 deletions
diff --git a/src/format.c b/src/format.c index b4a4340..1302520 100644 --- a/src/format.c +++ b/src/format.c @@ -271,12 +271,14 @@ grecs_format_node(struct grecs_node *node, int flags, FILE *fp) switch (node->type) { case grecs_node_root: case grecs_node_block: - for (node = node->down; node; node = node->next) { - grecs_format_node(node, flags, fp); - if (node->next) - fputc('\n', fp); + if (!(flags & GRECS_NODE_FLAG_NODESCEND)) { + for (node = node->down; node; node = node->next) { + grecs_format_node(node, flags, fp); + if (node->next) + fputc('\n', fp); + } + break; } - break; case grecs_node_stmt: if (flags & GRECS_NODE_FLAG_LOCUS) { diff --git a/src/grecs-gram.y b/src/grecs-gram.y index 960567e..9f8d000 100644 --- a/src/grecs-gram.y +++ b/src/grecs-gram.y @@ -34,14 +34,20 @@ int grecs_default_port = 0; %} %union { + struct { + grecs_locus_t locus; + char *string; + } ident; char *string; grecs_value_t svalue, *pvalue; struct grecs_list *list; struct grecs_node *node; + grecs_locus_t locus; struct { struct grecs_node *head, *tail; } node_list; } -%token <string> IDENT STRING QSTRING MSTRING +%token <ident> IDENT +%token <string> STRING QSTRING MSTRING %type <string> string slist %type <list> slist0 %type <svalue> value @@ -78,15 +84,15 @@ stmt : simple simple : IDENT vallist ';' { $$ = grecs_node_create(grecs_node_stmt, - &grecs_current_locus); - $$->ident = $1; + &$1.locus); + $$->ident = $1.string; $$->v.value = $2; } | IDENT ';' { $$ = grecs_node_create(grecs_node_stmt, - &grecs_current_locus); - $$->ident = $1; + &$1.locus); + $$->ident = $1.string; $$->v.value = NULL; } ; @@ -94,8 +100,8 @@ simple : IDENT vallist ';' block : IDENT tag '{' stmtlist '}' opt_sc { $$ = grecs_node_create(grecs_node_block, - &grecs_current_locus); - $$->ident = $1; + &$1.locus); + $$->ident = $1.string; $$->v.value = $2; grecs_node_bind($$, $4.head, 1); } @@ -161,6 +167,9 @@ value : string string : STRING | IDENT + { + $$ = $1.string; + } | slist ; diff --git a/src/grecs-lex.l b/src/grecs-lex.l index a3cc7d8..4d491fe 100644 --- a/src/grecs-lex.l +++ b/src/grecs-lex.l @@ -411,7 +411,8 @@ ident() len = strlen(p); str = grecs_malloc(len + 1); strcpy(str, p); - yylval.string = str; + yylval.ident.locus = grecs_current_locus; + yylval.ident.string = str; return IDENT; } diff --git a/src/grecs.h b/src/grecs.h index 05eeff2..61a915b 100644 --- a/src/grecs.h +++ b/src/grecs.h @@ -273,6 +273,7 @@ void grecs_format_value(struct grecs_value *val, int flags, FILE *fp); #define GRECS_NODE_FLAG_QUOTE 0x0800 #define GRECS_NODE_FLAG_NOQUOTE 0x1000 #define GRECS_NODE_FLAG_QUOTE_HEX 0x2000 +#define GRECS_NODE_FLAG_NODESCEND 0x4000 #define GRECS_NODE_FLAG_DEFAULT \ (GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE|GRECS_NODE_FLAG_QUOTE) void grecs_format_node(struct grecs_node *node, int flags, FILE *fp); @@ -354,8 +355,16 @@ int grecs_tree_join(struct grecs_node *dst, struct grecs_node *src); int grecs_tree_process(struct grecs_node *node, struct grecs_keyword *kwd); +typedef struct grecs_match_buf *grecs_match_buf_t; +struct grecs_node *grecs_match_first(struct grecs_node *tree, + const char *pattern, + grecs_match_buf_t *buf); +struct grecs_node *grecs_match_next(struct grecs_match_buf *buf); +void grecs_match_buf_free(struct grecs_match_buf *buf); + int grecs_value_eq(struct grecs_value *a, struct grecs_value *b); struct grecs_node *grecs_find_node(struct grecs_node *node, const char *path); + struct grecs_node *grecs_node_from_path(const char *path, const char *value); int grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd, int flags); @@ -363,5 +372,8 @@ int grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd, void grecs_tree_sort(struct grecs_node *node, int (*compare)(struct grecs_node const *, struct grecs_node const *)); + +struct grecs_node *grecs_tree_first_node(struct grecs_node *tree); +struct grecs_node *grecs_next_node(struct grecs_node *node); #endif diff --git a/src/lookup.c b/src/lookup.c index 09b7e85..d30d348 100644 --- a/src/lookup.c +++ b/src/lookup.c @@ -81,50 +81,34 @@ grecs_value_eq(struct grecs_value *a, struct grecs_value *b) } -static int -split_cfg_path(const char *path, int *pargc, char ***pargv) -{ +struct grecs_match_buf { int argc; char **argv; - char *delim = "."; - char static_delim[2] = { 0, 0 }; - - if (path[0] == '\\') { - argv = calloc(2, sizeof (*argv)); - if (!argv) - return ENOMEM; - argv[0] = strdup(path + 1); - if (!argv[0]) { - free(argv); - return ENOMEM; - } - argv[1] = NULL; - argc = 1; - } else { - struct wordsplit ws; - - if (ispunct(path[0])) { - delim = static_delim; - delim[0] = path[0]; - path++; - } - ws.ws_delim = delim; - - if (wordsplit(path, &ws, WRDSF_DEFFLAGS|WRDSF_DELIM)) - return errno; - argc = ws.ws_wordc; - argv = ws.ws_wordv; - ws.ws_wordc = 0; - ws.ws_wordv = NULL; - wordsplit_free(&ws); + int argi; + struct grecs_value **labelv; + struct grecs_node *node; +}; + +static void +grecs_match_buf_free_contents(struct grecs_match_buf *buf) +{ + size_t i; + for (i = 0; i < buf->argc; i++) { + free(buf->argv[i]); + grecs_value_free(buf->labelv[i]); } - - *pargc = argc; - *pargv = argv; - - return 0; + free(buf->argv); + free(buf->labelv); } +void +grecs_match_buf_free(struct grecs_match_buf *buf) +{ + grecs_match_buf_free_contents(buf); + free(buf); +} + + static struct grecs_value * parse_label(const char *str) { @@ -178,44 +162,81 @@ parse_label(const char *str) return val; } - -struct find_closure { +static int +split_cfg_path(const char *path, int *pargc, char ***pargv, + grecs_value_t ***pvalv) +{ int argc; char **argv; - int tag; - struct grecs_value *label; - struct grecs_node *node; -}; + char *delim = "."; + char static_delim[2] = { 0, 0 }; + + if (path[0] == '\\') { + argv = calloc(2, sizeof (*argv)); + if (!argv) + return ENOMEM; + argv[0] = strdup(path + 1); + if (!argv[0]) { + free(argv); + return ENOMEM; + } + argv[1] = NULL; + argc = 1; + } else { + struct wordsplit ws; + + if (ispunct(path[0])) { + delim = static_delim; + delim[0] = path[0]; + path++; + } + ws.ws_delim = delim; + + if (wordsplit(path, &ws, WRDSF_DEFFLAGS|WRDSF_DELIM)) + return errno; + argc = ws.ws_wordc; + argv = ws.ws_wordv; + ws.ws_wordc = 0; + ws.ws_wordv = NULL; + wordsplit_free(&ws); + } -static void -parse_tag(struct find_closure *fptr) -{ - char *p = strchr(fptr->argv[fptr->tag], '='); - if (p) { - *p++ = 0; - fptr->label = parse_label(p); + *pargv = argv; + *pargc = argc; + if (pvalv) { + int i; + grecs_value_t **valv; + + valv = grecs_calloc(argc, sizeof(valv[0])); + for (i = 0; i < argc; i++) { + char *p = strchr(argv[i], '='); + if (p) { + *p++ = 0; + valv[i] = parse_label(p); + } + } + *pvalv = valv; } - else - fptr->label = NULL; + return 0; } + static enum grecs_tree_recurse_res node_finder(enum grecs_tree_recurse_op op, struct grecs_node *node, void *data) { - struct find_closure *fdptr = data; + struct grecs_match_buf *buf = data; if (op == grecs_tree_recurse_post || node->type == grecs_node_root) return grecs_tree_recurse_ok; - if (strcmp(fdptr->argv[fdptr->tag], node->ident) == 0 - && (!fdptr->label || - grecs_value_eq(fdptr->label, node->v.value))) { - fdptr->tag++; - if (fdptr->tag == fdptr->argc) { - fdptr->node = node; + if (strcmp(buf->argv[buf->argi], node->ident) == 0 + && (!buf->labelv[buf->argi] || + grecs_value_eq(buf->labelv[buf->argi], node->v.value))) { + buf->argi++; + if (buf->argi == buf->argc) { + buf->node = node; return grecs_tree_recurse_stop; } - parse_tag(fdptr); return grecs_tree_recurse_ok; } @@ -226,22 +247,17 @@ node_finder(enum grecs_tree_recurse_op op, struct grecs_node *node, void *data) struct grecs_node * grecs_find_node(struct grecs_node *node, const char *path) { - int rc, i; - struct find_closure clos; + int rc; + struct grecs_match_buf buf; - rc = split_cfg_path(path, &clos.argc, &clos.argv); - if (rc || !clos.argc) + rc = split_cfg_path(path, &buf.argc, &buf.argv, &buf.labelv); + if (rc || !buf.argc) return NULL; - clos.tag = 0; - clos.label = NULL; - clos.node = NULL; - parse_tag(&clos); - grecs_tree_recurse(node, node_finder, &clos); - for (i = 0; i < clos.argc; i++) - free(clos.argv[i]); - free(clos.argv); - grecs_value_free(clos.label); - return clos.node; + buf.argi = 0; + buf.node = NULL; + grecs_tree_recurse(node, node_finder, &buf); + grecs_match_buf_free_contents(&buf); + return buf.node; } @@ -254,7 +270,7 @@ grecs_node_from_path(const char *path, const char *value) char **argv; struct grecs_node *dn = NULL; - rc = split_cfg_path(path, &argc, &argv); + rc = split_cfg_path(path, &argc, &argv, NULL); if (rc) return NULL; dn = grecs_node_create(grecs_node_stmt, NULL); @@ -297,3 +313,85 @@ grecs_node_from_path(const char *path, const char *value) return dn; } + +#define ISWC(c,w) ((c)[0] == (w) && (c)[1] == 0) + +static int +grecs_match(struct grecs_match_buf *buf) +{ + struct grecs_node *node; + int wcard = 0; + + buf->argi = buf->argc - 1; + node = buf->node; + + while (buf->argi >= 0) { + if (ISWC(buf->argv[buf->argi], '*')) { + wcard = 1; + if (buf->argi-- == 0) + return 1; + continue; + } + + if (strcmp(buf->argv[buf->argi], node->ident) == 0 + /* FIXME: */ + && (!buf->labelv[buf->argi] || + grecs_value_eq(buf->labelv[buf->argi], node->v.value))) { + wcard = 0; + node = node->up; + if (buf->argi-- == 0) + return !node || + node->type == grecs_node_root; + } else if (!wcard) + return 0; + else + node = node->up; + if (!node || node->type == grecs_node_root) + return ISWC(buf->argv[buf->argi], '*'); + } + return 0; +} + +struct grecs_node * +grecs_match_next(struct grecs_match_buf *buf) +{ + while (buf->node = grecs_next_node(buf->node)) + if (grecs_match(buf)) + break; + return buf->node; +} + +struct grecs_node * +grecs_match_first(struct grecs_node *tree, const char *pattern, + struct grecs_match_buf **pbuf) +{ + struct grecs_node *node; + struct grecs_match_buf *buf; + + if (tree->type != grecs_node_root) { + errno = EINVAL; + return NULL; + } + errno = 0; + + buf = grecs_zalloc(sizeof(*buf)); + if (split_cfg_path(pattern, &buf->argc, &buf->argv, &buf->labelv)) { + free(buf); + return NULL; + } + /* FIXME: Compress argv/argc by replacing contiguous sequences of *'s + with a single *. */ + buf->argi = 0; + buf->node = grecs_tree_first_node(tree); + *pbuf = buf; + if (grecs_match(buf)) + node = buf->node; + else + node = grecs_match_next(buf); + if (!node) { + grecs_match_buf_free(buf); + *pbuf = NULL; + } + return node; +} + @@ -1072,6 +1072,7 @@ grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd, struct nodeproc_closure clos; struct grecs_keyword config_keywords; + memset(&config_keywords, 0, sizeof(config_keywords)); config_keywords.kwd = kwd; if (kwd) { clos.cursect = &config_keywords; @@ -1085,3 +1086,30 @@ grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd, grecs_list_free(clos.sections); return rc; } + + +struct grecs_node * +grecs_tree_first_node(struct grecs_node *tree) +{ + if (tree->type != grecs_node_root) { + errno = EINVAL; + return NULL; + } + errno = 0; + return tree->down; +} + +struct grecs_node * +grecs_next_node(struct grecs_node *node) +{ + if (!node) + return NULL; + if (node->down) + return node->down; + while (!node->next) { + node = node->up; + if (!node || node->type == grecs_node_root) + return NULL; + } + return node->next; +} diff --git a/tests/.gitignore b/tests/.gitignore index af31c5e..1860fd4 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,6 +1,7 @@ atconfig atlocal distck +gcfenum gcffmt gcfpeek gcfset diff --git a/tests/Makefile.am b/tests/Makefile.am index df8739a..448d4e5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -41,10 +41,14 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac $(top_srcdir)/@GRECS_SUBDIR@/am ## ------------ ## TESTSUITE_AT = \ + cfhelp.at\ format00.at\ format01.at\ format02.at\ - cfhelp.at\ + glob00.at\ + glob01.at\ + glob02.at\ + enum.at\ join.at\ peek00.at\ peek01.at\ @@ -82,6 +86,7 @@ check-local: atconfig atlocal $(TESTSUITE) noinst_PROGRAMS = \ distck\ gcffmt\ + gcfenum\ gcfpeek\ gcfset\ gcfver diff --git a/tests/enum.at b/tests/enum.at new file mode 100644 index 0000000..d410c8e --- /dev/null +++ b/tests/enum.at @@ -0,0 +1,44 @@ +# This file is part of grecs -*- Autotest -*- +# Copyright (C) 2007, 2009-2011 Sergey Poznyakoff +# +# Grecs is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Grecs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grecs. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Enumerate nodes]) +AT_KEYWORDS([enum]) + +AT_CHECK([gcfenum $abs_srcdir/gcf1.conf], +[0], +[.scalar +.listvar +.compound +.mailbox +.mailbox.mailbox-pattern +.mailbox.mailbox-type +.logging +.logging.syslog +.logging.facility +.program="foo" +.program="foo".logging +.program="foo".logging.syslog +.program="foo".logging.facility +.program="foo".scalar +.program="bar" +.program="bar".logging +.program="bar".logging.syslog +.program="bar".logging.facility +.program="bar".logging.tag +.program="bar".scalar +]) + +AT_CLEANUP diff --git a/tests/gcfenum.c b/tests/gcfenum.c new file mode 100644 index 0000000..064b5c5 --- /dev/null +++ b/tests/gcfenum.c @@ -0,0 +1,78 @@ +/* grecs - Gray's Extensible Configuration System + Copyright (C) 2007-2011 Sergey Poznyakoff + + Grecs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + Grecs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Grecs. If not, see <http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include <string.h> +#include <errno.h> +#include "grecs.h" + +static void +usage(const char *arg, FILE *fp, int code) +{ + fprintf(fp, + "usage: %s [-h] [-locus] [-delim=char] [-reduce] file\n", + arg); + exit(code); +} + +int +main(int argc, char **argv) +{ + char *progname = argv[0]; + char *file = NULL; + struct grecs_node *tree, *node; + int flags = GRECS_NODE_FLAG_QUOTE| + GRECS_NODE_FLAG_PATH| + GRECS_NODE_FLAG_NODESCEND; + int reduce = 0; + + while (--argc) { + char *arg = *++argv; + if (strcmp(arg, "-locus") == 0) + flags |= GRECS_NODE_FLAG_LOCUS; + else if (strncmp(arg, "-delim=", 7) == 0) + flags |= arg[7]; + else if (strcmp(arg, "-reduce") == 0) + reduce = 1; + else if (strcmp(arg, "-h") == 0) + usage(progname, stdout, 0); + else if (arg[0] == '-') + usage(progname, stderr, 1); + else + file = arg; + } + + if (!file || argc) + usage(progname, stderr, 1); + + tree = grecs_parse(file); + if (!tree) + exit(1); + if (reduce) + grecs_tree_reduce(tree, NULL, 0); + + for (node = grecs_tree_first_node(tree); node; + node = grecs_next_node(node)) { + grecs_format_node(node, flags, stdout); + fputc('\n', stdout); + } + grecs_tree_free(tree); + exit(0); +} + + diff --git a/tests/gcfpeek.c b/tests/gcfpeek.c index df01b3c..36e3648 100644 --- a/tests/gcfpeek.c +++ b/tests/gcfpeek.c @@ -25,7 +25,7 @@ static void usage(const char *arg, FILE *fp, int code) { fprintf(fp, - "usage: %s [-h] [-locus] [-delim=char] [-reduce] file path\n", + "usage: %s [-h] [-locus] [-delim=char] [-nodesc] [-reduce] [-match] file path\n", arg); exit(code); } @@ -40,6 +40,7 @@ main(int argc, char **argv) int flags = GRECS_NODE_FLAG_DEFAULT; int rc = 2; int reduce = 0; + int match = 0; while (--argc) { char *arg = *++argv; @@ -49,6 +50,10 @@ main(int argc, char **argv) flags |= arg[7]; else if (strcmp(arg, "-reduce") == 0) reduce = 1; + else if (strcmp(arg, "-match") == 0) + match = 1; + else if (strcmp(arg, "-nodesc") == 0) + flags |= GRECS_NODE_FLAG_NODESCEND; else if (strcmp(arg, "-h") == 0) usage(progname, stdout, 0); else if (arg[0] == '-') @@ -71,13 +76,26 @@ main(int argc, char **argv) if (reduce) grecs_tree_reduce(tree, NULL, 0); - for (node = tree; node; node = node->next) { - node = grecs_find_node(node, path); - if (!node) - break; - rc = 0; - grecs_format_node(node, flags, stdout); - fputc('\n', stdout); + if (match) { + grecs_match_buf_t match_buf; + + for (node = grecs_match_first(tree, path, &match_buf); + node; + node = grecs_match_next(match_buf)) { + rc = 0; + grecs_format_node(node, flags, stdout); + fputc('\n', stdout); + } + grecs_match_buf_free(match_buf); + } else { + for (node = tree; node; node = node->next) { + node = grecs_find_node(node, path); + if (!node) + break; + rc = 0; + grecs_format_node(node, flags, stdout); + fputc('\n', stdout); + } } grecs_tree_free(tree); exit(rc); diff --git a/tests/glob00.at b/tests/glob00.at new file mode 100644 index 0000000..b9bc50f --- /dev/null +++ b/tests/glob00.at @@ -0,0 +1,27 @@ +# This file is part of grecs -*- Autotest -*- +# Copyright (C) 2007, 2009-2011 Sergey Poznyakoff +# +# Grecs is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Grecs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grecs. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP(Globbing: leading wildcard) +AT_KEYWORDS([peek peek04 glob glob00]) + +AT_CHECK([gcfpeek -match $abs_srcdir/gcf1.conf .*.facility], +[0], +[.logging.facility: "mail" +.program="foo".logging.facility: "local1" +.program="bar".logging.facility: "local2" +]) + +AT_CLEANUP diff --git a/tests/glob01.at b/tests/glob01.at new file mode 100644 index 0000000..a0e2e63 --- /dev/null +++ b/tests/glob01.at @@ -0,0 +1,27 @@ +# This file is part of grecs -*- Autotest -*- +# Copyright (C) 2007, 2009-2011 Sergey Poznyakoff +# +# Grecs is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Grecs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grecs. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP(Globbing: trailing wildcard) +AT_KEYWORDS([peek peek05 glob glob01]) + +AT_CHECK([gcfpeek -nodesc -match $abs_srcdir/gcf1.conf .logging.*|sed 's/ *$//'], +[0], +[.logging: +.logging.syslog: "yes" +.logging.facility: "mail" +]) + +AT_CLEANUP diff --git a/tests/glob02.at b/tests/glob02.at new file mode 100644 index 0000000..54be577 --- /dev/null +++ b/tests/glob02.at @@ -0,0 +1,25 @@ +# This file is part of grecs -*- Autotest -*- +# Copyright (C) 2007, 2009-2011 Sergey Poznyakoff +# +# Grecs is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Grecs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grecs. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP(Globbing: intermediate wildcard) +AT_KEYWORDS([peek peek05 glob02]) + +AT_CHECK([gcfpeek -match $abs_srcdir/gcf1.conf .program="foo".*.facility], +[0], +[.program="foo".logging.facility: "local1" +]) + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index f307cd8..08bc37a 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -51,11 +51,17 @@ m4_include([format00.at]) m4_include([format01.at]) m4_include([format02.at]) +m4_include([enum.at]) + m4_include([peek00.at]) m4_include([peek01.at]) m4_include([peek02.at]) m4_include([peek03.at]) +m4_include([glob00.at]) +m4_include([glob01.at]) +m4_include([glob02.at]) + m4_include([cfhelp.at]) m4_include([set.at]) |