aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/menu.c')
-rw-r--r--src/nvim/menu.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index ab28eeca1c..aa76b8010d 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -13,6 +13,7 @@
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor.h"
+#include "nvim/errors.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
@@ -60,7 +61,7 @@ static const char e_nomenu[] = N_("E329: No menu \"%s\"");
static bool menu_is_winbar(const char *const name)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
- return (strncmp(name, "WinBar", 6) == 0);
+ return (strncmp(name, S_LEN("WinBar")) == 0);
}
static vimmenu_T **get_root_menu(const char *const name)
@@ -89,17 +90,17 @@ void ex_menu(exarg_T *eap)
char *arg = eap->arg;
while (true) {
- if (strncmp(arg, "<script>", 8) == 0) {
+ if (strncmp(arg, S_LEN("<script>")) == 0) {
noremap = REMAP_SCRIPT;
arg = skipwhite(arg + 8);
continue;
}
- if (strncmp(arg, "<silent>", 8) == 0) {
+ if (strncmp(arg, S_LEN("<silent>")) == 0) {
silent = true;
arg = skipwhite(arg + 8);
continue;
}
- if (strncmp(arg, "<special>", 9) == 0) {
+ if (strncmp(arg, S_LEN("<special>")) == 0) {
// Ignore obsolete "<special>" modifier.
arg = skipwhite(arg + 9);
continue;
@@ -109,7 +110,7 @@ void ex_menu(exarg_T *eap)
// Locate an optional "icon=filename" argument
// TODO(nvim): Currently this is only parsed. Should expose it to UIs.
- if (strncmp(arg, "icon=", 5) == 0) {
+ if (strncmp(arg, S_LEN("icon=")) == 0) {
arg += 5;
while (*arg != NUL && *arg != ' ') {
if (*arg == '\\') {
@@ -152,10 +153,10 @@ void ex_menu(exarg_T *eap)
pri_tab[MENUDEPTH] = -1; // mark end of the table
// Check for "disable" or "enable" argument.
- if (strncmp(arg, "enable", 6) == 0 && ascii_iswhite(arg[6])) {
+ if (strncmp(arg, S_LEN("enable")) == 0 && ascii_iswhite(arg[6])) {
enable = kTrue;
arg = skipwhite(arg + 6);
- } else if (strncmp(arg, "disable", 7) == 0 && ascii_iswhite(arg[7])) {
+ } else if (strncmp(arg, S_LEN("disable")) == 0 && ascii_iswhite(arg[7])) {
enable = kFalse;
arg = skipwhite(arg + 7);
}
@@ -888,10 +889,10 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for
}
if (!ascii_iswhite(*p)) {
- if (strncmp(arg, "enable", 6) == 0
+ if (strncmp(arg, S_LEN("enable")) == 0
&& (arg[6] == NUL || ascii_iswhite(arg[6]))) {
p = arg + 6;
- } else if (strncmp(arg, "disable", 7) == 0
+ } else if (strncmp(arg, S_LEN("disable")) == 0
&& (arg[7] == NUL || ascii_iswhite(arg[7]))) {
p = arg + 7;
} else {
@@ -1056,7 +1057,7 @@ char *get_menu_names(expand_T *xp, int idx)
}
// hack on menu separators: use a 'magic' char for the separator
// so that '.' in names gets escaped properly
- STRCAT(tbuffer, "\001");
+ strcat(tbuffer, "\001");
str = tbuffer;
} else {
if (should_advance) {
@@ -1332,14 +1333,14 @@ bool menu_is_menubar(const char *const name)
bool menu_is_popup(const char *const name)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
- return strncmp(name, "PopUp", 5) == 0;
+ return strncmp(name, S_LEN("PopUp")) == 0;
}
// Return true if "name" is a toolbar menu name.
bool menu_is_toolbar(const char *const name)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
- return strncmp(name, "ToolBar", 7) == 0;
+ return strncmp(name, S_LEN("ToolBar")) == 0;
}
/// @return true if the name is a menu separator identifier: Starts and ends
@@ -1700,7 +1701,7 @@ void ex_menutranslate(exarg_T *eap)
}
// ":menutrans clear": clear all translations.
- if (strncmp(arg, "clear", 5) == 0 && ends_excmd(*skipwhite(arg + 5))) {
+ if (strncmp(arg, S_LEN("clear")) == 0 && ends_excmd(*skipwhite(arg + 5))) {
GA_DEEP_CLEAR(&menutrans_ga, menutrans_T, FREE_MENUTRANS);
// Delete all "menutrans_" global variables.