aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mark.h
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2017-04-11 22:44:48 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-04-11 22:44:48 +0200
commit2d72d85b23761383ac7838faed2f7b53bdce8817 (patch)
tree5c4cfe225180ae19b9e6ce3e12f66b810ca23730 /src/nvim/mark.h
parent1b94852ccbd07c2475621651bbd02970d30dbc3b (diff)
downloadrneovim-2d72d85b23761383ac7838faed2f7b53bdce8817.tar.gz
rneovim-2d72d85b23761383ac7838faed2f7b53bdce8817.tar.bz2
rneovim-2d72d85b23761383ac7838faed2f7b53bdce8817.zip
refactor: pos_T macros to functions (#6496)
Diffstat (limited to 'src/nvim/mark.h')
-rw-r--r--src/nvim/mark.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/nvim/mark.h b/src/nvim/mark.h
index c22a102926..a356c1f398 100644
--- a/src/nvim/mark.h
+++ b/src/nvim/mark.h
@@ -4,6 +4,7 @@
#include "nvim/macros.h"
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
+#include "nvim/func_attr.h"
#include "nvim/mark_defs.h"
#include "nvim/memory.h"
#include "nvim/pos.h"
@@ -75,6 +76,45 @@ static inline int mark_local_index(const char name)
: -1))));
}
+static inline bool lt(pos_T, pos_T) REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
+static inline bool equalpos(pos_T, pos_T)
+ REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
+static inline bool ltoreq(pos_T, pos_T)
+ REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
+static inline void clearpos(pos_T *) REAL_FATTR_ALWAYS_INLINE;
+
+/// Return true if position a is before (less than) position b.
+static inline bool lt(pos_T a, pos_T b)
+{
+ if (a.lnum != b.lnum) {
+ return a.lnum < b.lnum;
+ } else if (a.col != b.col) {
+ return a.col < b.col;
+ } else {
+ return a.coladd < b.coladd;
+ }
+}
+
+/// Return true if position a and b are equal.
+static inline bool equalpos(pos_T a, pos_T b)
+{
+ return (a.lnum == b.lnum) && (a.col == b.col) && (a.coladd == b.coladd);
+}
+
+/// Return true if position a is less than or equal to b.
+static inline bool ltoreq(pos_T a, pos_T b)
+{
+ return lt(a, b) || equalpos(a, b);
+}
+
+/// Clear the pos_T structure pointed to by a.
+static inline void clearpos(pos_T *a)
+{
+ a->lnum = 0;
+ a->col = 0;
+ a->coladd = 0;
+}
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "mark.h.generated.h"
#endif