diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-09-25 17:20:35 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-09-25 17:20:35 +0300 |
commit | 75f912738f5e73b445b1d6aed08c3c77a178036d (patch) | |
tree | ba24560f70469b61fb5f4d106d0ac971850a16fb | |
parent | 4d441e3be04af215601858c32ff4df193ee30946 (diff) | |
download | dico-75f912738f5e73b445b1d6aed08c3c77a178036d.tar.gz dico-75f912738f5e73b445b1d6aed08c3c77a178036d.tar.bz2 |
Include customized version of pp-setup
-rw-r--r-- | configure.boot | 2 | ||||
-rw-r--r-- | dicod/Makefile.am | 5 | ||||
-rw-r--r-- | dicod/pp-setup | 106 | ||||
-rw-r--r-- | doc/dico.texi | 18 |
4 files changed, 120 insertions, 11 deletions
diff --git a/configure.boot b/configure.boot index 0d6f01e..f6e704c 100644 --- a/configure.boot +++ b/configure.boot @@ -152,7 +152,7 @@ if test -z "$DEFAULT_VERSION_INCLUDE_DIR"; then fi # Grecs configuration system -GRECS_SETUP(grecs, [shared tests getopt git2chg std-pp-setup sockaddr-list]) +GRECS_SETUP(grecs, [shared tests getopt git2chg sockaddr-list]) GRECS_HOST_PROJECT_INCLUDES='-I$(top_srcdir)/gnu -I$(top_builddir)/gnu' # Tcl/tk diff --git a/dicod/Makefile.am b/dicod/Makefile.am index 9ccad06..116ab2b 100644 --- a/dicod/Makefile.am +++ b/dicod/Makefile.am @@ -82,4 +82,7 @@ SUFFIXES=.opt .c $(AM_V_GEN)m4 -s $(top_srcdir)/@GRECS_SUBDIR@/build-aux/getopt.m4 $< > $@ BUILT_SOURCES=cmdline.c -EXTRA_DIST=cmdline.opt +EXTRA_DIST=cmdline.opt pp-setup + +incdir=$(pkgdatadir)/$(VERSION)/include +inc_DATA = pp-setup diff --git a/dicod/pp-setup b/dicod/pp-setup new file mode 100644 index 0000000..2d30c8d --- /dev/null +++ b/dicod/pp-setup @@ -0,0 +1,106 @@ +divert(-1) dnl -*- m4 -*- +# This file is part of GNU Dico +# Copyright (C) 2018 Sergey Poznyakoff +# +# GNU Dico 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. +# +# GNU Dico 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 GNU Dico. If not, see <http://www.gnu.org/licenses/>. + +changecom(/*,*/) +changequote([,]) + +/* ------------------------------ + * Simulate --prefix-builtins. + * Borrowed from Autoconf + * ------------------------------- */ + +define([m4_define], defn([define])) +define([m4_defn], defn([defn])) +define([m4_undefine], defn([undefine])) + +m4_undefine([define]) +m4_undefine([defn]) +m4_undefine([undefine]) + +/* m4_copy(SRC, DST) + * ----------------- + * Define DST as the definition of SRC. + * What]s the difference between: + * 1. m4_copy([from], [to]) + * 2. m4_define([to], [from($@)]) + * Well, obviously 1 is more expensive in space. Maybe 2 is more expensive + * in time, but because of the space cost of 1, it]s not that obvious. + * Nevertheless, one huge difference is the handling of [$0]. If [from] + * uses [$0], then with 1, [to]]s [$0] is [to], while it is [from] in 2. + * The user will certainly prefer to see [to]. + */ +m4_define([m4_copy], +[m4_define([$2], m4_defn([$1]))]) + +/* m4_rename(SRC, DST) + * ------------------- + * Rename the macro SRC as DST. + */ +m4_define([m4_rename], +[m4_copy([$1], [$2])m4_undefine([$1])]) + +/* m4_rename_m4(MACRO-NAME) + * ------------------------ + * Rename MACRO-NAME as m4_MACRO-NAME. + */ +m4_define([m4_rename_m4], +[m4_rename([$1], [m4_$1])]) + +/* Some m4 internals have names colliding with tokens we might use. + * Rename them a[ la [m4 --prefix-builtins]. + */ +m4_rename_m4([builtin]) +m4_rename_m4([changecom]) +m4_rename_m4([changequote]) +m4_rename_m4([debugfile]) +m4_rename_m4([debugmode]) +m4_rename_m4([decr]) +m4_rename_m4([divert]) +m4_rename_m4([divnum]) +m4_rename_m4([dumpdef]) +m4_rename_m4([errprint]) +m4_rename_m4([esyscmd]) +m4_rename_m4([eval]) +m4_rename_m4([format]) +m4_rename_m4([ifdef]) +m4_rename_m4([ifelse]) +m4_rename_m4([include]) +m4_rename_m4([incr]) +m4_rename_m4([index]) +m4_rename_m4([indir]) +m4_rename_m4([len]) +m4_rename([m4exit], [m4_exit]) +m4_rename([m4wrap], [m4_wrap]) +m4_rename_m4([maketemp]) +m4_rename_m4([patsubst]) +m4_rename_m4([popdef]) +m4_rename_m4([pushdef]) +m4_rename_m4([regexp]) +m4_rename_m4([shift]) +m4_rename_m4([sinclude]) +m4_rename_m4([substr]) +m4_rename_m4([symbols]) +m4_rename_m4([syscmd]) +m4_rename_m4([sysval]) +m4_rename_m4([traceoff]) +m4_rename_m4([traceon]) +m4_rename_m4([translit]) +m4_rename_m4([undivert]) +m4_rename_m4([dnl]) +m4_rename_m4([__line__]) +m4_rename_m4([__file__]) +m4_divert(0)m4_dnl diff --git a/doc/dico.texi b/doc/dico.texi index 81dbee2..31edfcc 100644 --- a/doc/dico.texi +++ b/doc/dico.texi @@ -2716,11 +2716,11 @@ diagnostic. An initial set of macro definitions is supplied by the @file{@var{$prefix}/share/dico/@var{version}/include} directory (where @var{version} means the version of GNU Dico package). -The default @file{pp-setup} file renames all @command{m4} built-in -macros so they all start with the prefix @samp{m4_}. This -is similar to GNU m4 @option{--prefix-builtin} option, but has an -advantage that it works with non-GNU @command{m4} implementations as -well. +The default @file{pp-setup} file changes quote characters to @samp{[} +and @samp{]}, and renames all @command{m4} built-in macros so they all +start with the prefix @samp{m4_}. The latter has an effect similar +to GNU @command{m4} @option{--prefix-builtin} option, but has an +advantage that it works with non-GNU @command{m4} implementations as well. As an example of how the use of preprocessor may improve @command{dicod} configuration, consider the following fragment taken @@ -2735,14 +2735,14 @@ repeating the same text over again, we define the following macro: # defdb(@sc{name}[, @sc{descr}]) # @r{Produce a standard definition for a database @sc{name}}. # @r{If @sc{descr} is given, use it as a description}. -m4_define(`defdb', ` +m4_define([defdb], [ database @{ name "$1"; handler "dictorg database=$1";m4_dnl -m4_ifelse(`$2',,,` - description "$2";') +m4_ifelse([$2],,,[ + description "$2";]) @} -') +]) @end group @end example |