maint: summarize highlights of 1.4.18 release
[m4/ericb.git] / tests / import.c
blobcdd1176c463667e3582df9e3215dc8eba1a6ad44
1 /* GNU m4 -- A simple macro processor
2 Copyright (C) 2003, 2006-2008, 2010, 2013-2014, 2017 Free Software
3 Foundation, Inc.
5 This file is part of GNU M4.
7 GNU M4 is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU M4 is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <config.h>
23 /* Build using only the exported interfaces, unless NDEBUG is set, in
24 which case use private symbols to speed things up as much as possible. */
25 #ifndef NDEBUG
26 # include <m4/m4module.h>
27 #else
28 # include "m4private.h"
29 #endif
31 /* function macros blind side minargs maxargs */
32 #define builtin_functions \
33 BUILTIN (import, false, false, false, 0, 1) \
34 BUILTIN (symbol_fail, false, false, false, 0, 1) \
35 BUILTIN (module_fail, false, false, false, 0, 1) \
37 #define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler)
38 builtin_functions
39 #undef BUILTIN
41 static const m4_builtin m4_builtin_table[] =
43 #define BUILTIN(handler, macros, blind, side, min, max) \
44 M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max)
46 builtin_functions
47 #undef BUILTIN
49 { NULL, NULL, 0, 0, 0 },
53 void
54 include_import (m4 *context, m4_module *module, m4_obstack *obs)
56 m4_install_builtins (context, module, m4_builtin_table);
61 typedef bool export_test_func (const char *);
62 typedef bool no_such_func (const char *);
64 /**
65 * import()
66 **/
67 M4BUILTIN_HANDLER (import)
69 M4_MODULE_IMPORT (modtest, export_test);
71 const char *s = "`import'::`import' called.";
73 assert (obs != 0);
74 obstack_grow (obs, s, strlen(s));
76 if (export_test && export_test (M4ARG (1)))
77 fputs ("TRUE\n", stderr);
80 /**
81 * symbol_fail()
82 **/
83 M4BUILTIN_HANDLER (symbol_fail)
85 M4_MODULE_IMPORT (modtest, no_such);
87 const char *s = "`import'::`symbol_fail' called.";
89 assert (obs != 0);
90 obstack_grow (obs, s, strlen(s));
92 if (no_such && no_such (M4ARG (1)))
93 fputs ("TRUE\n", stderr);
96 /**
97 * module_fail()
98 **/
99 M4BUILTIN_HANDLER (module_fail)
101 M4_MODULE_IMPORT (no_such, no_such);
103 const char *s = "`import'::`module_fail' called.";
105 assert (obs != 0);
106 obstack_grow (obs, s, strlen(s));
108 if (no_such && no_such (M4ARG (1)))
109 fputs ("TRUE\n", stderr);