]> git.saurik.com Git - bison.git/commitdiff
Fix strange %define locations for default values.
authorJoel E. Denny <jdenny@ces.clemson.edu>
Fri, 3 Apr 2009 07:13:36 +0000 (03:13 -0400)
committerJoel E. Denny <jdenny@ces.clemson.edu>
Fri, 3 Apr 2009 07:56:58 +0000 (03:56 -0400)
Reported by Akim Demaille at
<http://lists.gnu.org/archive/html/bug-bison/2007-12/msg00001.html>
and discussed again starting at
<http://lists.gnu.org/archive/html/bison-patches/2008-11/msg00102.html>.
* data/bison.m4 (b4_percent_define_default): Leave syncline blank
because location information is bogus.
Use angle brackets to delimit fake file name because square brackets
look like over-quoted m4.  Choose a better fake file name.
Use negative line numbers.
* src/muscle_tab.c (muscle_percent_define_default): Likewise.
* src/location.c (location_print): If line for a boundary is negative,
only print that boundary's file name.
* src/location.h: Document that.
* tests/skeletons.at (%define Boolean variables: invalid skeleton
defaults): Update output.

ChangeLog
data/bison.m4
src/location.c
src/location.h
src/muscle_tab.c
tests/skeletons.at

index 0bebbdfda47aca6eaf0edda6a538bf1120dbd884..e0c738b91dfcb2e4a1c2b0880b438087c0502717 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2009-04-03  Joel E. Denny  <jdenny@ces.clemson.edu>
+
+       Fix strange %define locations for default values.
+       Reported by Akim Demaille at
+       <http://lists.gnu.org/archive/html/bug-bison/2007-12/msg00001.html>
+       and discussed again starting at
+       <http://lists.gnu.org/archive/html/bison-patches/2008-11/msg00102.html>.
+       * data/bison.m4 (b4_percent_define_default): Leave syncline blank
+       because location information is bogus.
+       Use angle brackets to delimit fake file name because square brackets
+       look like underexpanded m4.  Choose a better fake file name.
+       Use negative line numbers.
+       * src/muscle_tab.c (muscle_percent_define_default): Likewise.
+       * src/location.c (location_print): If line for a boundary is negative,
+       only print that boundary's file name.
+       * src/location.h: Document that.
+       * tests/skeletons.at (%define Boolean variables: invalid skeleton
+       defaults): Update output.
+
 2008-11-07  Akim Demaille  <demaille@gostai.com>
 
        Locations without columns for command line arguments.
 2008-11-07  Akim Demaille  <demaille@gostai.com>
 
        Locations without columns for command line arguments.
index bad629631ba107d695a50e825f94c838b21e15ed..f9dd503d74a23446f6257f5f39ae64013b68cc44 100644 (file)
@@ -1,8 +1,8 @@
                                                             -*- Autoconf -*-
 
 # Language-independent M4 Macros for Bison.
                                                             -*- Autoconf -*-
 
 # Language-independent M4 Macros for Bison.
-# Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008 Free Software Foundation,
-# Inc.
+# Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+# Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -464,10 +464,9 @@ m4_define([b4_percent_define_default],
 [m4_ifndef([b4_percent_define(]$1[)],
            [m4_define([b4_percent_define(]$1[)], [$2])dnl
             m4_define([b4_percent_define_loc(]$1[)],
 [m4_ifndef([b4_percent_define(]$1[)],
            [m4_define([b4_percent_define(]$1[)], [$2])dnl
             m4_define([b4_percent_define_loc(]$1[)],
-                      [[[[[Bison:b4_percent_define_default]:1.0]], [[[Bison:b4_percent_define_default]:1.0]]]])dnl
-            m4_define([b4_percent_define_syncline(]$1[)],
-                      [[]b4_syncline(1, [["[Bison:b4_percent_define_default]"]])[
-]])])])
+                      [[[[<skeleton default value>:-1.-1]],
+                        [[<skeleton default value>:-1.-1]]]])dnl
+            m4_define([b4_percent_define_syncline(]$1[)], [[]])])])
 
 # b4_percent_define_check_values(VALUES)
 # --------------------------------------
 
 # b4_percent_define_check_values(VALUES)
 # --------------------------------------
