summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/macros.h5
-rw-r--r--src/ops.c18
-rw-r--r--src/version.c2
3 files changed, 20 insertions, 5 deletions
diff --git a/src/macros.h b/src/macros.h
index d86097ced3..cc2d11fdd1 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -14,11 +14,6 @@
*/
/*
- * PBYTE(lp, c) - put byte 'c' at position 'lp'
- */
-#define PBYTE(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c))
-
-/*
* Position comparisons
*/
#define LT_POS(a, b) (((a).lnum != (b).lnum) \
diff --git a/src/ops.c b/src/ops.c
index f4524d3d7b..aa6f4af37a 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -17,6 +17,9 @@
static void shift_block(oparg_T *oap, int amount);
static void mb_adjust_opend(oparg_T *oap);
static int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1);
+static void pbyte(pos_T lp, int c);
+#define PBYTE(lp, c) pbyte(lp, c)
+
// Flags for third item in "opchars".
#define OPF_LINES 1 // operator always works on lines
@@ -4349,3 +4352,18 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
restore_lbr(lbr_saved);
#endif
}
+
+// put byte 'c' at position 'lp', but
+// verify, that the position to place
+// is actually safe
+ static void
+pbyte(pos_T lp, int c)
+{
+ char_u *p = ml_get_buf(curbuf, lp.lnum, TRUE);
+ int len = curbuf->b_ml.ml_line_len;
+
+ // safety check
+ if (lp.col >= len)
+ lp.col = (len > 1 ? len - 2 : 0);
+ *(p + lp.col) = c;
+}
diff --git a/src/version.c b/src/version.c
index ba4be27807..4576d5a4c2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1899,
+/**/
1898,
/**/
1897,