Mercurial > vim
comparison src/xdiff/xmacros.h @ 32174:f84e5db372ea v9.0.1418
patch 9.0.1418: the included xdiff code is a bit outdated
Commit: https://github.com/vim/vim/commit/5fedb8a5ab7addb584728c89e809be190de992bf
Author: Yee Cheng Chin <ychin.git@gmail.com>
Date: Mon Mar 20 17:30:52 2023 +0000
patch 9.0.1418: the included xdiff code is a bit outdated
Problem: The included xdiff code is a bit outdated.
Solution: Sync with the latest git xdiff code. (Yee Cheng Chin,
closes #12181)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 20 Mar 2023 18:45:04 +0100 |
parents | d5142d87f898 |
children | 9493de63a3f6 |
comparison
equal
deleted
inserted
replaced
32173:1d3bf14313b6 | 32174:f84e5db372ea |
---|---|
32 #define XDL_ISDIGIT(c) ((c) >= '0' && (c) <= '9') | 32 #define XDL_ISDIGIT(c) ((c) >= '0' && (c) <= '9') |
33 #define XDL_ISSPACE(c) (isspace((unsigned char)(c))) | 33 #define XDL_ISSPACE(c) (isspace((unsigned char)(c))) |
34 #define XDL_ADDBITS(v,b) ((v) + ((v) >> (b))) | 34 #define XDL_ADDBITS(v,b) ((v) + ((v) >> (b))) |
35 #define XDL_MASKBITS(b) ((1UL << (b)) - 1) | 35 #define XDL_MASKBITS(b) ((1UL << (b)) - 1) |
36 #define XDL_HASHLONG(v,b) (XDL_ADDBITS((unsigned long)(v), b) & XDL_MASKBITS(b)) | 36 #define XDL_HASHLONG(v,b) (XDL_ADDBITS((unsigned long)(v), b) & XDL_MASKBITS(b)) |
37 #define XDL_PTRFREE(p) do { if (p) { xdl_free(p); (p) = NULL; } } while (0) | |
38 #define XDL_LE32_PUT(p, v) \ | 37 #define XDL_LE32_PUT(p, v) \ |
39 do { \ | 38 do { \ |
40 unsigned char *__p = (unsigned char *) (p); \ | 39 unsigned char *__p = (unsigned char *) (p); \ |
41 *__p++ = (unsigned char) (v); \ | 40 *__p++ = (unsigned char) (v); \ |
42 *__p++ = (unsigned char) ((v) >> 8); \ | 41 *__p++ = (unsigned char) ((v) >> 8); \ |
48 unsigned char const *__p = (unsigned char const *) (p); \ | 47 unsigned char const *__p = (unsigned char const *) (p); \ |
49 (v) = (unsigned long) __p[0] | ((unsigned long) __p[1]) << 8 | \ | 48 (v) = (unsigned long) __p[0] | ((unsigned long) __p[1]) << 8 | \ |
50 ((unsigned long) __p[2]) << 16 | ((unsigned long) __p[3]) << 24; \ | 49 ((unsigned long) __p[2]) << 16 | ((unsigned long) __p[3]) << 24; \ |
51 } while (0) | 50 } while (0) |
52 | 51 |
52 /* Allocate an array of nr elements, returns NULL on failure */ | |
53 #define XDL_ALLOC_ARRAY(p, nr) \ | |
54 ((p) = SIZE_MAX / sizeof(*(p)) >= (size_t)(nr) \ | |
55 ? xdl_malloc((nr) * sizeof(*(p))) \ | |
56 : NULL) | |
57 | |
58 /* Allocate an array of nr zeroed out elements, returns NULL on failure */ | |
59 #define XDL_CALLOC_ARRAY(p, nr) ((p) = xdl_calloc(nr, sizeof(*(p)))) | |
60 | |
61 /* | |
62 * Ensure array p can accommodate at least nr elements, growing the | |
63 * array and updating alloc (which is the number of allocated | |
64 * elements) as necessary. Frees p and returns -1 on failure, returns | |
65 * 0 on success | |
66 */ | |
67 #define XDL_ALLOC_GROW(p, nr, alloc) \ | |
68 (-!((nr) <= (alloc) || \ | |
69 ((p) = xdl_alloc_grow_helper((p), (nr), &(alloc), sizeof(*(p)))))) | |
53 | 70 |
54 #endif /* #if !defined(XMACROS_H) */ | 71 #endif /* #if !defined(XMACROS_H) */ |