]> git.saurik.com Git - bison.git/blobdiff - data/location.cc
xml: also use "%empty" with html output
[bison.git] / data / location.cc
index 309b9c0f7432098d2624393908e756adf189aa34..e80742a51f7d93d91c805e2a148a28f37ae53d31 100644 (file)
@@ -27,7 +27,7 @@ m4_define([b4_position_define],
   {
   public:]m4_ifdef([b4_location_constructors], [[
     /// Construct a position.
   {
   public:]m4_ifdef([b4_location_constructors], [[
     /// Construct a position.
-    explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,
+    explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
                        unsigned int l = ]b4_location_initial_line[u,
                        unsigned int c = ]b4_location_initial_column[u)
       : filename (f)
                        unsigned int l = ]b4_location_initial_line[u,
                        unsigned int c = ]b4_location_initial_column[u)
       : filename (f)
@@ -38,7 +38,7 @@ m4_define([b4_position_define],
 
 ]])[
     /// Initialization.
 
 ]])[
     /// Initialization.
-    void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL,
+    void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
                      unsigned int l = ]b4_location_initial_line[u,
                      unsigned int c = ]b4_location_initial_column[u)
     {
                      unsigned int l = ]b4_location_initial_line[u,
                      unsigned int c = ]b4_location_initial_column[u)
     {
@@ -55,20 +55,14 @@ m4_define([b4_position_define],
       if (count)
         {
           column = ]b4_location_initial_column[u;
       if (count)
         {
           column = ]b4_location_initial_column[u;
-          line =
-            0 < count || -count < line
-            ? line + count
-            : ]b4_location_initial_line[;
+          line = add_ (line, count, ]b4_location_initial_line[);
         }
     }
 
     /// (column related) Advance to the COUNT next columns.
     void columns (int count = 1)
     {
         }
     }
 
     /// (column related) Advance to the COUNT next columns.
     void columns (int count = 1)
     {
-      column =
-        0 < count || -count < column
-        ? column + count
-        : ]b4_location_initial_column[;
+      column = add_ (column, count, ]b4_location_initial_column[);
     }
     /** \} */
 
     }
     /** \} */
 
@@ -78,6 +72,15 @@ m4_define([b4_position_define],
     unsigned int line;
     /// Current column number.
     unsigned int column;
     unsigned int line;
     /// Current column number.
     unsigned int column;
+
+  private:
+    /// Compute max(min, lhs+rhs) (provided min <= lhs).
+    static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min)
+    {
+      return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs
+              ? rhs + lhs
+              : min);
+    }
   };
 
   /// Add and assign a position.
   };
 
   /// Add and assign a position.
@@ -175,7 +178,7 @@ m4_define([b4_location_define],
 
 ])[
     /// Initialization.
 
 ])[
     /// Initialization.
-    void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,
+    void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
                      unsigned int l = ]b4_location_initial_line[u,
                      unsigned int c = ]b4_location_initial_column[u)
     {
                      unsigned int l = ]b4_location_initial_line[u,
                      unsigned int c = ]b4_location_initial_column[u)
     {