From ff34c91194f9ab9d02808f2880029c38a4655eb5 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 17 Apr 2023 17:23:47 +0100 Subject: vim-patch:9.0.1330: handling new value of an option has a long "else if" chain Problem: Handling new value of an option has a long "else if" chain. Solution: Use a function pointer. (Yegappan Lakshmanan, closes vim/vim#12015) https://github.com/vim/vim/commit/af93691b53f38784efce0b93fe7644c44a7e382e --- src/nvim/mapping.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/nvim/mapping.c') diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 9a835e0eb8..a2f2ed4d86 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -2386,7 +2386,7 @@ void langmap_init(void) /// Called when langmap option is set; the language map can be /// changed at any time! -void langmap_set(void) +const char *did_set_langmap(optset_T *args FUNC_ATTR_UNUSED) { char *p; char *p2; @@ -2434,9 +2434,11 @@ void langmap_set(void) } } if (to == NUL) { + // TODO(vim): Need to use errbuf argument for this error message + // and return it. semsg(_("E357: 'langmap': Matching character missing for %s"), transchar(from)); - return; + return NULL; } if (from >= 256) { @@ -2454,8 +2456,10 @@ void langmap_set(void) p = p2; if (p[0] != NUL) { if (p[0] != ',') { + // TODO(vim): Need to use errbuf argument for this error + // message and return it. semsg(_("E358: 'langmap': Extra characters after semicolon: %s"), p); - return; + return NULL; } p++; } @@ -2464,6 +2468,8 @@ void langmap_set(void) } } } + + return NULL; } static void do_exmap(exarg_T *eap, int isabbrev) -- cgit From 5cda9c267ab951c9d3ba05cddd0e8f63b3a7680a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 26 Apr 2023 15:32:48 +0100 Subject: vim-patch:9.0.1359: too many "else if" statements in handling options Problem: Too many "else if" statements in handling options. Solution: Add more functions for handling option changes. (Yegappan Lakshmanan, closes vim/vim#12060) https://github.com/vim/vim/commit/5da901bb68717b2baff6e971c1517219b6ee3a67 --- src/nvim/mapping.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/nvim/mapping.c') diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index a2f2ed4d86..c1d02e89b8 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -2386,7 +2386,7 @@ void langmap_init(void) /// Called when langmap option is set; the language map can be /// changed at any time! -const char *did_set_langmap(optset_T *args FUNC_ATTR_UNUSED) +const char *did_set_langmap(optset_T *args) { char *p; char *p2; @@ -2434,11 +2434,10 @@ const char *did_set_langmap(optset_T *args FUNC_ATTR_UNUSED) } } if (to == NUL) { - // TODO(vim): Need to use errbuf argument for this error message - // and return it. - semsg(_("E357: 'langmap': Matching character missing for %s"), - transchar(from)); - return NULL; + snprintf(args->os_errbuf, args->os_errbuflen, + _("E357: 'langmap': Matching character missing for %s"), + transchar(from)); + return args->os_errbuf; } if (from >= 256) { @@ -2456,10 +2455,10 @@ const char *did_set_langmap(optset_T *args FUNC_ATTR_UNUSED) p = p2; if (p[0] != NUL) { if (p[0] != ',') { - // TODO(vim): Need to use errbuf argument for this error - // message and return it. - semsg(_("E358: 'langmap': Extra characters after semicolon: %s"), p); - return NULL; + snprintf(args->os_errbuf, args->os_errbuflen, + _("E358: 'langmap': Extra characters after semicolon: %s"), + p); + return args->os_errbuf; } p++; } -- cgit