aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-09-30 11:11:58 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-09-30 11:11:58 +0300
commitafa79161b65f810b8ad0ef37a8408d91061a1085 (patch)
treeee94fb695aaf9a4ca4840ba97855e1eb4099d60d
parente4b5a8f38a50787419984aacbb0143dd57516fe6 (diff)
downloadmailfromd-afa79161b65f810b8ad0ef37a8408d91061a1085.tar.gz
mailfromd-afa79161b65f810b8ad0ef37a8408d91061a1085.tar.bz2
Clean-up file inclusion code.
* configure.ac: Call AC_PROG_LN_S. * mfd/Makefile.am: Rename status.mfh to status.mf (install-data-local): Create a link to status.mfh, for compatibility. * mfd/gram.y (print_syntax_tree): Test attempt to print all modules. * mfd/mailfromd.h (struct module): New member incl_sources. * mfd/pp.c (incl_sources): Removed. (source_lookup): Search in top_modules->incl_sources. (parse_include): Remove include_once kludge. Both include and include_once are now handled by lex_new_source, as previously. * mfd/symbols.c (import_confun): Remove spurious diagnostics. (module_init): Initialize all members. (module_free): Destroy incl_sources. * mflib/sieve.mfh: Rename to sieve.mf * mflib/Makefile.am: Rename sieve.mfh to sieve.mf (install-data-local): Create a link to sieve.mfh, for compatibility. * tests/Makefile.am: Remove status.mfh to status.mf * mflib/match_cidr.mf, mflib/match_dnsbl.mf, mflib/match_rhsbl.mf, mflib/sockmap.mf, tests/etc/catch.rc, tests/etc/catch01.rc, tests/etc/poll-1.rc, tests/etc/poll.rc: Use require instead of #include_once.
-rw-r--r--configure.ac1
-rw-r--r--mfd/Makefile.am15
-rw-r--r--mfd/gram.y17
-rw-r--r--mfd/mailfromd.h1
-rw-r--r--mfd/pp.c31
-rw-r--r--mfd/symbols.c15
-rw-r--r--mflib/Makefile.am9
-rw-r--r--mflib/match_cidr.mf2
-rw-r--r--mflib/match_dnsbl.mf2
-rw-r--r--mflib/match_rhsbl.mf2
-rw-r--r--mflib/sieve.mf (renamed from mflib/sieve.mfh)0
-rw-r--r--mflib/sockmap.mf2
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/etc/catch.rc2
-rw-r--r--tests/etc/catch01.rc2
-rw-r--r--tests/etc/poll-1.rc2
-rw-r--r--tests/etc/poll.rc2
17 files changed, 70 insertions, 43 deletions
diff --git a/configure.ac b/configure.ac
index 6346fb80..5ed7a890 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ gl_EARLY
AC_PROG_RANLIB
AC_PROG_YACC
AC_PROG_LEX
+AC_PROG_LN_S
# Debugging mode
MU_DEBUG_MODE
diff --git a/mfd/Makefile.am b/mfd/Makefile.am
index 747e8e0f..d979158f 100644
--- a/mfd/Makefile.am
+++ b/mfd/Makefile.am
@@ -17,7 +17,7 @@
sbin_PROGRAMS = mailfromd
incdir=$(pkgdatadir)/$(VERSION)/include
-inc_DATA = status.mfh
+inc_DATA = status.mf
M4_FILES=\
bi_body.m4\
@@ -108,7 +108,7 @@ EXTRA_DIST = \
optab.opc\
optab.oph\
snarf.m4\
- status.mfh\
+ status.mf\
status.mfi
BUILT_SOURCES=\
@@ -151,15 +151,15 @@ node-tab.c: drivers.c
$(M4_FILES:.m4=.c): snarf.m4 init.m4
lex.c: gram.h
-status.mfh: status.mfi mailfromd.h Makefile.am
+status.mf: status.mfi mailfromd.h Makefile.am
-SUFFIXES = .m4 .c .def .h .mfi .mfh .opc .oph .cin .hin
+SUFFIXES = .m4 .c .def .h .mfi .mf .opc .oph .cin .hin
.mfi.c:
$(AM_V_GEN) $(AWK) -f $(top_srcdir)/mfd/mfstat.awk \
$(top_srcdir)/mfd/mailfromd.h $< > $@
-.mfi.mfh:
+.mfi.mf:
$(AM_V_GEN) $(AWK) -f $(top_srcdir)/mfd/mfstat.awk \
$(top_srcdir)/mfd/mailfromd.h $< > $@
@@ -199,6 +199,11 @@ AM_YFLAGS=-dtv
AM_LFLAGS=-dvp
install-data-local:
+ @here=`pwd`; \
+ cd $(DESTDIR)$(incdir); \
+ rm -f status.mfh; \
+ $(LN_S) status.mf status.mfh; \
+ cd $$here
-test -d $(DESTDIR)$(DEFAULT_STATE_DIR) || \
$(mkinstalldirs) -o $(DEFAULT_USER) $(DESTDIR)$(DEFAULT_STATE_DIR)
diff --git a/mfd/gram.y b/mfd/gram.y
index 1b19432d..43e8757f 100644
--- a/mfd/gram.y
+++ b/mfd/gram.y
@@ -2498,7 +2498,10 @@ function_enumerator(void *sym, void *data)
void
print_syntax_tree()
{
+ struct module_list *mp;
+
enum smtp_state tag;
+
printf("State handlers:\n");
printf("---------------\n");
for (tag = smtp_state_first; tag < smtp_state_count; tag++) {
@@ -2512,6 +2515,20 @@ print_syntax_tree()
printf("---------------\n");
symtab_enumerate(TOP_MODULE_SYMTAB(namespace_function),
function_enumerator, NULL);
+ printf("Modules:\n");
+ printf("--------\n");
+
+ /* FIXME */
+ for (mp = top_module->submodule_head; mp; mp = mp->next) {
+ printf("Module %s (%s)\n", mp->module->name,
+ mp->module->file);
+ printf("Declared name: %s\n",
+ mp->module->dclname ?
+ mp->module->dclname : mp->module->name);
+ symtab_enumerate(MODULE_SYMTAB(mp->module, namespace_function),
+ function_enumerator, NULL);
+ printf("--------\n");
+ }
}
diff --git a/mfd/mailfromd.h b/mfd/mailfromd.h
index 99df8a96..1a9a77fa 100644
--- a/mfd/mailfromd.h
+++ b/mfd/mailfromd.h
@@ -741,6 +741,7 @@ struct module {
struct symtab *symtab[MODULE_NAMESPACE_COUNT];
struct import_rule *import_rules;
struct module_list *submodule_head, *submodule_tail;
+ mu_list_t /* of struct input_file_ident */ incl_sources;
};
struct module_list {
diff --git a/mfd/pp.c b/mfd/pp.c
index 99296636..733791f9 100644
--- a/mfd/pp.c
+++ b/mfd/pp.c
@@ -83,9 +83,8 @@ add_include_dir(const char *dir)
mu_strerror(rc));
}
-static mu_list_t /* of struct input_file_ident */ incl_sources;
-
-#define ID_EQ(a,b) \
+
+#define ID_EQ(a,b) \
((a).i_node == (b).i_node && (a).device == (a).device)
static int
@@ -106,20 +105,22 @@ int
source_lookup(struct input_file_ident *idptr)
{
int rc;
- if (!incl_sources) {
- mu_list_create(&incl_sources);
- mu_list_set_comparator(incl_sources, input_file_ident_cmp);
- mu_list_set_destroy_item(incl_sources, input_file_ident_free);
+ if (!top_module->incl_sources) {
+ mu_list_create(&top_module->incl_sources);
+ mu_list_set_comparator(top_module->incl_sources,
+ input_file_ident_cmp);
+ mu_list_set_destroy_item(top_module->incl_sources,
+ input_file_ident_free);
}
- rc = mu_list_locate (incl_sources, idptr, NULL);
+ rc = mu_list_locate (top_module->incl_sources, idptr, NULL);
if (rc == MU_ERR_NOENT) {
struct input_file_ident *new_id = xmalloc(sizeof *new_id);
*new_id = *idptr;
- mu_list_append(incl_sources, new_id);
+ mu_list_append(top_module->incl_sources, new_id);
}
return rc == 0;
}
-
+
static int
try_file(const char *name, int allow_cwd, int err_not_found, char **newp)
{
@@ -207,13 +208,9 @@ parse_include(const char *text, int once)
advance_line();
if (p) {
- if (once)
- rc = begin_module(p, p, NULL); /* FIXME */
- else {
- rc = lex_new_source(p, once);
- if (rc == 0)
- module_push(top_module);
- }
+ rc = lex_new_source(p, once);
+ if (rc == 0)
+ module_push(top_module);
}
free(tmp);
mu_argcv_free(argc, argv);
diff --git a/mfd/symbols.c b/mfd/symbols.c
index a8e95bcc..8f657490 100644
--- a/mfd/symbols.c
+++ b/mfd/symbols.c
@@ -383,14 +383,8 @@ import_confun(struct symtab *tab,
struct mf_symbol *src = (struct mf_symbol*)srcent;
struct mf_symbol *dst = (struct mf_symbol*)dstent;
- if (LOCUS_EQ(&src->locus, &dst->locus)) {
- /* FIXME: These are debugging messages, actually */
- parse_warning_locus(&sip->locus,
- _("mild symbol import conflict: %s"),
- srcent->name);
- parse_warning_locus(&src->locus, _("symbol defined here"));
+ if (LOCUS_EQ(&src->locus, &dst->locus))
return 0;
- }
parse_error_locus(&sip->locus,
_("symbol import conflict: %s"), srcent->name);
parse_error_locus(&src->locus, _("imported symbol location"));
@@ -456,13 +450,17 @@ module_init(struct module *mod, const char *name, const char *file)
{
mod->name = mf_strdup(name);
mod->file = file ? mf_strdup(file) : NULL;
-
+ mod->dclname = NULL;
+ mod->flags = 0;
mod->symtab[namespace_function] =
xsymtab_create(sizeof(struct function), SYMTAB_COPY_KEY, NULL);
mod->symtab[namespace_variable] =
xsymtab_create(sizeof(struct variable), SYMTAB_COPY_KEY, NULL);
mod->symtab[namespace_constant] =
xsymtab_create(sizeof(struct constant), SYMTAB_COPY_KEY, NULL);
+ mod->import_rules = NULL;
+ mod->submodule_head = mod->submodule_tail = NULL;
+ mod->incl_sources = NULL;
}
struct module *
@@ -481,6 +479,7 @@ module_free(struct module *mod)
return;
for (i = 0; i < MODULE_NAMESPACE_COUNT; i++)
symtab_destroy(&mod->symtab[i]);
+ mu_list_destroy(&mod->incl_sources);
}
void
diff --git a/mflib/Makefile.am b/mflib/Makefile.am
index 5e5e2268..49a6af45 100644
--- a/mflib/Makefile.am
+++ b/mflib/Makefile.am
@@ -32,7 +32,7 @@ MF_FILES =\
revip.mf\
sa.mf\
safedb.mf\
- sieve.mfh\
+ sieve.mf\
sockmap.mf\
spf.mf\
strip_domain_part.mf\
@@ -54,3 +54,10 @@ check-am:
do \
$$MFD -I$(top_srcdir)/mfd -I$(top_srcdir)/mflib -I$(top_builddir)/mflib --lint $(top_srcdir)/mflib/$$file || exit 1; \
done
+
+install-data-local:
+ @here=`pwd`; \
+ cd $(DESTDIR)$(incdir); \
+ rm -f sieve.mfh; \
+ $(LN_S) sieve.mf sieve.mfh; \
+ cd $$here
diff --git a/mflib/match_cidr.mf b/mflib/match_cidr.mf
index d4657c42..490866ec 100644
--- a/mflib/match_cidr.mf
+++ b/mflib/match_cidr.mf
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include_once <status.mfh>
+require status
#pragma regex push +extended
diff --git a/mflib/match_dnsbl.mf b/mflib/match_dnsbl.mf
index 1c672d1c..462ee154 100644
--- a/mflib/match_dnsbl.mf
+++ b/mflib/match_dnsbl.mf
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include_once <status.mfh>
+require status
require dns
require match_cidr
diff --git a/mflib/match_rhsbl.mf b/mflib/match_rhsbl.mf
index 8c79eb99..27b371a1 100644
--- a/mflib/match_rhsbl.mf
+++ b/mflib/match_rhsbl.mf
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include_once <status.mfh>
+require status
require dns
require match_cidr
diff --git a/mflib/sieve.mfh b/mflib/sieve.mf
index 03caa180..03caa180 100644
--- a/mflib/sieve.mfh
+++ b/mflib/sieve.mf
diff --git a/mflib/sockmap.mf b/mflib/sockmap.mf
index 9848bcdf..f1d4cf91 100644
--- a/mflib/sockmap.mf
+++ b/mflib/sockmap.mf
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include_once <status.mfh>
+require status
static func __sockmap_send(number fd, string query)
do
diff --git a/tests/Makefile.am b/tests/Makefile.am
index af2f6541..208692b9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -123,17 +123,17 @@ $(TESTSUITE): package.m4 $(TESTSUITE_AT)
$(AM_V_GEN)$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
$(AM_V_at)mv $@.tmp $@
-status.mfh: $(top_srcdir)/mfd/status.mfh
- $(AM_V_GEN)$(M4) $(top_srcdir)/mflib/pp-setup $(top_srcdir)/mfd/status.mfh > status.mfh
+status.mf: $(top_srcdir)/mfd/status.mf
+ $(AM_V_GEN)$(M4) $(top_srcdir)/mflib/pp-setup $(top_srcdir)/mfd/status.mf > status.mf
atconfig: $(top_builddir)/config.status
cd $(top_builddir) && ./config.status tests/$@
clean-local:
@test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
- @test ! -f status.mfh || rm status.mfh
+ @test ! -f status.mf || rm status.mf
-check-local: atconfig atlocal $(TESTSUITE) status.mfh
+check-local: atconfig atlocal $(TESTSUITE) status.mf
@$(SHELL) $(TESTSUITE)
# Run the test suite on the *installed* tree.
diff --git a/tests/etc/catch.rc b/tests/etc/catch.rc
index 1ece48ea..7254ba4c 100644
--- a/tests/etc/catch.rc
+++ b/tests/etc/catch.rc
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with Mailfromd. If not, see <http://www.gnu.org/licenses/>. */
-#include_once <status.mfh>
+require status
require match_cidr
set network "127.0.0.0/8"
diff --git a/tests/etc/catch01.rc b/tests/etc/catch01.rc
index 7bcecf93..c5562ae0 100644
--- a/tests/etc/catch01.rc
+++ b/tests/etc/catch01.rc
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with Mailfromd. If not, see <http://www.gnu.org/licenses/>. */
-#include_once <status.mfh>
+require status
require match_cidr
set network "127.0.0.0/8"
diff --git a/tests/etc/poll-1.rc b/tests/etc/poll-1.rc
index 8cc28b28..15c9cce8 100644
--- a/tests/etc/poll-1.rc
+++ b/tests/etc/poll-1.rc
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with Mailfromd. If not, see <http://www.gnu.org/licenses/>. */
-#include_once <status.mfh>
+require status
prog envfrom
do
diff --git a/tests/etc/poll.rc b/tests/etc/poll.rc
index b5e2ee52..e0ef3d6f 100644
--- a/tests/etc/poll.rc
+++ b/tests/etc/poll.rc
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with Mailfromd. If not, see <http://www.gnu.org/licenses/>. */
-#include <status.mfh>
+require status
prog envfrom
do

Return to:

Send suggestions and report system problems to the System administrator.