X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/6ce4b4ff1b761a0408cf94abb308fac9b55edd3d..7ba01e111c878291d8677db124eb4d7aef7c9541:/data/location.cc?ds=sidebyside diff --git a/data/location.cc b/data/location.cc index 309b9c0f..9a60f250 100644 --- a/data/location.cc +++ b/data/location.cc @@ -55,20 +55,14 @@ m4_define([b4_position_define], 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 = - 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; + + 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(rhs) < lhs + ? rhs + lhs + : min); + } }; /// Add and assign a position.