aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore29
-rw-r--r--Makefile.am2
-rw-r--r--am/grecs.m421
-rw-r--r--src/.gitignore4
-rw-r--r--src/Makefile.am3
-rw-r--r--src/diag.c73
-rw-r--r--src/format.c121
-rw-r--r--src/grecs-gram.y715
-rw-r--r--src/grecs.h86
-rw-r--r--src/lookup.c272
-rw-r--r--src/tree.c773
-rw-r--r--tests/.gitignore8
-rw-r--r--tests/Makefile.am84
-rw-r--r--tests/atlocal.in10
-rw-r--r--tests/cfhelp.at76
-rw-r--r--tests/format00.at38
-rw-r--r--tests/format01.at38
-rw-r--r--tests/format02.at38
-rw-r--r--tests/gcf1.conf54
-rw-r--r--tests/gcffmt.c67
-rw-r--r--tests/gcfpeek.c76
-rw-r--r--tests/gcfset.c240
-rw-r--r--tests/peek00.at25
-rw-r--r--tests/peek01.at30
-rw-r--r--tests/peek02.at26
-rw-r--r--tests/peek03.at33
-rw-r--r--tests/set.at38
-rw-r--r--tests/testsuite.at54
28 files changed, 2318 insertions, 716 deletions
diff --git a/.gitignore b/.gitignore
index 42c88b2..eec45d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,25 @@
1gconf-gram.c 1*.a
2gconf-gram.h 2*.o
3gconf-gram.output 3*.tar.*
4gconf-lex.c 4*~
5.deps
6.emacs.desktop
7.emacs.desktop.lock
8.emacsrc
9ABOUT-NLS
10ChangeLog
11INSTALL
12Makefile
13Makefile.in
14TAGS
15aclocal.m4
16autom4te.cache
17build-aux
18config.h
19config.h.in
20config.log
21config.status
22configure
23core
24m4
25stamp-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
@@ -49,14 +49,15 @@ AC_DEFUN([_GRECS_OPTION_SWITCH],
49AC_DEFUN([_GRECS_SET_OPTIONS], 49AC_DEFUN([_GRECS_SET_OPTIONS],
50[m4_foreach_w([_GRECS_Option], [$1], [_GRECS_SET_OPTION(_GRECS_Option)])]) 50[m4_foreach_w([_GRECS_Option], [$1], [_GRECS_SET_OPTION(_GRECS_Option)])])
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.
56# std-pp-setup Install standard pp-setup file. 56# std-pp-setup Install standard pp-setup file.
57# pp-setup-option Add the --with-pp-setup-file option to the 57# pp-setup-option Add the --with-pp-setup-file option to the
58# configuration file. The option allows user to 58# configuration file. The option allows user to
59# control whether the pp-setup file is installed. 59# control whether the pp-setup file is installed.
60# tests Build tests.
60# 61#
61# The pp-setup-file argument supplies the pathname of the preprocessor 62# The pp-setup-file argument supplies the pathname of the preprocessor
62# setup file in the source tree. It is ignored if std-pp-setup option is 63# setup file in the source tree. It is ignored if std-pp-setup option is
@@ -69,7 +70,8 @@ AC_DEFUN([GRECS_SETUP],[
69 AC_PROG_YACC 70 AC_PROG_YACC
70 AM_PROG_LEX 71 AM_PROG_LEX
71 72
72 _GRECS_SET_OPTIONS([$1]) 73 AC_SUBST([GRECS_SUBDIR],m4_if([$1],,grecs,$1))
74 _GRECS_SET_OPTIONS([$2])
73 # ********************** 75 # **********************
74 # Preprocessor 76 # Preprocessor
75 # ********************** 77 # **********************
@@ -104,7 +106,7 @@ AC_DEFUN([GRECS_SETUP],[
104 DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS" 106 DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS"
105 _GRECS_IF_OPTION_SET([std-pp-setup], 107 _GRECS_IF_OPTION_SET([std-pp-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)
109 if test -n "$PP_SETUP_FILE"; then 111 if test -n "$PP_SETUP_FILE"; then
110 _GRECS_IF_OPTION_SET([pp-setup-option], 112 _GRECS_IF_OPTION_SET([pp-setup-option],
@@ -127,5 +129,14 @@ AC_DEFUN([GRECS_SETUP],[
127 else 129 else
128 DEFAULT_PREPROCESSOR=NULL 130 DEFAULT_PREPROCESSOR=NULL
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 @@
1grecs-gram.c
2grecs-gram.h
3grecs-gram.output
4grecs-lex.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 759716b..0c2c444 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,14 +16,17 @@
16 16
17noinst_LIBRARIES=libgrecs.a 17noinst_LIBRARIES=libgrecs.a
18libgrecs_a_SOURCES = \ 18libgrecs_a_SOURCES = \
19 diag.c\
19 format.c\ 20 format.c\
20 grecs-gram.y\ 21 grecs-gram.y\
21 grecs-lex.l\ 22 grecs-lex.l\
22 list.c\ 23 list.c\
24 lookup.c\
23 mem.c\ 25 mem.c\
24 preproc.c\ 26 preproc.c\
25 symtab.c\ 27 symtab.c\
26 text.c\ 28 text.c\
29 tree.c\
27 grecs.h\ 30 grecs.h\
28 wordsplit.c\ 31 wordsplit.c\
29 wordsplit.h 32 wordsplit.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
26static void
27default_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
39void (*grecs_print_diag_fun)(grecs_locus_t *, int, int, const char *msg) =
40 default_print_diag;
41
42void
43grecs_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
57void
58grecs_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
@@ -24,7 +24,7 @@
24#include <string.h> 24#include <string.h>
25 25
26const char * 26const char *
27grecs_data_type_string (enum grecs_data_type type) 27grecs_data_type_string(enum grecs_data_type type)