Mercurial > vim
diff src/macros.h @ 11127:506f5d8b7d8b v8.0.0451
patch 8.0.0451: some macros are in lower case
commit https://github.com/vim/vim/commit/91acfffc1e6c0d8c2abfb186a0e79a5bf19c3f3f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 12 19:22:36 2017 +0100
patch 8.0.0451: some macros are in lower case
Problem: Some macros are in lower case.
Solution: Make a few more macros upper case. Avoid lower case macros use an
argument twice.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 12 Mar 2017 19:30:05 +0100 |
parents | 778c10516955 |
children | f4ea50924c6d |
line wrap: on
line diff
--- 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