]> granicus.if.org Git - vim/commitdiff
patch 8.2.5051: check for autocmd_add() event argument is confusing v8.2.5051
authorBram Moolenaar <Bram@vim.org>
Wed, 1 Jun 2022 15:02:38 +0000 (16:02 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 1 Jun 2022 15:02:38 +0000 (16:02 +0100)
Problem:    Check for autocmd_add() event argument is confusing.
Solution:   Make the code more straightforward.

src/autocmd.c
src/version.c

index 2050da6640310b0c936010eae387404af0065c55..71aeb5036bf8926f5147bd1b83969982a259f48d 100644 (file)
@@ -2951,26 +2951,24 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
                    if (eli == NULL)
                        break;
                    if (eli->li_tv.v_type != VAR_STRING
-                           || eli->li_tv.vval.v_string == NULL)
+                           || (p = eli->li_tv.vval.v_string) == NULL)
                    {
                        emsg(_(e_string_required));
-                       continue;
+                       break;
                    }
-                   p = eli->li_tv.vval.v_string;
                }
                else
                {
-                   if (end == NULL)
-                       p = end = event_name;
-                   if (end == NULL || *end == NUL)
+                   if (p == NULL)
+                       p = event_name;
+                   if (p == NULL || *p == NUL)
                        break;
                }
-               if (p == NULL)
-                   continue;
 
                event = event_name2nr(p, &end);
                if (event == NUM_EVENTS || *end != NUL)
                {
+                   // this also catches something following a valid event name
                    semsg(_(e_no_such_event_str), p);
                    retval = VVAL_FALSE;
                    break;
index ba8688bc55c961eef84947b7f9a92bd1dab0cc32..9df41679b474ce8a60f49fc1db5082d86a5d3351 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5051,
 /**/
     5050,
 /**/