Loading ...
Sorry, an error occurred while loading the content.

Patch 7.2.010

Expand Messages
  • Bram Moolenaar
    Patch 7.2.010 Problem: When using K in Visual mode not all characters are properly escaped. (Ben Schmidt) Solution: Use a function with the
    Message 1 of 3 , Sep 6 7:56 AM
    • 0 Attachment
      Patch 7.2.010
      Problem: When using "K" in Visual mode not all characters are properly
      escaped. (Ben Schmidt)
      Solution: Use a function with the functionality of shellescape(). (Jan
      Minar)
      Files: src/mbyte.c, src/misc2.c, src/normal.c


      *** ../vim-7.2.009/src/mbyte.c Wed Aug 6 18:45:36 2008
      --- src/mbyte.c Wed Sep 3 22:34:48 2008
      ***************
      *** 2540,2546 ****
      return (int)(p - q);
      }

      - #if defined(FEAT_EVAL) || defined(PROTO)
      /*
      * Copy a character from "*fp" to "*tp" and advance the pointers.
      */
      --- 2540,2545 ----
      ***************
      *** 2555,2561 ****
      *tp += l;
      *fp += l;
      }
      - #endif

      /*
      * Return the offset from "p" to the first byte of a character. When "p" is
      --- 2554,2559 ----
      *** ../vim-7.2.009/src/misc2.c Thu Jul 24 20:28:58 2008
      --- src/misc2.c Wed Sep 3 22:05:21 2008
      ***************
      *** 1257,1263 ****
      return escaped_string;
      }

      - #if !defined(BACKSLASH_IN_FILENAME) || defined(FEAT_EVAL) || defined(PROTO)
      /*
      * Return TRUE when 'shell' has "csh" in the tail.
      */
      --- 1257,1262 ----
      ***************
      *** 1266,1274 ****
      {
      return (strstr((char *)gettail(p_sh), "csh") != NULL);
      }
      - #endif

      - #if defined(FEAT_EVAL) || defined(PROTO)
      /*
      * Escape "string" for use as a shell argument with system().
      * This uses single quotes, except when we know we need to use double qoutes
      --- 1265,1271 ----
      ***************
      *** 1391,1397 ****

      return escaped_string;
      }
      - #endif

      /*
      * Like vim_strsave(), but make all characters uppercase.
      --- 1388,1393 ----
      *** ../vim-7.2.009/src/normal.c Thu Jul 31 22:03:54 2008
      --- src/normal.c Sat Sep 6 15:06:07 2008
      ***************
      *** 5469,5474 ****
      --- 5469,5479 ----
      STRCPY(buf, "he! ");
      else
      {
      + /* An external command will probably use an argument starting
      + * with "-" as an option. To avoid trouble we skip the "-". */
      + while (*ptr == '-')
      + ++ptr;
      +
      /* When a count is given, turn it into a range. Is this
      * really what we want? */
      isman = (STRCMP(kp, "man") == 0);
      ***************
      *** 5511,5547 ****
      /*
      * Now grab the chars in the identifier
      */
      ! if (cmdchar == '*')
      ! aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
      ! else if (cmdchar == '#')
      ! aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
      ! else if (cmdchar == 'K' && !kp_help)
      ! aux_ptr = (char_u *)" \t\\\"|!";
      ! else
      ! /* Don't escape spaces and Tabs in a tag with a backslash */
      ! aux_ptr = (char_u *)"\\|\"";
      !
      ! p = buf + STRLEN(buf);
      ! while (n-- > 0)
      ! {
      ! /* put a backslash before \ and some others */
      ! if (vim_strchr(aux_ptr, *ptr) != NULL)
      ! *p++ = '\\';
      ! #ifdef FEAT_MBYTE
      ! /* When current byte is a part of multibyte character, copy all bytes
      ! * of that character. */
      ! if (has_mbyte)
      {
      ! int i;
      ! int len = (*mb_ptr2len)(ptr) - 1;
      !
      ! for (i = 0; i < len && n >= 1; ++i, --n)
      ! *p++ = *ptr++;
      }
      #endif
      ! *p++ = *ptr++;
      }
      - *p = NUL;

      /*
      * Execute the command.
      --- 5516,5572 ----
      /*
      * Now grab the chars in the identifier
      */
      ! if (cmdchar == 'K' && !kp_help)
      ! {
      ! /* Escape the argument properly for a shell command */
      ! p = vim_strsave_shellescape(ptr, TRUE);
      ! if (p == NULL)
      {
      ! vim_free(buf);
      ! return;
      }
      + buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
      + if (buf == NULL)
      + {
      + vim_free(buf);
      + vim_free(p);
      + return;
      + }
      + STRCAT(buf, p);
      + vim_free(p);
      + }
      + else
      + {
      + if (cmdchar == '*')
      + aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
      + else if (cmdchar == '#')
      + aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
      + else
      + /* Don't escape spaces and Tabs in a tag with a backslash */
      + aux_ptr = (char_u *)"\\|\"\n*?[";
      +
      + p = buf + STRLEN(buf);
      + while (n-- > 0)
      + {
      + /* put a backslash before \ and some others */
      + if (vim_strchr(aux_ptr, *ptr) != NULL)
      + *p++ = '\\';
      + #ifdef FEAT_MBYTE
      + /* When current byte is a part of multibyte character, copy all
      + * bytes of that character. */
      + if (has_mbyte)
      + {
      + int i;
      + int len = (*mb_ptr2len)(ptr) - 1;
      +
      + for (i = 0; i < len && n >= 1; ++i, --n)
      + *p++ = *ptr++;
      + }
      #endif
      ! *p++ = *ptr++;
      ! }
      ! *p = NUL;
      }

      /*
      * Execute the command.
      *** ../vim-7.2.009/src/version.c Mon Sep 1 17:56:05 2008
      --- src/version.c Sat Sep 6 16:26:42 2008
      ***************
      *** 678,679 ****
      --- 678,681 ----
      { /* Add new patch number below this line */
      + /**/
      + 10,
      /**/

      --
      Q. What happens to programmers when they die?
      A: MS-Windows programmers are reinstalled. C++ programmers become undefined,
      anyone who refers to them will die as well. Java programmers reincarnate
      after being garbage collected.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • James Vega
      ... This ended up breaking the functionality of K all together. The entire line, starting from the beginning of the word under the cursor, is used in the
      Message 2 of 3 , Oct 3, 2008
      • 0 Attachment
        On Sat, Sep 06, 2008 at 04:56:25PM +0200, Bram Moolenaar wrote:
        > Patch 7.2.010
        > Problem: When using "K" in Visual mode not all characters are properly
        > escaped. (Ben Schmidt)
        > Solution: Use a function with the functionality of shellescape(). (Jan
        > Minar)
        > Files: src/mbyte.c, src/misc2.c, src/normal.c

        This ended up breaking the functionality of K all together. The entire
        line, starting from the beginning of the word under the cursor, is used
        in the command instead of just the word itself. This can be verified by
        placing the cursor on the word popen in the following line and pressing
        K.

        FILE *popen(const char *command, const char *type);

        The attached patch fixes the problem.

        --
        James
        GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>
      • Bram Moolenaar
        ... Thanks. This is not valid C (can t allocate an array with variable size), but it does point out the location where the fix should go. -- hundred-and-one
        Message 3 of 3 , Oct 30, 2008
        • 0 Attachment
          James Vega wrote:

          > On Sat, Sep 06, 2008 at 04:56:25PM +0200, Bram Moolenaar wrote:
          > > Patch 7.2.010
          > > Problem: When using "K" in Visual mode not all characters are properly
          > > escaped. (Ben Schmidt)
          > > Solution: Use a function with the functionality of shellescape(). (Jan
          > > Minar)
          > > Files: src/mbyte.c, src/misc2.c, src/normal.c
          >
          > This ended up breaking the functionality of K all together. The entire
          > line, starting from the beginning of the word under the cursor, is used
          > in the command instead of just the word itself. This can be verified by
          > placing the cursor on the word popen in the following line and pressing
          > K.
          >
          > FILE *popen(const char *command, const char *type);
          >
          > The attached patch fixes the problem.

          Thanks. This is not valid C (can't allocate an array with variable
          size), but it does point out the location where the fix should go.

          --
          hundred-and-one symptoms of being an internet addict:
          152. You find yourself falling for someone you've never seen or hardly
          know, but, boy can he/she TYPE!!!!!!

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ download, build and distribute -- http://www.A-A-P.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.