summaryrefslogtreecommitdiff
path: root/src/macros.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-03-12 19:22:36 +0100
committerBram Moolenaar <Bram@vim.org>2017-03-12 19:22:36 +0100
commit91acfffc1e6c0d8c2abfb186a0e79a5bf19c3f3f (patch)
tree1923145c992a09b3adc06e40f02284ff0ef21bbd /src/macros.h
parent47ffb905f363571072faefbd417938e7ff351a9f (diff)
downloadvim-git-91acfffc1e6c0d8c2abfb186a0e79a5bf19c3f3f.tar.gz
patch 8.0.0451: some macros are in lower casev8.0.0451
Problem: Some macros are in lower case. Solution: Make a few more macros upper case. Avoid lower case macros use an argument twice.
Diffstat (limited to 'src/macros.h')
-rw-r--r--src/macros.h31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/macros.h b/src/macros.h
index 559a4bef0..97e7e8322 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -8,6 +8,9 @@
/*
* macros.h: macro definitions for often used code
+ *
+ * Macros should be ALL_CAPS. An exception is for where a function is
+ * replaced and an argument is not used more than once.
*/
/*
@@ -161,10 +164,10 @@
#endif
/*
- * vim_isbreak() is used very often if 'linebreak' is set, use a macro to make
- * it work fast.
+ * VIM_ISBREAK() is used very often if 'linebreak' is set, use a macro to make
+ * it work fast. Only works for single byte characters!
*/
-#define vim_isbreak(c) (breakat_flags[(char_u)(c)])
+#define VIM_ISBREAK(c) ((c) < 256 && breakat_flags[(char_u)(c)])
/*
* On VMS file names are different and require a translation.
@@ -190,9 +193,7 @@
# define mch_stat(n, p) vim_stat((n), (p))
# else
# ifdef STAT_IGNORES_SLASH
- /* On Solaris stat() accepts "file/" as if it was "file". Return -1 if
- * the name ends in "/" and it's not a directory. */
-# define mch_stat(n, p) (illegal_slash(n) ? -1 : stat((n), (p)))
+# define mch_stat(n, p) vim_stat((n), (p))
# else
# define mch_stat(n, p) stat((n), (p))
# endif
@@ -258,22 +259,22 @@
#endif
/*
- * mb_ptr_adv(): advance a pointer to the next character, taking care of
+ * MB_PTR_ADV(): advance a pointer to the next character, taking care of
* multi-byte characters if needed.
- * mb_ptr_back(): backup a pointer to the previous character, taking care of
+ * MB_PTR_BACK(): backup a pointer to the previous character, taking care of
* multi-byte characters if needed.
* MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
* PTR2CHAR(): get character from pointer.
*/
#ifdef FEAT_MBYTE
/* Get the length of the character p points to */
-# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
+# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
/* Advance multi-byte pointer, skip over composing chars. */
-# define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
+# define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
/* Advance multi-byte pointer, do not skip over composing chars. */
-# define mb_cptr_adv(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
+# define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
/* Backup multi-byte pointer. Only use with "p" > "s" ! */
-# define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
+# define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
/* get length of multi-byte char, not including composing chars */
# define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
@@ -284,9 +285,9 @@
#else
# define MB_PTR2LEN(p) 1
# define MB_CPTR2LEN(p) 1
-# define mb_ptr_adv(p) ++p
-# define mb_cptr_adv(p) ++p
-# define mb_ptr_back(s, p) --p
+# define MB_PTR_ADV(p) ++p
+# define MB_CPTR_ADV(p) ++p
+# define MB_PTR_BACK(s, p) --p
# define MB_COPY_CHAR(f, t) *t++ = *f++
# define MB_CHARLEN(p) STRLEN(p)
# define MB_CHAR2LEN(c) 1