1 -*- Autoconf -*- 2 3# Common code for C-like languages (C, C++, Java, etc.) 4 5# Copyright (C) 2012-2015, 2018-2021 Free Software Foundation, Inc. 6 7# This program 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. 11# 12# This program 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. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <https://www.gnu.org/licenses/>. 19 20 21# _b4_comment(TEXT, OPEN, CONTINUE, END) 22# -------------------------------------- 23# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines. 24# Avoid adding indentation to the first line, as the indentation comes 25# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]). 26# Turn "*/" in TEXT into "* /" so that we don't unexpectedly close 27# the comments before its end. 28# 29# Prefix all the output lines with PREFIX. 30m4_define([_b4_comment], 31[$2[]b4_gsub(m4_expand([$1]), 32 [[*]/], [*\\/], 33 [/[*]], [/\\*], 34 [ 35\(.\)], [ 36$3\1])$4]) 37 38 39# b4_comment(TEXT, [PREFIX]) 40# -------------------------- 41# Put TEXT in comment. Prefix all the output lines with PREFIX. 42m4_define([b4_comment], 43[_b4_comment([$1], [$2/* ], [$2 ], [ */])]) 44 45 46 47 48# _b4_dollar_dollar(VALUE, SYMBOL-NUM, FIELD, DEFAULT-FIELD) 49# ---------------------------------------------------------- 50# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD", 51# otherwise just VALUE. Be sure to pass "(VALUE)" if VALUE is a 52# pointer. 53m4_define([_b4_dollar_dollar], 54[b4_symbol_value([$1], 55 [$2], 56 m4_if([$3], [[]], 57 [[$4]], [[$3]]))]) 58 59# b4_dollar_pushdef(VALUE-POINTER, SYMBOL-NUM, [TYPE_TAG], LOCATION) 60# b4_dollar_popdef 61# ------------------------------------------------------------------ 62# Define b4_dollar_dollar for VALUE-POINTER and DEFAULT-FIELD, 63# and b4_at_dollar for LOCATION. 64m4_define([b4_dollar_pushdef], 65[m4_pushdef([b4_dollar_dollar], 66 [_b4_dollar_dollar([$1], [$2], m4_dquote($][1), [$3])])dnl 67m4_pushdef([b4_at_dollar], [$4])dnl 68]) 69m4_define([b4_dollar_popdef], 70[m4_popdef([b4_at_dollar])dnl 71m4_popdef([b4_dollar_dollar])dnl 72]) 73