]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_utils.C
fix pullArg when pressing <Delete> at the end of an cell
[lyx.git] / src / mathed / math_utils.C
index 0d9c61c1e4bfaebdf630ea4e514bda72888cdb9a..0773885ed07efe7e92da2d1307b58dd5e49f7317 100644 (file)
@@ -9,8 +9,6 @@
  *  License: GNU GPL version 2 or later
  */
 
-#include <config.h>
-
 #include <algorithm>
 
 #include "math_defs.h"
 using std::sort;
 using std::lower_bound;
 
+namespace {
+
 // This table includes all binary operators and relations
 struct binary_op_pair {
        short id;
        short isrel;
 };
 
+
 binary_op_pair binary_op_table[] = {
       { LM_leq, LMB_RELATION }, { LM_geq, LMB_RELATION }, 
       { LM_equiv, LMB_RELATION }, { LM_models, LMB_RELATION }, 
@@ -63,35 +64,34 @@ binary_op_pair binary_op_table[] = {
 };
 
 
-struct compara {
-       // used by sort
+struct comparator {
+       // used by sort and lower_bound
        inline
-       int operator()(binary_op_pair const & a,
-                      binary_op_pair const & b) const {
+       int operator()(binary_op_pair const & a, binary_op_pair const & b) const
+       {
                return a.id < b.id;
        }
-       // used by lower_bound
-       inline
-       int operator()(binary_op_pair const & a, short int id) const {
-               return a.id < id;
-       }
 };
 
+} // namespace anon
+
 
-int MathedLookupBOP(short id)
+int MathLookupBOP(short id)
 {
        static int const bopCount =
                sizeof(binary_op_table) / sizeof(binary_op_pair);
        static bool issorted = false;
        
        if (!issorted) {
-               sort(binary_op_table, binary_op_table + bopCount, compara());
+               sort(binary_op_table, binary_op_table + bopCount, comparator());
                issorted = true;
        }
+
+       binary_op_pair search_elem = { id, 0 };
        
        binary_op_pair * res = lower_bound(binary_op_table,
                                           binary_op_table + bopCount,
-                                          id, compara());
+                                          search_elem, comparator());
        if (res != binary_op_table + bopCount && res->id == id)
                return res->isrel;
        else