Patch 9.0.1353
Problem:    Too many "else if" statements to handle option values.
Solution:   Add more functions to handle option value changes. (Yegappan
            Lakshmanan, closes #12058)
Files:      src/option.c, src/option.h, src/optiondefs.h, src/optionstr.c,
            src/proto/optionstr.pro, src/structs.h,
            src/testdir/gen_opt_test.vim


*** ../vim-9.0.1352/src/option.c        2023-02-20 12:16:33.332269406 +0000
--- src/option.c        2023-02-25 11:43:57.612573942 +0000
***************
*** 3898,3903 ****
--- 3898,3904 ----
        args.os_oldval.boolean = old_value;
        args.os_newval.boolean = value;
        args.os_doskip = FALSE;
+       args.os_errbuf = NULL;
        errmsg = options[opt_idx].opt_did_set_cb(&args);
        if (args.os_doskip)
            return errmsg;
***************
*** 4669,4674 ****
--- 4670,4676 ----
        args.os_flags = opt_flags;
        args.os_oldval.number = old_value;
        args.os_newval.number = value;
+       args.os_errbuf = NULL;
        errmsg = options[opt_idx].opt_did_set_cb(&args);
      }
  
*** ../vim-9.0.1352/src/option.h        2023-02-20 12:16:33.332269406 +0000
--- src/option.h        2023-02-25 11:43:57.612573942 +0000
***************
*** 299,305 ****
  #define GO_FOOTER     'F'             // add footer
  #define GO_VERTICAL   'v'             // arrange dialog buttons vertically
  #define GO_KEEPWINSIZE        'k'             // keep GUI window size
! #define GO_ALL                "!aAbcdefFghilmMprtTvk" // all possible flags 
for 'go'
  
  // flags for 'comments' option
  #define COM_NEST      'n'             // comments strings nest
--- 299,306 ----
  #define GO_FOOTER     'F'             // add footer
  #define GO_VERTICAL   'v'             // arrange dialog buttons vertically
  #define GO_KEEPWINSIZE        'k'             // keep GUI window size
! // all possible flags for 'go'
! #define GO_ALL                "!aAbcdefFghilLmMpPrRtTvk"
  
  // flags for 'comments' option
  #define COM_NEST      'n'             // comments strings nest
*** ../vim-9.0.1352/src/optiondefs.h    2023-02-23 15:05:18.917676841 +0000
--- src/optiondefs.h    2023-02-25 11:43:57.612573942 +0000
***************
*** 468,474 ****
                            SCTX_INIT},
      {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
  #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
!                           (char_u *)&p_bexpr, PV_BEXPR, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 468,474 ----
                            SCTX_INIT},
      {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
  #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
!                           (char_u *)&p_bexpr, PV_BEXPR, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 559,565 ****
                            SCTX_INIT},
      {"charconvert",  "ccv", P_STRING|P_VI_DEF|P_SECURE,
  #if defined(FEAT_EVAL)
!                           (char_u *)&p_ccv, PV_NONE, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 559,565 ----
                            SCTX_INIT},
      {"charconvert",  "ccv", P_STRING|P_VI_DEF|P_SECURE,
  #if defined(FEAT_EVAL)
!                           (char_u *)&p_ccv, PV_NONE, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 616,622 ****
                            {(char_u *)80L, (char_u *)0L} SCTX_INIT},
      {"comments",    "com",  P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
                                                          |P_NODUP|P_CURSWANT,
!                           (char_u *)&p_com, PV_COM, NULL,
                            {(char_u 
*)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
                                (char_u *)0L}
                            SCTX_INIT},
--- 616,622 ----
                            {(char_u *)80L, (char_u *)0L} SCTX_INIT},
      {"comments",    "com",  P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
                                                          |P_NODUP|P_CURSWANT,
!                           (char_u *)&p_com, PV_COM, did_set_comments,
                            {(char_u 
*)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
                                (char_u *)0L}
                            SCTX_INIT},
