]> git.saurik.com Git - bison.git/blobdiff - data/c.m4
%define variables: support value changes in deprecation
[bison.git] / data / c.m4
index 91126a82b84ef325cb83ed406f5d4b0fdf33c2a1..b6f77d8fa046d69946f8304dd54e6b1c9a1ab356 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -58,20 +58,17 @@ m4_define([b4_cpp_guard_close],
 # from OPEN.  That's why we don't patsubst([$1], [^\(.\)], [   \1]).
 #
 # Prefix all the output lines with PREFIX.
-m4_define([b4_comment_], [$2[]m4_bpatsubst([$1], [
+m4_define([b4_comment_],
+[$2[]m4_bpatsubst(m4_expand([$1]), [
 \(.\)], [
 $3\1])$4])
 
 
 # b4_comment(TEXT, [PREFIX])
 # --------------------------
-# Put TEXT in comment.  Avoid trailing spaces: don't indent empty lines.
-# Avoid adding indentation to the first line, as the indentation comes
-# from "/*".  That's why we don't patsubst([$1], [^\(.\)], [   \1]).
-#
-# Prefix all the output lines with PREFIX.
+# Put TEXT in comment.  Prefix all the output lines with PREFIX.
 m4_define([b4_comment],
-[b4_comment_([$1], [$2/* ], [$2   ], [$2  */])])
+[b4_comment_([$1], [$2/* ], [$2   ], [  */])])
 
 
 # b4_identification
@@ -610,14 +607,40 @@ m4_define([b4_yy_location_print_define],
 
 #ifndef YY_LOCATION_PRINT
 # if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
+
+/* Print *YYLOCP on YYO.  Private, do not rely on its existence. */
+
+__attribute__((__unused__))
+]b4_function_define([yy_location_print_],
+    [static unsigned],
+               [[FILE *yyo],                    [yyo]],
+               [[YYLTYPE const * const yylocp], [yylocp]])[
+{
+  unsigned res = 0;
+  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
+  if (0 <= yylocp->first_line)
+    {
+      res += fprintf (yyo, "%d", yylocp->first_line);
+      if (0 <= yylocp->first_column)
+        res += fprintf (yyo, ".%d", yylocp->first_column);
+    }
+  if (0 <= yylocp->last_line)
+    {
+      if (yylocp->first_line < yylocp->last_line)
+        {
+          res += fprintf (yyo, "-%d", yylocp->last_line);
+          if (0 <= end_col)
+            res += fprintf (yyo, ".%d", end_col);
+        }
+      else if (0 <= end_col && yylocp->first_column < end_col)
+        res += fprintf (yyo, "-%d", end_col);
+    }
+  return res;
+ }
+
 #  define YY_LOCATION_PRINT(File, Loc)                                   \
-  do {                                                                   \
-    fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column);       \
-    if ((Loc).first_line < (Loc).last_line)                              \
-      fprintf (File, "-%d.%d", (Loc).last_line,  (Loc).last_column - 1); \
-    else if ((Loc).first_column < (Loc).last_column - 1)                 \
-      fprintf (File, "-%d", (Loc).last_column - 1);                      \
-  } while (0)
+  yy_location_print_ (File, &(Loc))
+
 # else
 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 # endif