diff options
-rw-r--r-- | .gitignore | 29 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | am/grecs.m4 | 21 | ||||
-rw-r--r-- | src/.gitignore | 4 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/diag.c | 73 | ||||
-rw-r--r-- | src/format.c | 117 | ||||
-rw-r--r-- | src/grecs-gram.y | 709 | ||||
-rw-r--r-- | src/grecs.h | 82 | ||||
-rw-r--r-- | src/lookup.c | 272 | ||||
-rw-r--r-- | src/tree.c | 773 | ||||
-rw-r--r-- | tests/.gitignore | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 84 | ||||
-rw-r--r-- | tests/atlocal.in | 10 | ||||
-rw-r--r-- | tests/cfhelp.at | 76 | ||||
-rw-r--r-- | tests/format00.at | 38 | ||||
-rw-r--r-- | tests/format01.at | 38 | ||||
-rw-r--r-- | tests/format02.at | 38 | ||||
-rw-r--r-- | tests/gcf1.conf | 54 | ||||
-rw-r--r-- | tests/gcffmt.c | 67 | ||||
-rw-r--r-- | tests/gcfpeek.c | 76 | ||||
-rw-r--r-- | tests/gcfset.c | 240 | ||||
-rw-r--r-- | tests/peek00.at | 25 | ||||
-rw-r--r-- | tests/peek01.at | 30 | ||||
-rw-r--r-- | tests/peek02.at | 26 | ||||
-rw-r--r-- | tests/peek03.at | 33 | ||||
-rw-r--r-- | tests/set.at | 38 | ||||
-rw-r--r-- | tests/testsuite.at | 54 |
28 files changed, 2311 insertions, 709 deletions
@@ -1,4 +1,25 @@ | |||
1 | gconf-gram.c | 1 | *.a |
2 | gconf-gram.h | 2 | *.o |
3 | gconf-gram.output | 3 | *.tar.* |
4 | gconf-lex.c | 4 | *~ |
5 | .deps | ||
6 | .emacs.desktop | ||
7 | .emacs.desktop.lock | ||
8 | .emacsrc | ||
9 | ABOUT-NLS | ||
10 | ChangeLog | ||
11 | INSTALL | ||
12 | Makefile | ||
13 | Makefile.in | ||
14 | TAGS | ||
15 | aclocal.m4 | ||
16 | autom4te.cache | ||
17 | build-aux | ||
18 | config.h | ||
19 | config.h.in | ||
20 | config.log | ||
21 | config.status | ||
22 | configure | ||
23 | core | ||
24 | m4 | ||
25 | stamp-h1 | ||
diff --git a/Makefile.am b/Makefile.am index 1bfdcf4..17f1ff6 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -1 +1 @@ | |||
SUBDIRS=src | SUBDIRS=src @GRECS_TESTDIR@ | ||
diff --git a/am/grecs.m4 b/am/grecs.m4 index 47c9867..5fc1819 100644 --- a/am/grecs.m4 +++ b/am/grecs.m4 | |||
@@ -51,5 +51,5 @@ AC_DEFUN([_GRECS_SET_OPTIONS], | |||
51 | 51 | ||
52 | # GRECS_SETUP([OPTIONS],[pp-setup-file]) | 52 | # GRECS_SETUP([dir],[OPTIONS],[pp-setup-file]) |
53 | # | 53 | # dir - Directory in the source tree where grecs has been cloned. |
54 | # Options are: | 54 | # OPTIONS are: |
55 | # no-preproc Disable the use of preprocessor. | 55 | # no-preproc Disable the use of preprocessor. |
@@ -59,2 +59,3 @@ AC_DEFUN([_GRECS_SET_OPTIONS], | |||
59 | # control whether the pp-setup file is installed. | 59 | # control whether the pp-setup file is installed. |
60 | # tests Build tests. | ||
60 | # | 61 | # |
@@ -71,3 +72,4 @@ AC_DEFUN([GRECS_SETUP],[ | |||
71 | 72 | ||
72 | _GRECS_SET_OPTIONS([$1]) | 73 | AC_SUBST([GRECS_SUBDIR],m4_if([$1],,grecs,$1)) |
74 | _GRECS_SET_OPTIONS([$2]) | ||
73 | # ********************** | 75 | # ********************** |
@@ -106,3 +108,3 @@ AC_DEFUN([GRECS_SETUP],[ | |||
106 | [PP_SETUP_FILE='pp-setup'], | 108 | [PP_SETUP_FILE='pp-setup'], |
107 | [m4_if([$2],,[PP_SETUP_FILE=],[PP_SETUP_FILE='$2'])]) | 109 | [m4_if([$3],,[PP_SETUP_FILE=],[PP_SETUP_FILE='$3'])]) |
108 | AC_SUBST(PP_SETUP_FILE) | 110 | AC_SUBST(PP_SETUP_FILE) |
@@ -129,3 +131,12 @@ AC_DEFUN([GRECS_SETUP],[ | |||
129 | fi | 131 | fi |
132 | _GRECS_IF_OPTION_SET([tests], | ||
133 | [m4_pushdef([TESTDIR],m4_if([$1],,grecs,$1)/tests) | ||
134 | AC_CONFIG_TESTDIR(TESTDIR) | ||
135 | AC_CONFIG_FILES(TESTDIR/Makefile TESTDIR/atlocal) | ||
136 | m4_popdef([TESTDIR]) | ||
137 | AM_MISSING_PROG([AUTOM4TE], [autom4te]) | ||
138 | GRECS_TESTDIR=tests | ||
139 | ]) | ||
130 | AC_SUBST([GRECS_INCLUDES]) | 140 | AC_SUBST([GRECS_INCLUDES]) |
141 | AC_SUBST([GRECS_TESTDIR]) | ||
131 | ]) | 142 | ]) |
diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..7c38320 --- /dev/null +++ b/src/.gitignore | |||
@@ -0,0 +1,4 @@ | |||
1 | grecs-gram.c | ||
2 | grecs-gram.h | ||
3 | grecs-gram.output | ||
4 | grecs-lex.c | ||
diff --git a/src/Makefile.am b/src/Makefile.am index 759716b..0c2c444 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -18,2 +18,3 @@ noinst_LIBRARIES=libgrecs.a | |||
18 | libgrecs_a_SOURCES = \ | 18 | libgrecs_a_SOURCES = \ |
19 | diag.c\ | ||
19 | format.c\ | 20 | format.c\ |
@@ -22,2 +23,3 @@ libgrecs_a_SOURCES = \ | |||
22 | list.c\ | 23 | list.c\ |
24 | lookup.c\ | ||
23 | mem.c\ | 25 | mem.c\ |
@@ -26,2 +28,3 @@ libgrecs_a_SOURCES = \ | |||
26 | text.c\ | 28 | text.c\ |
29 | tree.c\ | ||
27 | grecs.h\ | 30 | grecs.h\ |
diff --git a/src/diag.c b/src/diag.c new file mode 100644 index 0000000..fcb8fd2 --- /dev/null +++ b/src/diag.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* grecs - Gray's Extensible Configuration System | ||
2 | Copyright (C) 2007-2011 Sergey Poznyakoff | ||
3 | |||
4 | Grecs is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published by the | ||
6 | Free Software Foundation; either version 3 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | Grecs is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with Grecs. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <grecs.h> | ||
21 | #include <stdlib.h> | ||
22 | #include <stdio.h> | ||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | |||
26 | static void | ||
27 | default_print_diag(grecs_locus_t *locus, int err, int errcode, const char *msg) | ||
28 | { | ||
29 | if (locus) | ||
30 | fprintf(stderr, "%s:%d: ", locus->file, locus->line); | ||
31 | if (!err) | ||
32 | fprintf(stderr, "warning: "); | ||
33 | fprintf(stderr, "%s", msg); | ||
34 | if (errcode) | ||
35 | fprintf(stderr, ": %s", strerror(errno)); | ||
36 | fputc('\n', stderr); | ||
37 | } | ||
38 | |||
39 | void (*grecs_print_diag_fun)(grecs_locus_t *, int, int, const char *msg) = | ||
40 | default_print_diag; | ||
41 | |||
42 | void | ||
43 | grecs_warning(grecs_locus_t *locus, int errcode, const char *fmt, ...) | ||
44 | { | ||
45 | va_list ap; | ||
46 | char *buf = NULL; | ||
47 | size_t size = 0; | ||
48 | |||
49 | va_start(ap, fmt); | ||
50 | if (grecs_vasprintf(&buf, &size, fmt, ap)) | ||
51 | grecs_alloc_die(); | ||
52 | va_end(ap); | ||
53 | grecs_print_diag_fun(locus, 0, errcode, buf); | ||
54 | free(buf); | ||
55 | } | ||
56 | |||
57 | void | ||
58 | grecs_error(grecs_locus_t *locus, int errcode, const char *fmt, ...) | ||
59 | { | ||
60 | va_list ap; | ||
61 | char *buf = NULL; | ||
62 | size_t size = 0; | ||
63 | |||
64 | va_start(ap, fmt); | ||
65 | if (grecs_vasprintf(&buf, &size, fmt, ap)) | ||
66 | grecs_alloc_die(); | ||
67 | va_end(ap); | ||
68 | grecs_print_diag_fun(locus, 1, errcode, buf); | ||
69 | free(buf); | ||
70 | grecs_error_count++; | ||
71 | } | ||
72 | |||
73 | |||
diff --git a/src/format.c b/src/format.c index fc6c8d6..11b405a 100644 --- a/src/format.c +++ b/src/format.c | |||
@@ -70,3 +70,3 @@ grecs_data_type_string (enum grecs_data_type type) | |||
70 | static void | 70 | static void |
71 | format_level(FILE *stream, unsigned level) | 71 | format_level(unsigned level, FILE *stream) |
72 | { | 72 | { |
@@ -77,3 +77,3 @@ format_level(FILE *stream, unsigned level) | |||
77 | void | 77 | void |
78 | grecs_format_docstring(FILE *stream, const char *docstring, unsigned level) | 78 | grecs_format_docstring(const char *docstring, unsigned level, FILE *stream) |
79 | { | 79 | { |
@@ -103,3 +103,3 @@ grecs_format_docstring(FILE *stream, const char *docstring, unsigned level) | |||
103 | 103 | ||
104 | format_level(stream, level); | 104 | format_level(level, stream); |
105 | fprintf(stream, "# "); | 105 | fprintf(stream, "# "); |
@@ -121,4 +121,4 @@ grecs_format_docstring(FILE *stream, const char *docstring, unsigned level) | |||
121 | void | 121 | void |
122 | grecs_format_simple_statement(FILE *stream, struct grecs_keyword *kwp, | 122 | grecs_format_simple_statement(struct grecs_keyword *kwp, unsigned level, |
123 | unsigned level) | 123 | FILE *stream) |
124 | { | 124 | { |
@@ -127,4 +127,4 @@ grecs_format_simple_statement(FILE *stream, struct grecs_keyword *kwp, | |||
127 | if (kwp->docstring) | 127 | if (kwp->docstring) |
128 | grecs_format_docstring(stream, kwp->docstring, level); | 128 | grecs_format_docstring(kwp->docstring, level, stream); |
129 | format_level(stream, level); | 129 | format_level(level, stream); |
130 | 130 | ||
@@ -153,8 +153,8 @@ grecs_format_simple_statement(FILE *stream, struct grecs_keyword *kwp, | |||
153 | void | 153 | void |
154 | grecs_format_block_statement(FILE *stream, struct grecs_keyword *kwp, | 154 | grecs_format_block_statement(struct grecs_keyword *kwp, unsigned level, |
155 | unsigned level) | 155 | FILE *stream) |
156 | { | 156 | { |
157 | if (kwp->docstring) | 157 | if (kwp->docstring) |