fix generated comments

In Bison 3.6.2, the comments with brackets lose their brackets, for
improper m4 quotation.

* data/skeletons/bison.m4 (b4_gsub): New.
* data/skeletons/c-like.m4 (_b4_comment): Use it.
* tests/m4.at: Check b4_gsub.
This commit is contained in:
Akim Demaille
2020-05-21 17:23:21 +02:00
parent 1ebc2ac55c
commit f80890c4bb
3 changed files with 54 additions and 5 deletions

View File

@@ -19,6 +19,27 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# m4_gsub(STRING, RE1, SUBST1, RE2, SUBST2, ...)
# ----------------------------------------------
# m4 equivalent of
#
# $_ = STRING;
# s/RE1/SUBST1/g;
# s/RE2/SUBST2/g;
# ...
#
# Really similar to m4_bpatsubsts, but behaves properly with quotes.
# See m4.at's "Generating Comments". Super inelegant, but so far, I
# did not find any better solution.
m4_define([b4_gsub],
[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst([[[[$1]]]],
[$2], [$3]),
[$4], [$5]),
[$6], [$7])])
## ---------------- ##
## Identification. ##
## ---------------- ##