aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memory.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2023-12-07 01:34:29 +0600
committerFamiu Haque <famiuhaque@proton.me>2023-12-14 16:46:42 +0600
commit3c2c022e5e299ecac4663c3813e2db5e2b099ffa (patch)
tree8cfefb87b8a675e1c29b0caf3e1adca14bf196b5 /src/nvim/memory.c
parent320e9c1c21817fd76b84345018661f70437fa4b5 (diff)
downloadrneovim-3c2c022e5e299ecac4663c3813e2db5e2b099ffa.tar.gz
rneovim-3c2c022e5e299ecac4663c3813e2db5e2b099ffa.tar.bz2
rneovim-3c2c022e5e299ecac4663c3813e2db5e2b099ffa.zip
refactor(options): remove option type macros
Problem: We have `P_(BOOL|NUM|STRING)` macros to represent an option's type, which is redundant because `OptValType` can already do that. The current implementation of option type flags is also too limited to allow adding multitype options in the future. Solution: Remove `P_(BOOL|NUM|STRING)` and replace it with a new `type_flags` attribute in `vimoption_T`. Also do some groundwork for adding multitype options in the future. Side-effects: Attempting to set an invalid keycode option (e.g. `set t_foo=123`) no longer gives an error.
Diffstat (limited to 'src/nvim/memory.c')
-rw-r--r--src/nvim/memory.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index 7036c91c9b..a0786391b5 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -515,6 +515,13 @@ bool strequal(const char *a, const char *b)
return (a == NULL && b == NULL) || (a && b && strcmp(a, b) == 0);
}
+/// Returns true if first `n` characters of strings `a` and `b` are equal. Arguments may be NULL.
+bool strnequal(const char *a, const char *b, size_t n)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ return (a == NULL && b == NULL) || (a && b && strncmp(a, b, n) == 0);
+}
+
// Avoid repeating the error message many times (they take 1 second each).
// Did_outofmem_msg is reset when a character is read.
void do_outofmem_msg(size_t size)