***************
*** 635,646 ****
                            (char_u *)&p_cp, PV_NONE, did_set_compatible,
                            {(char_u *)TRUE, (char_u *)FALSE} SCTX_INIT},
      {"complete",    "cpt",  P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
!                           (char_u *)&p_cpt, PV_CPT, NULL,
                            {(char_u *)".,w,b,u,t,i", (char_u *)0L}
                            SCTX_INIT},
      {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
  #ifdef FEAT_CONCEAL
!                           (char_u *)VAR_WIN, PV_COCU, NULL,
                            {(char_u *)"", (char_u *)NULL}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 635,646 ----
                            (char_u *)&p_cp, PV_NONE, did_set_compatible,
                            {(char_u *)TRUE, (char_u *)FALSE} SCTX_INIT},
      {"complete",    "cpt",  P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
!                           (char_u *)&p_cpt, PV_CPT, did_set_complete,
                            {(char_u *)".,w,b,u,t,i", (char_u *)0L}
                            SCTX_INIT},
      {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
  #ifdef FEAT_CONCEAL
!                           (char_u *)VAR_WIN, PV_COCU, did_set_concealcursor,
                            {(char_u *)"", (char_u *)NULL}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 700,706 ****
                            (char_u *)&p_ci, PV_CI, NULL,
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"cpoptions",   "cpo",  P_STRING|P_VIM|P_RALL|P_FLAGLIST,
!                           (char_u *)&p_cpo, PV_NONE, NULL,
                            {(char_u *)CPO_VI, (char_u *)CPO_VIM}
                            SCTX_INIT},
      {"cryptmethod", "cm",   P_STRING|P_ALLOCED|P_VI_DEF,
--- 700,706 ----
                            (char_u *)&p_ci, PV_CI, NULL,
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"cpoptions",   "cpo",  P_STRING|P_VIM|P_RALL|P_FLAGLIST,
!                           (char_u *)&p_cpo, PV_NONE, did_set_cpoptions,
                            {(char_u *)CPO_VI, (char_u *)CPO_VIM}
                            SCTX_INIT},
      {"cryptmethod", "cm",   P_STRING|P_ALLOCED|P_VI_DEF,
***************
*** 818,824 ****
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"diffexpr",    "dex",  P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
  #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
!                           (char_u *)&p_dex, PV_NONE, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 818,824 ----
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"diffexpr",    "dex",  P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
  #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
!                           (char_u *)&p_dex, PV_NONE, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 986,992 ****
                            SCTX_INIT},
      {"foldexpr",    "fde",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN|P_MLE,
  #if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
!                           (char_u *)VAR_WIN, PV_FDE, NULL,
                            {(char_u *)"0", (char_u *)NULL}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 986,992 ----
                            SCTX_INIT},
      {"foldexpr",    "fde",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN|P_MLE,
  #if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
!                           (char_u *)VAR_WIN, PV_FDE, did_set_foldexpr,
                            {(char_u *)"0", (char_u *)NULL}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 1069,1075 ****
                            SCTX_INIT},
      {"foldtext",    "fdt",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN|P_MLE,
  #if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
!                           (char_u *)VAR_WIN, PV_FDT, NULL,
                            {(char_u *)"foldtext()", (char_u *)NULL}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 1069,1075 ----
                            SCTX_INIT},
      {"foldtext",    "fdt",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN|P_MLE,
  #if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
!                           (char_u *)VAR_WIN, PV_FDT, did_set_optexpr,
                            {(char_u *)"foldtext()", (char_u *)NULL}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 1078,1084 ****
                            SCTX_INIT},
      {"formatexpr", "fex",   P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
  #ifdef FEAT_EVAL
!                           (char_u *)&p_fex, PV_FEX, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 1078,1084 ----
                            SCTX_INIT},
      {"formatexpr", "fex",   P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
  #ifdef FEAT_EVAL
!                           (char_u *)&p_fex, PV_FEX, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 1086,1092 ****
  #endif
                            SCTX_INIT},
      {"formatoptions","fo",  P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
!                           (char_u *)&p_fo, PV_FO, NULL,
                            {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
                            SCTX_INIT},
      {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
--- 1086,1092 ----
  #endif
                            SCTX_INIT},
      {"formatoptions","fo",  P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
!                           (char_u *)&p_fo, PV_FO, did_set_formatoptions,
                            {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
                            SCTX_INIT},
      {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
***************
*** 1144,1150 ****
                            SCTX_INIT},
      {"guicursor",    "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
  #ifdef CURSOR_SHAPE
!                           (char_u *)&p_guicursor, PV_NONE, NULL,
                            {
  # ifdef FEAT_GUI
                                (char_u 
*)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
--- 1144,1151 ----
                            SCTX_INIT},
      {"guicursor",    "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
  #ifdef CURSOR_SHAPE
!                           (char_u *)&p_guicursor, PV_NONE,
!                           did_set_guicursor,
                            {
  # ifdef FEAT_GUI
                                (char_u 
*)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
***************
*** 1375,1381 ****
                            SCTX_INIT},
      {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF|P_MLE,
  #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
!                           (char_u *)&p_inex, PV_INEX, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 1376,1382 ----
                            SCTX_INIT},
      {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF|P_MLE,
  #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
!                           (char_u *)&p_inex, PV_INEX, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 1387,1393 ****
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"indentexpr", "inde",  P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
  #if defined(FEAT_EVAL)
!                           (char_u *)&p_inde, PV_INDE, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 1388,1394 ----
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"indentexpr", "inde",  P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
  #if defined(FEAT_EVAL)
!                           (char_u *)&p_inde, PV_INDE, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 1689,1695 ****
                            (char_u *)&p_more, PV_NONE, NULL,
                            {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
      {"mouse",     NULL,   P_STRING|P_VI_DEF|P_FLAGLIST,
!                           (char_u *)&p_mouse, PV_NONE, NULL,
                            {
  #if defined(MSWIN)
                                (char_u *)"a",
--- 1690,1696 ----
                            (char_u *)&p_more, PV_NONE, NULL,
                            {(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
      {"mouse",     NULL,   P_STRING|P_VI_DEF|P_FLAGLIST,
!                           (char_u *)&p_mouse, PV_NONE, did_set_mouse,
                            {
  #if defined(MSWIN)
                                (char_u *)"a",
***************
*** 1834,1840 ****
                            {(char_u *)"", (char_u *)0L} SCTX_INIT},
      {"patchexpr",   "pex",  P_STRING|P_VI_DEF|P_SECURE,
  #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
!                           (char_u *)&p_pex, PV_NONE, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 1835,1841 ----
                            {(char_u *)"", (char_u *)0L} SCTX_INIT},
      {"patchexpr",   "pex",  P_STRING|P_VI_DEF|P_SECURE,
  #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
!                           (char_u *)&p_pex, PV_NONE, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 1910,1916 ****
                            SCTX_INIT},
      {"printexpr", "pexpr",  P_STRING|P_VI_DEF|P_SECURE,
  #ifdef FEAT_POSTSCRIPT
!                           (char_u *)&p_pexpr, PV_NONE, NULL,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
--- 1911,1917 ----
                            SCTX_INIT},
      {"printexpr", "pexpr",  P_STRING|P_VI_DEF|P_SECURE,
  #ifdef FEAT_POSTSCRIPT
!                           (char_u *)&p_pexpr, PV_NONE, did_set_optexpr,
                            {(char_u *)"", (char_u *)0L}
  #else
                            (char_u *)NULL, PV_NONE, NULL,
***************
*** 2259,2265 ****
                            did_set_shiftwidth_tabstop,
                            {(char_u *)8L, (char_u *)0L} SCTX_INIT},
      {"shortmess",   "shm",  P_STRING|P_VIM|P_FLAGLIST,
!                           (char_u *)&p_shm, PV_NONE, NULL,
                            {(char_u *)"S", (char_u *)"filnxtToOS"}
                            SCTX_INIT},
      {"shortname",   "sn",   P_BOOL|P_VI_DEF,
--- 2260,2266 ----
                            did_set_shiftwidth_tabstop,
                            {(char_u *)8L, (char_u *)0L} SCTX_INIT},
      {"shortmess",   "shm",  P_STRING|P_VIM|P_FLAGLIST,
!                           (char_u *)&p_shm, PV_NONE, did_set_shortmess,
                            {(char_u *)"S", (char_u *)"filnxtToOS"}
                            SCTX_INIT},
      {"shortname",   "sn",   P_BOOL|P_VI_DEF,
***************
*** 2742,2748 ****
                            SCTX_INIT},
      {"viminfo",           "vi",   P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
  #ifdef FEAT_VIMINFO
!                           (char_u *)&p_viminfo, PV_NONE, NULL,
  #if defined(MSWIN)
                            {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
  #elif defined(AMIGA)
--- 2743,2749 ----
                            SCTX_INIT},
      {"viminfo",           "vi",   P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
  #ifdef FEAT_VIMINFO
!                           (char_u *)&p_viminfo, PV_NONE, did_set_viminfo,
  #if defined(MSWIN)
                            {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
  #elif defined(AMIGA)
***************
*** 2790,2796 ****
                            (char_u *)&p_wiv, PV_NONE, did_set_weirdinvert,
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"whichwrap",   "ww",   P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
!                           (char_u *)&p_ww, PV_NONE, NULL,
                            {(char_u *)"", (char_u *)"b,s"} SCTX_INIT},
      {"wildchar",    "wc",   P_NUM|P_VIM,
                            (char_u *)&p_wc, PV_NONE, NULL,
--- 2791,2797 ----
                            (char_u *)&p_wiv, PV_NONE, did_set_weirdinvert,
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
      {"whichwrap",   "ww",   P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
!                           (char_u *)&p_ww, PV_NONE, did_set_whichwrap,
                            {(char_u *)"", (char_u *)"b,s"} SCTX_INIT},
      {"wildchar",    "wc",   P_NUM|P_VIM,
                            (char_u *)&p_wc, PV_NONE, NULL,
*** ../vim-9.0.1352/src/optionstr.c     2023-02-23 15:05:18.917676841 +0000
--- src/optionstr.c     2023-02-25 11:43:57.616573944 +0000
***************
*** 790,796 ****
      return NULL;
  }
  
! #ifdef FEAT_SYN_HL
  /*
   * The 'colorcolumn' option is changed.
   */
--- 790,796 ----
      return NULL;
  }
  
! #if defined(FEAT_SYN_HL) || defined(PROTO)
  /*
   * The 'colorcolumn' option is changed.
   */
***************
*** 1458,1477 ****
  /*
   * The 'comments' option is changed.
   */
!     static char *
! did_set_comments(char_u **varp, char *errbuf)
  {
      char_u    *s;
      char      *errmsg = NULL;
  
!     for (s = *varp; *s; )
      {
        while (*s && *s != ':')
        {
            if (vim_strchr((char_u *)COM_ALL, *s) == NULL
                    && !VIM_ISDIGIT(*s) && *s != '-')
            {
!               errmsg = illegal_char(errbuf, *s);
                break;
            }
            ++s;
--- 1458,1477 ----
  /*
   * The 'comments' option is changed.
   */
!     char *
! did_set_comments(optset_T *args)
  {
      char_u    *s;
      char      *errmsg = NULL;
  
!     for (s = args->os_varp; *s; )
      {
        while (*s && *s != ':')
        {
            if (vim_strchr((char_u *)COM_ALL, *s) == NULL
                    && !VIM_ISDIGIT(*s) && *s != '-')
            {
!               errmsg = illegal_char(args->os_errbuf, *s);
                break;
            }
            ++s;
***************
*** 1547,1558 ****
      return NULL;
  }
  
! #ifdef FEAT_VIMINFO
  /*
   * The 'viminfo' option is changed.
   */
!     static char *
! did_set_viminfo(char *errbuf)
  {
      char_u    *s;
      char      *errmsg = NULL;
--- 1547,1558 ----
      return NULL;
  }
  
! #if defined(FEAT_VIMINFO) || defined(PROTO)
  /*
   * The 'viminfo' option is changed.
   */
!     char *
! did_set_viminfo(optset_T *args)
  {
      char_u    *s;
      char      *errmsg = NULL;
***************
*** 1562,1568 ****
        // Check it's a valid character
        if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
        {
!           errmsg = illegal_char(errbuf, *s);
            break;
        }
        if (*s == 'n')  // name is always last one
--- 1562,1568 ----
        // Check it's a valid character
        if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
        {
!           errmsg = illegal_char(args->os_errbuf, *s);
            break;
        }
        if (*s == 'n')  // name is always last one
***************
*** 1587,1598 ****
  
            if (!VIM_ISDIGIT(*(s - 1)))
            {
!               if (errbuf != NULL)
                {
!                   sprintf(errbuf,
                            _(e_missing_number_after_angle_str_angle),
                            transchar_byte(*(s - 1)));
!                   errmsg = errbuf;
                }
                else
                    errmsg = "";
--- 1587,1598 ----
  
            if (!VIM_ISDIGIT(*(s - 1)))
            {
!               if (args->os_errbuf != NULL)
                {
!                   sprintf(args->os_errbuf,
                            _(e_missing_number_after_angle_str_angle),
                            transchar_byte(*(s - 1)));
!                   errmsg = args->os_errbuf;
                }
                else
                    errmsg = "";
***************
*** 1603,1609 ****
            ++s;
        else if (*s)
        {
!           if (errbuf != NULL)
                errmsg = e_missing_comma;
            else
                errmsg = "";
--- 1603,1609 ----
            ++s;
        else if (*s)
        {
!           if (args->os_errbuf != NULL)
                errmsg = e_missing_comma;
            else
                errmsg = "";
***************
*** 1698,1703 ****
--- 1698,1714 ----
  }
  #endif
  
+ #if defined(CURSOR_SHAPE) || defined(PROTO)
+ /*
+  * The 'guicursor' option is changed.
+  */
+     char *
+ did_set_guicursor(optset_T *args UNUSED)
+ {
+     return parse_shape_opt(SHAPE_CURSOR);
+ }
+ #endif
+ 
  #if defined(FEAT_GUI) || defined(PROTO)
  /*
   * The 'guifont' option is changed.
***************
*** 1849,1861 ****
      return did_set_titleiconstring(args, flagval);
  }
  
! #ifdef FEAT_GUI
  /*
   * The 'guioptions' option is changed.
   */
      char *
  did_set_guioptions(optset_T *args)
  {
      gui_init_which_components(args->os_oldval.string);
      return NULL;
  }
--- 1860,1894 ----
      return did_set_titleiconstring(args, flagval);
  }
  
! /*
!  * An option which is a list of flags is set.  Valid values are in 'flags'.
!  */
!     static char *
! did_set_option_listflag(char_u *varp, char_u *flags, char *errbuf)
! {
!     char_u    *s;
! 
!     for (s = varp; *s; ++s)
!       if (vim_strchr(flags, *s) == NULL)
!           return illegal_char(errbuf, *s);
! 
!     return NULL;
! }
! 
! #if defined(FEAT_GUI) || defined(PROTO)
  /*
   * The 'guioptions' option is changed.
   */
      char *
  did_set_guioptions(optset_T *args)
  {
+     char *errmsg;
+ 
+     errmsg = did_set_option_listflag(args->os_varp, (char_u *)GO_ALL,
+                                                       args->os_errbuf);
+     if (errmsg != NULL)
+       return errmsg;
+ 
      gui_init_which_components(args->os_oldval.string);
      return NULL;
  }
***************
*** 2095,2101 ****
      return NULL;
  }
  
! #ifdef FEAT_STL_OPT
  /*
   * The 'statusline' or the 'tabline' or the 'rulerformat' option is changed.
   * "rulerformat" is TRUE if the 'rulerformat' option is changed.
--- 2128,2134 ----
      return NULL;
  }
  
! #if defined(FEAT_STL_OPT) || defined(PROTO)
  /*
   * The 'statusline' or the 'tabline' or the 'rulerformat' option is changed.
   * "rulerformat" is TRUE if the 'rulerformat' option is changed.
***************
*** 2162,2181 ****
  /*
   * The 'complete' option is changed.
   */
!     static char *
! did_set_complete(char_u **varp, char *errbuf)
  {
      char_u    *s;
  
      // check if it is a valid value for 'complete' -- Acevedo
!     for (s = *varp; *s;)
      {
        while (*s == ',' || *s == ' ')
            s++;
        if (!*s)
            break;
        if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
!           return illegal_char(errbuf, *s);
        if (*++s != NUL && *s != ',' && *s != ' ')
        {
            if (s[-1] == 'k' || s[-1] == 's')
--- 2195,2214 ----
  /*
   * The 'complete' option is changed.
   */
!     char *
! did_set_complete(optset_T *args)
  {
      char_u    *s;
  
      // check if it is a valid value for 'complete' -- Acevedo
!     for (s = args->os_varp; *s;)
      {
        while (*s == ',' || *s == ' ')
            s++;
        if (!*s)
            break;
        if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
!           return illegal_char(args->os_errbuf, *s);
        if (*++s != NUL && *s != ',' && *s != ' ')
        {
            if (s[-1] == 'k' || s[-1] == 's')
***************
*** 2190,2200 ****
            }
            else
            {
!               if (errbuf != NULL)
                {
!                   sprintf((char *)errbuf,
                            _(e_illegal_character_after_chr), *--s);
!                   return errbuf;
                }
                return "";
            }
--- 2223,2233 ----
            }
            else
            {
!               if (args->os_errbuf != NULL)
                {
!                   sprintf((char *)args->os_errbuf,
                            _(e_illegal_character_after_chr), *--s);
!                   return args->os_errbuf;
                }
                return "";
            }
***************
*** 2744,2788 ****
  # endif
  #endif
  
! #ifdef FEAT_EVAL
  /*
   * One of the '*expr' options is changed: 'balloonexpr', 'diffexpr',
   * 'foldexpr', 'foldtext', 'formatexpr', 'includeexpr', 'indentexpr',
   * 'patchexpr', 'printexpr' and 'charconvert'.
   *
   */
!     static void
! did_set_optexpr(char_u **varp)
  {
      // If the option value starts with <SID> or s:, then replace that with
      // the script identifier.
!     char_u *name = get_scriptlocal_funcname(*varp);
      if (name != NULL)
      {
!       free_string_option(*varp);
!       *varp = name;
      }
  
! # ifdef FEAT_FOLDING
!     if (varp == &curwin->w_p_fde && foldmethodIsExpr(curwin))
        foldUpdateAll(curwin);
  # endif
  }
  #endif
  
  /*
!  * An option which is a list of flags is set.  Valid values are in 'flags'.
   */
!     static char *
! did_set_option_listflag(char_u **varp, char_u *flags, char *errbuf)
  {
!     char_u    *s;
  
!     for (s = *varp; *s; ++s)
!       if (vim_strchr(flags, *s) == NULL)
!           return illegal_char(errbuf, *s);
  
!     return NULL;
  }
  
  #ifdef FEAT_SYN_HL
--- 2777,2913 ----
  # endif
  #endif
  
! #if defined(FEAT_EVAL) || defined(PROTO)
! /*
!  * Returns TRUE if the option pointed by "varp" or "gvarp" is one of the
!  * '*expr' options: 'balloonexpr', 'diffexpr', 'foldexpr', 'foldtext',
!  * 'formatexpr', 'includeexpr', 'indentexpr', 'patchexpr', 'printexpr' or
!  * 'charconvert'.
!  */
!     static int
! is_expr_option(char_u **varp, char_u **gvarp)
! {
!     return (
! # ifdef FEAT_BEVAL
!       varp == &p_bexpr ||                     // 'balloonexpr'
! # endif
! # ifdef FEAT_DIFF
!       varp == &p_dex ||                       // 'diffexpr'
! # endif
! # ifdef FEAT_FOLDING
!       gvarp == &curwin->w_allbuf_opt.wo_fde ||        // 'foldexpr'
!       gvarp == &curwin->w_allbuf_opt.wo_fdt ||        // 'foldtext'
! # endif
!       gvarp == &p_fex ||                      // 'formatexpr'
! # ifdef FEAT_FIND_ID
!       gvarp == &p_inex ||                     // 'includeexpr'
! # endif
!       gvarp == &p_inde ||                     // 'indentexpr'
! # ifdef FEAT_DIFF
!       varp == &p_pex ||                       // 'patchexpr'
! # endif
! # ifdef FEAT_POSTSCRIPT
!       varp == &p_pexpr ||                     // 'printexpr'
! # endif
!       varp == &p_ccv);                        // 'charconvert'
! }
! 
  /*
   * One of the '*expr' options is changed: 'balloonexpr', 'diffexpr',
   * 'foldexpr', 'foldtext', 'formatexpr', 'includeexpr', 'indentexpr',
   * 'patchexpr', 'printexpr' and 'charconvert'.
   *
   */
!     char *
! did_set_optexpr(optset_T *args)
  {
      // If the option value starts with <SID> or s:, then replace that with
      // the script identifier.
!     char_u *name = get_scriptlocal_funcname(args->os_varp);
      if (name != NULL)
      {
!       free_string_option(args->os_varp);
!       args->os_varp = name;
      }
  
!     return NULL;
! }
! 
! # if defined(FEAT_FOLDING) || defined(PROTO)
! /*
!  * The 'foldexpr' option is changed.
!  */
!     char *
! did_set_foldexpr(optset_T *args)
! {
!     (void)did_set_optexpr(args);
!     if (foldmethodIsExpr(curwin))
        foldUpdateAll(curwin);
+     return NULL;
+ }
  # endif
+ #endif
+ 
+ #if defined(FEAT_CONCEAL) || defined(PROTO)
+ /*
+  * The 'concealcursor' option is changed.
+  */
+     char *
+ did_set_concealcursor(optset_T *args)
+ {
+     return did_set_option_listflag(args->os_varp, (char_u *)COCU_ALL,
+                                                       args->os_errbuf);
  }
  #endif
  
  /*
!  * The 'cpoptions' option is changed.
   */
!     char *
! did_set_cpoptions(optset_T *args)
  {
!     return did_set_option_listflag(args->os_varp, (char_u *)CPO_ALL,
!                                                       args->os_errbuf);
! }
  
! /*
!  * The 'formatoptions' option is changed.
!  */
!     char *
! did_set_formatoptions(optset_T *args)
! {
!     return did_set_option_listflag(args->os_varp, (char_u *)FO_ALL,
!                                                       args->os_errbuf);
! }
  
! /*
!  * The 'mouse' option is changed.
!  */
!     char *
! did_set_mouse(optset_T *args)
! {
!     return did_set_option_listflag(args->os_varp, (char_u *)MOUSE_ALL,
!                                                       args->os_errbuf);
! }
! 
! /*
!  * The 'shortmess' option is changed.
!  */
!     char *
! did_set_shortmess(optset_T *args)
! {
!     return did_set_option_listflag(args->os_varp, (char_u *)SHM_ALL,
!                                                       args->os_errbuf);
! }
! 
! /*
!  * The 'whichwrap' option is changed.
!  */
!     char *
! did_set_whichwrap(optset_T *args)
! {
!     return did_set_option_listflag(args->os_varp, (char_u *)WW_ALL,
!                                                       args->os_errbuf);
  }
  
  #ifdef FEAT_SYN_HL
***************
*** 2912,2918 ****
--- 3037,3050 ----
        args.os_flags = opt_flags;
        args.os_oldval.string = oldval;
        args.os_newval.string = value;
+       args.os_errbuf = errbuf;
        errmsg = did_set_cb(&args);
+ #ifdef FEAT_EVAL
+       // When processing the '*expr' options (e.g. diffexpr, foldexpr, etc.),
+       // the did_set_cb() function may modify '*varp'.
+       if (errmsg == NULL && is_expr_option(varp, gvarp))
+           *varp = args.os_varp;
+ #endif
      }
      else if (varp == &T_NAME)                 // 'term'
        errmsg = did_set_term(&opt_idx, &free_oldval);
***************
*** 2930,2937 ****
      else if (varp == &curbuf->b_p_keymap)     // 'keymap'
        errmsg = did_set_keymap(varp, opt_flags, value_checked);
  #endif
-     else if (gvarp == &p_com)                 // 'comments'
-       errmsg = did_set_comments(varp, errbuf);
      else if (  varp == &p_lcs                 // global 'listchars'
            || varp == &p_fcs)                  // global 'fillchars'
        errmsg = did_set_global_listfillchars(varp, opt_flags);
--- 3062,3067 ----
***************
*** 2939,2957 ****
        errmsg = set_chars_option(curwin, varp, TRUE);
      else if (varp == &curwin->w_p_fcs)                // local 'fillchars'
        errmsg = set_chars_option(curwin, varp, TRUE);
- #ifdef FEAT_VIMINFO
-     else if (varp == &p_viminfo)              // 'viminfo'
-       errmsg = did_set_viminfo(errbuf);
- #endif // FEAT_VIMINFO
      // terminal options
      else if (istermoption_idx(opt_idx) && full_screen)
        did_set_term_option(varp, &did_swaptcap);
- #ifdef CURSOR_SHAPE
-     else if (varp == &p_guicursor)            // 'guicursor'
-       errmsg = parse_shape_opt(SHAPE_CURSOR);
- #endif
-     else if (gvarp == &p_cpt)                 // 'complete'
-       errmsg = did_set_complete(varp, errbuf);
      else if (gvarp == &p_ft)                  // 'filetype'
        errmsg = did_set_filetype_or_syntax(varp, oldval, value_checked,
                                                        &value_changed);
--- 3069,3077 ----
***************
*** 2960,3009 ****
        errmsg = did_set_filetype_or_syntax(varp, oldval, value_checked,
                                                        &value_changed);
  #endif
- #ifdef FEAT_EVAL
-     else if (
- # ifdef FEAT_BEVAL
-           varp == &p_bexpr ||                 // 'balloonexpr'
- # endif
- # ifdef FEAT_DIFF
-           varp == &p_dex ||                   // 'diffexpr'
- # endif
- # ifdef FEAT_FOLDING
-           gvarp == &curwin->w_allbuf_opt.wo_fde ||    // 'foldexpr'
-           gvarp == &curwin->w_allbuf_opt.wo_fdt ||    // 'foldtext'
- # endif
-           gvarp == &p_fex ||                  // 'formatexpr'
- # ifdef FEAT_FIND_ID
-           gvarp == &p_inex ||                 // 'includeexpr'
- # endif
-           gvarp == &p_inde ||                 // 'indentexpr'
- # ifdef FEAT_DIFF
-           varp == &p_pex ||                   // 'patchexpr'
- # endif
- # ifdef FEAT_POSTSCRIPT
-           varp == &p_pexpr ||                 // 'printexpr'
- # endif
-           varp == &p_ccv)                     // 'charconvert'
-       did_set_optexpr(varp);
- #endif
-     else if (varp == &p_ww)                   // 'whichwrap'
-       errmsg = did_set_option_listflag(varp, (char_u *)WW_ALL, errbuf);
-     else if (varp == &p_shm)                  // 'shortmess'
-       errmsg = did_set_option_listflag(varp, (char_u *)SHM_ALL, errbuf);
-     else if (varp == &(p_cpo))                        // 'cpoptions'
-       errmsg = did_set_option_listflag(varp, (char_u *)CPO_ALL, errbuf);
-     else if (varp == &(curbuf->b_p_fo))               // 'formatoptions'
-       errmsg = did_set_option_listflag(varp, (char_u *)FO_ALL, errbuf);
- #ifdef FEAT_CONCEAL
-     else if (varp == &curwin->w_p_cocu)               // 'concealcursor'
-       errmsg = did_set_option_listflag(varp, (char_u *)COCU_ALL, errbuf);
- #endif
-     else if (varp == &p_mouse)                        // 'mouse'
-       errmsg = did_set_option_listflag(varp, (char_u *)MOUSE_ALL, errbuf);
- #if defined(FEAT_GUI)
-     else if (varp == &p_go)                   // 'guioptions'
-       errmsg = did_set_option_listflag(varp, (char_u *)GO_ALL, errbuf);
- #endif
  
      // If an error is detected, restore the previous value.
      if (errmsg != NULL)
--- 3080,3085 ----
*** ../vim-9.0.1352/src/proto/optionstr.pro     2023-02-23 15:05:18.917676841 
+0000
--- src/proto/optionstr.pro     2023-02-25 11:55:36.559582710 +0000
***************
*** 41,48 ****
--- 41,51 ----
  char *did_set_cryptkey(optset_T *args);
  char *did_set_cryptmethod(optset_T *args);
  char *did_set_matchpairs(optset_T *args);
+ char *did_set_comments(optset_T *args);
  char *did_set_verbosefile(optset_T *args);
+ char *did_set_viminfo(optset_T *args);
  char *did_set_showbreak(optset_T *args);
+ char *did_set_guicursor(optset_T *args);
  char *did_set_guifont(optset_T *args);
  char *did_set_guifontset(optset_T *args);
  char *did_set_guifontwide(optset_T *args);
***************
*** 71,76 ****
--- 74,80 ----
  char *did_set_statusline(optset_T *args);
  char *did_set_tabline(optset_T *args);
  char *did_set_rulerformat(optset_T *args);
+ char *did_set_complete(optset_T *args);
  char *did_set_completeopt(optset_T *args);
  char *did_set_completeslash(optset_T *args);
  char *did_set_signcolumn(optset_T *args);
***************
*** 99,104 ****
--- 103,116 ----
  char *did_set_vartabstop(optset_T *args);
  char *did_set_previewpopup(optset_T *args);
  char *did_set_completepopup(optset_T *args);
+ char *did_set_optexpr(optset_T *args);
+ char *did_set_foldexpr(optset_T *args);
+ char *did_set_concealcursor(optset_T *args);
+ char *did_set_cpoptions(optset_T *args);
+ char *did_set_formatoptions(optset_T *args);
+ char *did_set_mouse(optset_T *args);
+ char *did_set_shortmess(optset_T *args);
+ char *did_set_whichwrap(optset_T *args);
  char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, 
char_u *value, char *errbuf, int opt_flags, int *value_checked);
  int check_ff_value(char_u *p);
  void save_clear_shm_value(void);
*** ../vim-9.0.1352/src/structs.h       2023-02-21 19:55:02.795958051 +0000
--- src/structs.h       2023-02-25 11:52:53.916311521 +0000
***************
*** 4819,4822 ****
--- 4819,4827 ----
      // When set by the called function: Stop processing the option further.
      // Currently only used for boolean options.
      int               os_doskip;
+ 
+     // If the value specified for an option is not valid and the error message
+     // is parameterized, then the "os_errbuf" buffer is used to store the 
error
+     // message (when it is not NULL).
+     char      *os_errbuf;
  } optset_T;
*** ../vim-9.0.1352/src/testdir/gen_opt_test.vim        2022-12-15 
13:14:17.415527399 +0000
--- src/testdir/gen_opt_test.vim        2023-02-25 11:43:57.616573944 +0000
***************
*** 104,109 ****
--- 104,110 ----
        \ 'guifont': [['', fontname], []],
        \ 'guifontwide': [['', fontname], []],
        \ 'guifontset': [['', fontname], []],
+       \ 'guioptions': [['', 'a'], ['Q']],
        \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
        \ 'highlight': [['', 'e:Error'], ['xxx']],
        \ 'imactivatekey': [['', 'S-space'], ['xxx']],
*** ../vim-9.0.1352/src/version.c       2023-02-24 17:16:37.401362113 +0000
--- src/version.c       2023-02-25 11:43:43.252558623 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1353,
  /**/

-- 
The CIA drives around in cars with the "Intel inside" logo.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230225120018.0941F1C0E9C%40moolenaar.net.

Raspunde prin e-mail lui