comparison src/macros.h @ 18251:c8a53c0daeed v8.1.2120

patch 8.1.2120: some MB_ macros are more complicated than necessary Commit: https://github.com/vim/vim/commit/1614a14901558ca091329315d14a7d5e1b53aa47 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 6 22:00:13 2019 +0200 patch 8.1.2120: some MB_ macros are more complicated than necessary Problem: Some MB_ macros are more complicated than necessary. (Dominique Pelle) Solution: Simplify the macros. Expand inline.
author Bram Moolenaar <Bram@vim.org>
date Sun, 06 Oct 2019 22:15:04 +0200
parents 902845716069
children 9e6d5a4abb1c
comparison
equal deleted inserted replaced
18250:f1d9d3f76c98 18251:c8a53c0daeed
227 * MB_PTR_BACK(): backup a pointer to the previous character, taking care of 227 * MB_PTR_BACK(): backup a pointer to the previous character, taking care of
228 * multi-byte characters if needed. 228 * multi-byte characters if needed.
229 * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. 229 * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
230 * PTR2CHAR(): get character from pointer. 230 * PTR2CHAR(): get character from pointer.
231 */ 231 */
232 /* Get the length of the character p points to, including composing chars */
233 #define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : (*p == NUL ? 0 : 1))
234 /* Advance multi-byte pointer, skip over composing chars. */ 232 /* Advance multi-byte pointer, skip over composing chars. */
235 #define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : (*p == NUL ? 0 : 1) 233 #define MB_PTR_ADV(p) p += (*mb_ptr2len)(p)
236 /* Advance multi-byte pointer, do not skip over composing chars. */ 234 /* Advance multi-byte pointer, do not skip over composing chars. */
237 #define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : (*p == NUL ? 0 : 1) 235 #define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)
238 /* Backup multi-byte pointer. Only use with "p" > "s" ! */ 236 /* Backup multi-byte pointer. Only use with "p" > "s" ! */
239 #define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 237 #define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
240 /* get length of multi-byte char, not including composing chars */ 238 /* get length of multi-byte char, not including composing chars */
241 #define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) 239 #define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
242 240