c-like.m4 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. -*- Autoconf -*-
  2. # Common code for C-like languages (C, C++, Java, etc.)
  3. # Copyright (C) 2012-2015, 2018-2021 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. # _b4_comment(TEXT, OPEN, CONTINUE, END)
  17. # --------------------------------------
  18. # Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
  19. # Avoid adding indentation to the first line, as the indentation comes
  20. # from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
  21. # Turn "*/" in TEXT into "* /" so that we don't unexpectedly close
  22. # the comments before its end.
  23. #
  24. # Prefix all the output lines with PREFIX.
  25. m4_define([_b4_comment],
  26. [$2[]b4_gsub(m4_expand([$1]),
  27. [[*]/], [*\\/],
  28. [/[*]], [/\\*],
  29. [
  30. \(.\)], [
  31. $3\1])$4])
  32. # b4_comment(TEXT, [PREFIX])
  33. # --------------------------
  34. # Put TEXT in comment. Prefix all the output lines with PREFIX.
  35. m4_define([b4_comment],
  36. [_b4_comment([$1], [$2/* ], [$2 ], [ */])])
  37. # _b4_dollar_dollar(VALUE, SYMBOL-NUM, FIELD, DEFAULT-FIELD)
  38. # ----------------------------------------------------------
  39. # If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
  40. # otherwise just VALUE. Be sure to pass "(VALUE)" if VALUE is a
  41. # pointer.
  42. m4_define([_b4_dollar_dollar],
  43. [b4_symbol_value([$1],
  44. [$2],
  45. m4_if([$3], [[]],
  46. [[$4]], [[$3]]))])
  47. # b4_dollar_pushdef(VALUE-POINTER, SYMBOL-NUM, [TYPE_TAG], LOCATION)
  48. # b4_dollar_popdef
  49. # ------------------------------------------------------------------
  50. # Define b4_dollar_dollar for VALUE-POINTER and DEFAULT-FIELD,
  51. # and b4_at_dollar for LOCATION.
  52. m4_define([b4_dollar_pushdef],
  53. [m4_pushdef([b4_dollar_dollar],
  54. [_b4_dollar_dollar([$1], [$2], m4_dquote($][1), [$3])])dnl
  55. m4_pushdef([b4_at_dollar], [$4])dnl
  56. ])
  57. m4_define([b4_dollar_popdef],
  58. [m4_popdef([b4_at_dollar])dnl
  59. m4_popdef([b4_dollar_dollar])dnl
  60. ])