A quoted use of __line__ was not expanded in the skeletons.

There used to be a problem with a direct use of __file__ as the
user is free to use @ etc. in her directory names, what became
a problem to our post-m4 pass.  Hence the dirname invocation here.


Index: ChangeLog
from  Akim Demaille  <[EMAIL PROTECTED]>

        * data/c.m4 (b4_dirname): New.
        (b4_syncline): Also output the location of its invocation (from
        the skeleton).
        * data/yacc.c, data/glr.c, data/lalr1.cc, data/glr.cc: Adjust.

Index: data/c.m4
===================================================================
RCS file: /cvsroot/bison/bison/data/c.m4,v
retrieving revision 1.58
diff -u -r1.58 c.m4
--- data/c.m4 20 Jun 2006 11:32:19 -0000 1.58
+++ data/c.m4 8 Jul 2006 14:22:24 -0000
@@ -403,11 +403,51 @@
 ## Synclines.  ##
 ## ----------- ##
 
+# b4_basename(NAME)
+# -----------------
+# Beware that NAME is not evaluated.
+m4_define([b4_basename],
+[m4_case([$1],
+         [/], [/],
+             [m4_bpatsubst([$1], [^.*/\([^/]+\)/?$], [\1])])])
+        
+
 # b4_syncline(LINE, FILE)
 # -----------------------
 m4_define([b4_syncline],
-[b4_flag_if([synclines], [[#]line $1 $2])])
+[b4_flag_if([synclines], 
+[/* Line __line__ of b4_basename(m4_quote(__file__)).  */
+[#]line $1 $2])])
+
 
+# b4_user_code(USER-CODE)
+# -----------------------
+# Emit code from the user, ending it with synclines.
+m4_define([b4_user_code],
+[$1
+b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])])
+
+
+# b4_define_user_code(MACRO)
+# --------------------------
+# From b4_MACRO, build b4_user_MACRO that includes the synclines.
+m4_define([b4_define_user_code],
+[m4_define([b4_user_$1],
+[b4_user_code([b4_$1])])])
+
+
+# b4_user_actions
+# b4_user_initial_action
+# b4_user_post_prologue
+# b4_user_start_header
+# b4_user_stype
+# ----------------------
+# Macros that issue user code, ending with synclines.
+b4_define_user_code([actions])
+b4_define_user_code([initial_action])
+b4_define_user_code([post_prologue])
+b4_define_user_code([start_header])
+b4_define_user_code([stype])
 
 
 ## -------------- ##
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.182
diff -u -r1.182 glr.c
--- data/glr.c 23 Jun 2006 20:17:27 -0000 1.182
+++ data/glr.c 8 Jul 2006 14:22:25 -0000
@@ -178,9 +178,7 @@
 [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 ]m4_ifdef([b4_stype],
 [typedef union b4_union_name
-b4_stype
-/* Line __line__ of glr.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
+b4_user_stype
        YYSTYPE;],
 [typedef int YYSTYPE;])[
 # define YYSTYPE_IS_DECLARED 1
@@ -237,11 +235,8 @@
 static YYSTYPE yyval_default;
 
 /* Copy the second part of user declarations.  */
-]b4_post_prologue[
+]b4_user_post_prologue[
 
-]/* Line __line__ of glr.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
-[
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -934,9 +929,7 @@
 ]])[
   switch (yyn)
     {
-      ]b4_actions
-/* Line __line__ of glr.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+      ]b4_user_actions[
       default: break;
     }
 
@@ -2318,11 +2311,9 @@
 m4_pushdef([b4_at_dollar],     [yylloc])dnl
 m4_pushdef([b4_dollar_dollar], [yylval])dnl
   /* User initialization code.  */
-  b4_initial_action
+  b4_user_initial_action
 m4_popdef([b4_dollar_dollar])dnl
-m4_popdef([b4_at_dollar])dnl
-/* Line __line__ of glr.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])])dnl
+m4_popdef([b4_at_dollar])])dnl
 [
   if (! yyinitGLRStack (yystackp, YYINITDEPTH))
     goto yyexhaustedlab;
Index: data/glr.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.cc,v
retrieving revision 1.22
diff -u -r1.22 glr.cc
--- data/glr.cc 23 Jun 2006 20:17:27 -0000 1.22
+++ data/glr.cc 8 Jul 2006 14:22:25 -0000
@@ -90,8 +90,7 @@
 
 # Declare yyerror.
 m4_append([b4_post_prologue],
-[/* Line __line__ of glr.cc.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
+[b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
 
 b4_c_ansi_function_decl([yyerror],
     [static void],
@@ -102,8 +101,7 @@
 
 # Define yyerror.
 m4_append([b4_epilogue],
-[/* Line __line__ of glr.cc.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+[b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
 /*------------------.
 | Report an error.  |
 `------------------*/
@@ -237,10 +235,7 @@
 
 ]m4_ifdef([b4_start_header],
 [[/* Copy the %start-header blocks.  */
-]b4_start_header])[]dnl
-
-[/* Line __line__ of glr.cc.  */
-]b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+]b4_user_start_header])[
 
 #include "location.hh"
 
@@ -291,9 +286,7 @@
 #ifndef YYSTYPE
 ]m4_ifdef([b4_stype],
 [    union semantic_type
-b4_stype
-/* Line __line__ of lalr1.cc.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
+b4_user_stype
        ;],
 [    typedef int semantic_type;])[
 #else
Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.135
diff -u -r1.135 lalr1.cc
--- data/lalr1.cc 23 Jun 2006 20:17:27 -0000 1.135
+++ data/lalr1.cc 8 Jul 2006 14:22:25 -0000
@@ -55,10 +55,7 @@
 
 ]m4_ifdef([b4_start_header],
 [[/* Copy the %start-header blocks.  */
-]b4_start_header])[]dnl
-
-[/* Line __line__ of lalr1.cc.  */
-]b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+]b4_user_start_header])[
 
 ]dnl Include location.hh here: it might depend on headers included above.
 [#include "location.hh"
@@ -111,9 +108,7 @@
 #ifndef YYSTYPE
 ]m4_ifdef([b4_stype],
 [    union semantic_type
-b4_stype
-/* Line __line__ of lalr1.cc.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
+b4_user_stype
        ;],
 [    typedef int semantic_type;])[
 #else
@@ -321,10 +316,7 @@
 #include @[EMAIL PROTECTED])[
 
 /* User implementation prologue.  */
-]b4_post_prologue[
-
-]/* Line __line__ of lalr1.cc.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+]b4_user_post_prologue[
 
 #ifndef YY_
 # if YYENABLE_NLS
@@ -557,11 +549,9 @@
 m4_pushdef([b4_at_dollar],     [yylloc])dnl
 m4_pushdef([b4_dollar_dollar], [yylval])dnl
     /* User initialization code.  */
-    b4_initial_action
+    b4_user_initial_action
 m4_popdef([b4_dollar_dollar])dnl
-m4_popdef([b4_at_dollar])dnl
-  /* Line __line__ of yacc.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])])dnl
+m4_popdef([b4_at_dollar])])dnl
 
   [  /* Initialize the stacks.  The initial state will be pushed in
        yynewstate, since the latter expects the semantical and the
@@ -680,9 +670,7 @@
     YY_REDUCE_PRINT (yyn);
     switch (yyn)
       {
-       ]b4_actions
-    /* Line __line__ of lalr1.cc.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+       ]b4_user_actions[
        default: break;
       }
     YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
Index: data/yacc.c
===================================================================
RCS file: /cvsroot/bison/bison/data/yacc.c,v
retrieving revision 1.146
diff -u -r1.146 yacc.c
--- data/yacc.c 23 Jun 2006 20:17:27 -0000 1.146
+++ data/yacc.c 8 Jul 2006 14:22:26 -0000
@@ -190,9 +190,7 @@
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 ]m4_ifdef([b4_stype],
 [[typedef union ]b4_union_name
-b4_stype
-/* Line __line__ of yacc.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
+b4_user_stype
        YYSTYPE;],
 [typedef int YYSTYPE;])[
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -218,10 +216,7 @@
 ]b4_end_header])[]dnl
 
 [/* Copy the second part of user declarations.  */
-]b4_post_prologue
-
-[/* Line __line__ of yacc.c.  */
-]b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+]b4_user_post_prologue[
 
 #ifdef short
 # undef short
@@ -1077,12 +1072,9 @@
 m4_pushdef([b4_at_dollar],     [m4_define([b4_at_dollar_used])yylloc])dnl
 m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
   /* User initialization code.  */
-b4_initial_action
+  b4_user_initial_action
 m4_popdef([b4_dollar_dollar])dnl
-m4_popdef([b4_at_dollar])dnl
-/* Line __line__ of yacc.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
-])dnl
+m4_popdef([b4_at_dollar])])dnl
 m4_ifdef([b4_dollar_dollar_used],[[  yyvsp[0] = yylval;
 ]])dnl
 m4_ifdef([b4_at_dollar_used], [[  yylsp[0] = yylloc;
@@ -1270,9 +1262,7 @@
   YY_REDUCE_PRINT (yyn);
   switch (yyn)
     {
-      ]b4_actions
-/* Line __line__ of yacc.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])[
+      ]b4_user_actions[
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1507,9 +1497,7 @@
 [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 ]m4_ifdef([b4_stype],
 [[typedef union ]b4_union_name
-b4_stype
-/* Line __line__ of yacc.c.  */
-b4_syncline([EMAIL PROTECTED]@], [EMAIL PROTECTED]@])
+b4_user_stype
        YYSTYPE;],
 [typedef int YYSTYPE;])[
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */

Reply via email to