Patch 8.2.0613
Problem:    Vim9: no check for space before #comment.
Solution:   Add space checks.
Files:      src/highlight.c, src/menu.c, src/syntax.c,
            src/testdir/test_vim9_script.vim,
            runtime/lang/menu_de_de.latin1.vim


*** ../vim-8.2.0612/src/highlight.c     2020-04-20 19:42:06.594078510 +0200
--- src/highlight.c     2020-04-20 20:23:36.688085576 +0200
***************
*** 694,700 ****
      /*
       * ":highlight {group-name}": list highlighting for one group.
       */
!     if (!doclear && !dolink && ends_excmd(*linep))
      {
        id = syn_namen2id(line, (int)(name_end - line));
        if (id == 0)
--- 694,700 ----
      /*
       * ":highlight {group-name}": list highlighting for one group.
       */
!     if (!doclear && !dolink && ends_excmd2(line, linep))
      {
        id = syn_namen2id(line, (int)(name_end - line));
        if (id == 0)
***************
*** 720,733 ****
        to_start = skipwhite(from_end);
        to_end   = skiptowhite(to_start);
  
!       if (ends_excmd(*from_start) || ends_excmd(*to_start))
        {
            semsg(_("E412: Not enough arguments: \":highlight link %s\""),
                                                                  from_start);
            return;
        }
  
!       if (!ends_excmd(*skipwhite(to_end)))
        {
            semsg(_("E413: Too many arguments: \":highlight link %s\""), 
from_start);
            return;
--- 720,733 ----
        to_start = skipwhite(from_end);
        to_end   = skiptowhite(to_start);
  
!       if (ends_excmd2(line, from_start) || ends_excmd2(line, to_start))
        {
            semsg(_("E412: Not enough arguments: \":highlight link %s\""),
                                                                  from_start);
            return;
        }
  
!       if (!ends_excmd2(line, skipwhite(to_end)))
        {
            semsg(_("E413: Too many arguments: \":highlight link %s\""), 
from_start);
            return;
***************
*** 781,788 ****
        /*
         * ":highlight clear [group]" command.
         */
!       line = linep;
!       if (ends_excmd(*line))
        {
  #ifdef FEAT_GUI
            // First, we do not destroy the old values, but allocate the new
--- 781,787 ----
        /*
         * ":highlight clear [group]" command.
         */
!       if (ends_excmd2(line, linep))
        {
  #ifdef FEAT_GUI
            // First, we do not destroy the old values, but allocate the new
***************
*** 826,832 ****
            // It is now Ok to clear out the old data.
  #endif
  #ifdef FEAT_EVAL
!           do_unlet((char_u *)"colors_name", TRUE);
  #endif
            restore_cterm_colors();
  
--- 825,831 ----
            // It is now Ok to clear out the old data.
  #endif
  #ifdef FEAT_EVAL
!           do_unlet((char_u *)"g:colors_name", TRUE);
  #endif
            restore_cterm_colors();
  
***************
*** 845,850 ****
--- 844,850 ----
            redraw_later_clear();
            return;
        }
+       line = linep;
        name_end = skiptowhite(line);
        linep = skipwhite(name_end);
      }
***************
*** 888,894 ****
      }
  
      if (!doclear)
!       while (!ends_excmd(*linep))
        {
        key_start = linep;
        if (*linep == '=')
--- 888,894 ----
      }
  
      if (!doclear)
!       while (!ends_excmd2(line, linep))
        {
        key_start = linep;
        if (*linep == '=')
***************
*** 4946,4955 ****
      if (!eap->skip)
        match_delete(curwin, id, FALSE);
  
!     if (ends_excmd(*eap->arg))
        end = eap->arg;
      else if ((STRNICMP(eap->arg, "none", 4) == 0
!               && (VIM_ISWHITE(eap->arg[4]) || ends_excmd(eap->arg[4]))))
        end = eap->arg + 4;
      else
      {
--- 4946,4956 ----
      if (!eap->skip)
        match_delete(curwin, id, FALSE);
  
!     if (ends_excmd2(eap->cmd, eap->arg))
        end = eap->arg;
      else if ((STRNICMP(eap->arg, "none", 4) == 0
!               && (VIM_ISWHITE(eap->arg[4])
!                                     || ends_excmd2(eap->arg, eap->arg + 4))))
        end = eap->arg + 4;
      else
      {
***************
*** 4967,4973 ****
        end = skip_regexp(p + 1, *p, TRUE);
        if (!eap->skip)
        {
!           if (*end != NUL && !ends_excmd(*skipwhite(end + 1)))
            {
                vim_free(g);
                eap->errmsg = e_trailing;
--- 4968,4974 ----
        end = skip_regexp(p + 1, *p, TRUE);
        if (!eap->skip)
        {
!           if (*end != NUL && !ends_excmd2(end, skipwhite(end + 1)))
            {
                vim_free(g);
                eap->errmsg = e_trailing;
*** ../vim-8.2.0612/src/menu.c  2020-04-06 22:12:57.141652839 +0200
--- src/menu.c  2020-04-20 20:55:21.995515753 +0200
***************
*** 2680,2686 ****
      /*
       * ":menutrans clear": clear all translations.
       */
!     if (STRNCMP(arg, "clear", 5) == 0 && ends_excmd(*skipwhite(arg + 5)))
      {
        tp = (menutrans_T *)menutrans_ga.ga_data;
        for (i = 0; i < menutrans_ga.ga_len; ++i)
--- 2680,2686 ----
      /*
       * ":menutrans clear": clear all translations.
       */
!     if (STRNCMP(arg, "clear", 5) == 0 && ends_excmd2(arg, skipwhite(arg + 5)))
      {
        tp = (menutrans_T *)menutrans_ga.ga_data;
        for (i = 0; i < menutrans_ga.ga_len; ++i)
***************
*** 2703,2709 ****
        to = skipwhite(arg);
        *arg = NUL;
        arg = menu_skip_part(to);
!       if (arg == to)
            emsg(_(e_invarg));
        else
        {
--- 2703,2711 ----
        to = skipwhite(arg);
        *arg = NUL;
        arg = menu_skip_part(to);
!       if (arg == to || ends_excmd2(eap->arg, from)
!                     || ends_excmd2(eap->arg, to)
!                     || !ends_excmd2(eap->arg, skipwhite(arg)))
            emsg(_(e_invarg));
        else
        {
*** ../vim-8.2.0612/src/syntax.c        2020-04-12 19:37:13.526297236 +0200
--- src/syntax.c        2020-04-20 21:39:24.904887425 +0200
***************
*** 3632,3638 ****
      if (curwin->w_s->b_syn_topgrp != 0)
        return;
  
!     if (ends_excmd(*arg))
      {
        /*
         * No argument: Clear all syntax items.
--- 3632,3638 ----
      if (curwin->w_s->b_syn_topgrp != 0)
        return;
  
!     if (ends_excmd2(eap->cmd, arg))
      {
        /*
         * No argument: Clear all syntax items.
***************
*** 3652,3658 ****
        /*
         * Clear the group IDs that are in the argument.
         */
!       while (!ends_excmd(*arg))
        {
            arg_end = skiptowhite(arg);
            if (*arg == '@')
--- 3652,3658 ----
        /*
         * Clear the group IDs that are in the argument.
         */
!       while (!ends_excmd2(eap->cmd, arg))
        {
            arg_end = skiptowhite(arg);
            if (*arg == '@')
***************
*** 3843,3849 ****
      }
      else
        msg_puts_title(_("\n--- Syntax items ---"));
!     if (ends_excmd(*arg))
      {
        /*
         * No argument: List all group IDs and all syntax clusters.
--- 3843,3849 ----
      }
      else
        msg_puts_title(_("\n--- Syntax items ---"));
!     if (ends_excmd2(eap->cmd, arg))
      {
        /*
         * No argument: List all group IDs and all syntax clusters.
***************
*** 3858,3864 ****
        /*
         * List the group IDs and syntax clusters that are in the argument.
         */
!       while (!ends_excmd(*arg) && !got_int)
        {
            arg_end = skiptowhite(arg);
            if (*arg == '@')
--- 3858,3864 ----
        /*
         * List the group IDs and syntax clusters that are in the argument.
         */
!       while (!ends_excmd2(eap->cmd, arg) && !got_int)
        {
            arg_end = skiptowhite(arg);
            if (*arg == '@')
***************
*** 4463,4473 ****
   */
      static char_u *
  get_syn_options(
!     char_u        *arg,               // next argument to be checked
      syn_opt_arg_T   *opt,             // various things
      int                   *conceal_char UNUSED,
      int                   skip)               // TRUE if skipping over command
  {
      char_u    *gname_start, *gname;
      int               syn_id;
      int               len;
--- 4463,4474 ----
   */
      static char_u *
  get_syn_options(
!     char_u        *start,             // next argument to be checked
      syn_opt_arg_T   *opt,             // various things
      int                   *conceal_char UNUSED,
      int                   skip)               // TRUE if skipping over command
  {
+     char_u    *arg = start;
      char_u    *gname_start, *gname;
      int               syn_id;
      int               len;
***************
*** 4528,4534 ****
            if (p[i] == NUL && (VIM_ISWHITE(arg[len])
                                    || (flagtab[fidx].argtype > 0
                                         ? arg[len] == '='
!                                        : ends_excmd(arg[len]))))
            {
                if (opt->keyword
                        && (flagtab[fidx].flags == HL_DISPLAY
--- 4529,4535 ----
            if (p[i] == NUL && (VIM_ISWHITE(arg[len])
                                    || (flagtab[fidx].argtype > 0
                                         ? arg[len] == '='
!                                        : ends_excmd2(start, arg + len))))
            {
                if (opt->keyword
                        && (flagtab[fidx].flags == HL_DISPLAY
***************
*** 4790,4800 ****
             */
            cnt = 0;
            p = keyword_copy;
!           for ( ; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest))
            {
                rest = get_syn_options(rest, &syn_opt_arg, &conceal_char,
                                                                    eap->skip);
!               if (rest == NULL || ends_excmd(*rest))
                    break;
                // Copy the keyword, removing backslashes, and add a NUL.
                while (*rest != NUL && !VIM_ISWHITE(*rest))
--- 4791,4802 ----
             */
            cnt = 0;
            p = keyword_copy;
!           for ( ; rest != NULL && !ends_excmd2(eap->arg, rest);
!                                                       rest = skipwhite(rest))
            {
                rest = get_syn_options(rest, &syn_opt_arg, &conceal_char,
                                                                    eap->skip);
!               if (rest == NULL || ends_excmd2(eap->arg, rest))
                    break;
                // Copy the keyword, removing backslashes, and add a NUL.
                while (*rest != NUL && !VIM_ISWHITE(*rest))
***************
*** 4892,4897 ****
--- 4894,4900 ----
      syn_opt_arg_T syn_opt_arg;
      int               sync_idx = 0;
      int               conceal_char = NUL;
+     int               orig_called_emsg = called_emsg;
  
      // Isolate the group name, check for validity
      rest = get_group_name(arg, &group_name_end);
***************
*** 4922,4928 ****
         * Check for trailing command and illegal trailing arguments.
         */
        eap->nextcmd = check_nextcmd(rest);
!       if (!ends_excmd(*rest) || eap->skip)
            rest = NULL;
        else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL
                && (syn_id = syn_check_group(arg,
--- 4925,4931 ----
         * Check for trailing command and illegal trailing arguments.
         */
        eap->nextcmd = check_nextcmd(rest);
!       if (!ends_excmd2(eap->cmd, rest) || eap->skip)
            rest = NULL;
        else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL
                && (syn_id = syn_check_group(arg,
***************
*** 4974,4980 ****
      vim_free(syn_opt_arg.cont_in_list);
      vim_free(syn_opt_arg.next_list);
  
!     if (rest == NULL)
        semsg(_(e_invarg2), arg);
  }
  
--- 4977,4983 ----
      vim_free(syn_opt_arg.cont_in_list);
      vim_free(syn_opt_arg.next_list);
  
!     if (rest == NULL && called_emsg == orig_called_emsg)
        semsg(_(e_invarg2), arg);
  }
  
***************
*** 5037,5047 ****
      /*
       * get the options, patterns and matchgroup.
       */
!     while (rest != NULL && !ends_excmd(*rest))
      {
        // Check for option arguments
        rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
!       if (rest == NULL || ends_excmd(*rest))
            break;
  
        // must be a pattern or matchgroup then
--- 5040,5050 ----
      /*
       * get the options, patterns and matchgroup.
       */
!     while (rest != NULL && !ends_excmd2(eap->cmd, rest))
      {
        // Check for option arguments
        rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
!       if (rest == NULL || ends_excmd2(eap->cmd, rest))
            break;
  
        // must be a pattern or matchgroup then
***************
*** 5570,5576 ****
  
      if (!got_clstr)
        emsg(_("E400: No cluster specified"));
!     if (rest == NULL || !ends_excmd(*rest))
        semsg(_(e_invarg2), arg);
  }
  
--- 5573,5579 ----
  
      if (!got_clstr)
        emsg(_("E400: No cluster specified"));
!     if (rest == NULL || !ends_excmd2(eap->cmd, rest))
        semsg(_(e_invarg2), arg);
  }
  
***************
*** 5680,5686 ****
        }
      } while (idx >= 0);
  
!     if (!ends_excmd(*end) && !VIM_ISWHITE(*end))
      {
        semsg(_("E402: Garbage after pattern: %s"), arg);
        return NULL;
--- 5683,5689 ----
        }
      } while (idx >= 0);
  
!     if (!ends_excmd2(arg, end) && !VIM_ISWHITE(*end))
      {
        semsg(_("E402: Garbage after pattern: %s"), arg);
        return NULL;
***************
*** 5703,5715 ****
      long      n;
      char_u    *cpo_save;
  
!     if (ends_excmd(*arg_start))
      {
        syn_cmd_list(eap, TRUE);
        return;
      }
  
!     while (!ends_excmd(*arg_start))
      {
        arg_end = skiptowhite(arg_start);
        next_arg = skipwhite(arg_end);
--- 5706,5718 ----
      long      n;
      char_u    *cpo_save;
  
!     if (ends_excmd2(eap->cmd, arg_start))
      {
        syn_cmd_list(eap, TRUE);
        return;
      }
  
!     while (!ends_excmd2(eap->cmd, arg_start))
      {
        arg_end = skiptowhite(arg_start);
        next_arg = skipwhite(arg_end);
***************
*** 5719,5725 ****
        {
            if (!eap->skip)
                curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
!           if (!ends_excmd(*next_arg))
            {
                arg_end = skiptowhite(next_arg);
                if (!eap->skip)
--- 5722,5728 ----
        {
            if (!eap->skip)
                curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
!           if (!ends_excmd2(eap->cmd, next_arg))
            {
                arg_end = skiptowhite(next_arg);
                if (!eap->skip)
***************
*** 5888,5894 ****
            break;
        }
        p = skipwhite(p + 1);
!       if (ends_excmd(*p))
        {
            semsg(_("E406: Empty argument: %s"), *arg);
            break;
--- 5891,5897 ----
            break;
        }
        p = skipwhite(p + 1);
!       if (ends_excmd2(*arg, p))
        {
            semsg(_("E406: Empty argument: %s"), *arg);
            break;
***************
*** 5898,5904 ****
         * parse the arguments after "contains"
         */
        count = 0;
!       while (!ends_excmd(*p))
        {
            for (end = p; *end && !VIM_ISWHITE(*end) && *end != ','; ++end)
                ;
--- 5901,5907 ----
         * parse the arguments after "contains"
         */
        count = 0;
!       while (!ends_excmd2(*arg, p))
        {
            for (end = p; *end && !VIM_ISWHITE(*end) && *end != ','; ++end)
                ;
*** ../vim-8.2.0612/src/testdir/test_vim9_script.vim    2020-04-20 
19:42:06.594078510 +0200
--- src/testdir/test_vim9_script.vim    2020-04-20 21:38:32.577016610 +0200
***************
*** 1210,1215 ****
--- 1210,1385 ----
        'vim9script',
        'hi# comment',
        ], 'E416:')
+   CheckScriptSuccess([
+       'vim9script',
+       'hi Search # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'hi Search# comment',
+       ], 'E416:')
+   CheckScriptSuccess([
+       'vim9script',
+       'hi link This Search # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'hi link This That# comment',
+       ], 'E413:')
+   CheckScriptSuccess([
+       'vim9script',
+       'hi clear This # comment',
+       'hi clear # comment',
+       ])
+   " not tested, because it doesn't give an error but a warning:
+   " hi clear This# comment',
+   CheckScriptFailure([
+       'vim9script',
+       'hi clear# comment',
+       ], 'E416:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'hi Group term=bold',
+       'match Group /todo/ # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'hi Group term=bold',
+       'match Group /todo/# comment',
+       ], 'E488:')
+   CheckScriptSuccess([
+       'vim9script',
+       'match # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'match# comment',
+       ], 'E475:')
+   CheckScriptSuccess([
+       'vim9script',
+       'match none # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'match none# comment',
+       ], 'E475:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'menutrans clear # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'menutrans clear# comment text',
+       ], 'E474:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax clear # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax clear# comment text',
+       ], 'E28:')
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax keyword Word some',
+       'syntax clear Word # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax keyword Word some',
+       'syntax clear Word# comment text',
+       ], 'E28:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax list # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax list# comment text',
+       ], 'E28:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax match Word /pat/ oneline # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax match Word /pat/ oneline# comment',
+       ], 'E475:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax keyword Word word # comm[ent',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax keyword Word word# comm[ent',
+       ], 'E789:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax match Word /pat/ # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax match Word /pat/# comment',
+       ], 'E402:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax match Word /pat/ contains=Something # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax match Word /pat/ contains=Something# comment',
+       ], 'E475:')
+   CheckScriptFailure([
+       'vim9script',
+       'syntax match Word /pat/ contains= # comment',
+       ], 'E406:')
+   CheckScriptFailure([
+       'vim9script',
+       'syntax match Word /pat/ contains=# comment',
+       ], 'E475:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax region Word start=/pat/ end=/pat/ # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax region Word start=/pat/ end=/pat/# comment',
+       ], 'E475:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax sync # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax sync# comment',
+       ], 'E404:')
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax sync ccomment # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax sync ccomment# comment',
+       ], 'E404:')
+ 
+   CheckScriptSuccess([
+       'vim9script',
+       'syntax cluster Some contains=Word # comment',
+       ])
+   CheckScriptFailure([
+       'vim9script',
+       'syntax cluster Some contains=Word# comment',
+       ], 'E475:')
  enddef
  
  def Test_vim9_comment_gui()
*** ../vim-8.2.0612/runtime/lang/menu_de_de.latin1.vim  2019-04-01 
22:52:31.000000000 +0200
--- runtime/lang/menu_de_de.latin1.vim  2020-04-20 22:29:12.022754697 +0200
***************
*** 188,194 ****
  menutrans &Off                                        &Aus
  menutrans &Manual                             &Manuell
  menutrans A&utomatic                          A&utomatisch
! menutrans on/off\ for\ &This\ file            An/Aus (diese\ &Datei)
  menutrans Co&lor\ test                                Test\ der\ Farben
  menutrans &Highlight\ test                    Test\ der\ Un&terstreichungen
  menutrans &Convert\ to\ HTML                  Konvertieren\ nach\ &HTML
--- 188,194 ----
  menutrans &Off                                        &Aus
  menutrans &Manual                             &Manuell
  menutrans A&utomatic                          A&utomatisch
! menutrans on/off\ for\ &This\ file            An/Aus\ (diese\ &Datei)
  menutrans Co&lor\ test                                Test\ der\ Farben
  menutrans &Highlight\ test                    Test\ der\ Un&terstreichungen
  menutrans &Convert\ to\ HTML                  Konvertieren\ nach\ &HTML
*** ../vim-8.2.0612/src/version.c       2020-04-20 19:42:06.594078510 +0200
--- src/version.c       2020-04-20 19:56:40.687885636 +0200
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     613,
  /**/

-- 
For society, it's probably a good thing that engineers value function over
appearance.  For example, you wouldn't want engineers to build nuclear power
plants that only _look_ like they would keep all the radiation inside.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202004202042.03KKgx5u021107%40masaka.moolenaar.net.

Raspunde prin e-mail lui