index 98627a559c2c02204d43c55e33b422dd7b12f412..4cbfd8db0c03c386e2dae197cefab0ddbccf9366 100644 (file)
@@ -1,5 +1,6 @@
 /* Locations for Bison
 /* Locations for Bison
-   Copyright (C) 2002, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+   Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -100,21 +101,37 @@ location_compute (location *loc, boundary *cur, char const *token, size_t size)
 void
 location_print (FILE *out, location loc)
 {
 void
 location_print (FILE *out, location loc)
 {
-  int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
-  fprintf (out, "%s:%d",
-          quotearg_n_style (3, escape_quoting_style, loc.start.file),
-          loc.start.line);
-  if (0 <= loc.start.column)
-    fprintf (out, ".%d", loc.start.column);
-
+  int end_col = 0 != loc.end.column ? loc.end.column - 1 : 0;
+  fprintf (out, "%s",
+           quotearg_n_style (3, escape_quoting_style, loc.start.file));
+  if (0 <= loc.start.line)
+    {
+      fprintf(out, ":%d", loc.start.line);
+      if (0 <= loc.start.column)
+        fprintf (out, ".%d", loc.start.column);
+    }
   if (loc.start.file != loc.end.file)
   if (loc.start.file != loc.end.file)
-    fprintf (out, "-%s:%d.%d",
-            quotearg_n_style (3, escape_quoting_style, loc.end.file),
-            loc.end.line, end_col);
-  else if (loc.start.line < loc.end.line)
-    fprintf (out, "-%d.%d", loc.end.line, end_col);
-  else if (0 <= loc.start.column && loc.start.column < end_col)
-    fprintf (out, "-%d", end_col);
+    {
+      fprintf (out, "-%s",
+               quotearg_n_style (3, escape_quoting_style, loc.end.file));
+      if (0 <= loc.end.line)
+        {
+          fprintf(out, ":%d", loc.end.line);
+          if (0 <= end_col)
+            fprintf (out, ".%d", end_col);
+        }
+    }
+  else if (0 <= loc.end.line)
+    {
+      if (loc.start.line < loc.end.line)
+        {
+          fprintf (out, "-%d", loc.end.line);
+          if (0 <= end_col)
+            fprintf (out, ".%d", end_col);
+        }
+      else if (0 <= end_col && loc.start.column < end_col)
+        fprintf (out, "-%d", end_col);
+    }
 }
 
 void
 }
 
 void
index efd256dd9529b40f10c15d2479073f34a8378136..a99232bdab0b88709facf867a243bbd374ef801a 100644 (file)
@@ -1,5 +1,6 @@
 /* Locations for Bison
 /* Locations for Bison
-   Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+   Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -27,8 +28,11 @@ typedef struct
   /* The name of the file that contains the boundary.  */
   uniqstr file;
 
   /* The name of the file that contains the boundary.  */
   uniqstr file;
 
-  /* The (origin-1) line that contains the boundary.
-     If this is INT_MAX, the line number has overflowed.  */
+  /* If nonnegative, the (origin-1) line that contains the boundary.
+     If this is INT_MAX, the line number has overflowed.
+
+     Meaningless and not displayed if negative.
+  */
   int line;
 
   /* If nonnegative, the (origin-1) column just after the boundary.
   int line;
 
   /* If nonnegative, the (origin-1) column just after the boundary.
index afe59becab0be10d0f144e2b3d0b61d2c6fda364..43415716b1b4d40b31917850e08c1e40b88400b3 100644 (file)
@@ -1,6 +1,6 @@
 /* Muscle table manager for Bison.
 
 /* Muscle table manager for Bison.
 
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Free Software
    Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
    Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
@@ -540,13 +540,12 @@ muscle_percent_define_default (char const *variable, char const *value)
     {
       location loc;
       MUSCLE_INSERT_STRING (name, value);
     {
       location loc;
       MUSCLE_INSERT_STRING (name, value);
-      loc.start.file = loc.end.file = "[Bison:muscle_percent_define_default]";
-      loc.start.line = loc.end.line = 1;
-      loc.start.column = loc.end.column = 0;
+      loc.start.file = loc.end.file = "<default value>";
+      loc.start.line = loc.end.line = -1;
+      loc.start.column = loc.end.column = -1;
       muscle_insert (loc_name, "");
       muscle_location_grow (loc_name, loc);
       muscle_insert (syncline_name, "");
       muscle_insert (loc_name, "");
       muscle_location_grow (loc_name, loc);
       muscle_insert (syncline_name, "");
-      muscle_syncline_grow (syncline_name, loc);
     }
 }
 
     }
 }
 
index 3845d3dd75b32f12137df354cc7937cf0768ccfe..60fc1176ca5decb98f25f1adf0bb01b01374d298 100644 (file)
@@ -1,5 +1,5 @@
 # Checking skeleton support.                     -*- Autotest -*-
 # Checking skeleton support.                     -*- Autotest -*-
-# Copyright (C) 2007 Free Software Foundation, Inc.
+# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -159,7 +159,7 @@ start: ;
 ]])
 
 AT_BISON_CHECK([[input.y]], [[1]], [[]],
 ]])
 
 AT_BISON_CHECK([[input.y]], [[1]], [[]],
-[[[Bison:b4_percent_define_default]:1.0: invalid value for %define Boolean variable `foo'
+[[<skeleton default value>: invalid value for %define Boolean variable `foo'
 ]])
 
 AT_CLEANUP
 ]])
 
 AT_CLEANUP