comparison src/map.c @ 31996:ca6bc7c04163 v9.0.1330

patch 9.0.1330: handling new value of an option has a long "else if" chain Commit: https://github.com/vim/vim/commit/af93691b53f38784efce0b93fe7644c44a7e382e Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Feb 20 12:16:39 2023 +0000 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 https://github.com/vim/vim/issues/12015)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 Feb 2023 13:30:05 +0100
parents 096fe1952003
children 8a3f659c7b5e
comparison
equal deleted inserted replaced
31995:95971aa5e525 31996:ca6bc7c04163
3032 3032
3033 /* 3033 /*
3034 * Called when langmap option is set; the language map can be 3034 * Called when langmap option is set; the language map can be
3035 * changed at any time! 3035 * changed at any time!
3036 */ 3036 */
3037 void 3037 char *
3038 langmap_set(void) 3038 did_set_langmap(optset_T *args UNUSED)
3039 { 3039 {
3040 char_u *p; 3040 char_u *p;
3041 char_u *p2; 3041 char_u *p2;
3042 int from, to; 3042 int from, to;
3043 3043
3086 to = (*mb_ptr2char)(p2); 3086 to = (*mb_ptr2char)(p2);
3087 } 3087 }
3088 } 3088 }
3089 if (to == NUL) 3089 if (to == NUL)
3090 { 3090 {
3091 // TODO: Need to use errbuf argument for this error message
3092 // and return it.
3091 semsg(_(e_langmap_matching_character_missing_for_str), 3093 semsg(_(e_langmap_matching_character_missing_for_str),
3092 transchar(from)); 3094 transchar(from));
3093 return; 3095 return NULL;
3094 } 3096 }
3095 3097
3096 if (from >= 256) 3098 if (from >= 256)
3097 langmap_set_entry(from, to); 3099 langmap_set_entry(from, to);
3098 else 3100 else
3108 p = p2; 3110 p = p2;
3109 if (p[0] != NUL) 3111 if (p[0] != NUL)
3110 { 3112 {
3111 if (p[0] != ',') 3113 if (p[0] != ',')
3112 { 3114 {
3115 // TODO: Need to use errbuf argument for this error
3116 // message and return it.
3113 semsg(_(e_langmap_extra_characters_after_semicolon_str), p); 3117 semsg(_(e_langmap_extra_characters_after_semicolon_str), p);
3114 return; 3118 return NULL;
3115 } 3119 }
3116 ++p; 3120 ++p;
3117 } 3121 }
3118 break; 3122 break;
3119 } 3123 }
3120 } 3124 }
3121 } 3125 }
3122 } 3126 }
3127
3128 return NULL;
3123 } 3129 }
3124 #endif 3130 #endif
3125 3131
3126 static void 3132 static void
3127 do_exmap(exarg_T *eap, int isabbrev) 3133 do_exmap(exarg_T *eap, int isabbrev)