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

Patch 7.4a.036

Expand Messages
  • Bram Moolenaar
    Patch 7.4a.036 Problem: p in a regexp does not match double-width characters. (Yukihiro Nakadaira) Solution: Don t count display cells, use
    Message 1 of 1 , Jul 21, 2013
    • 0 Attachment
      Patch 7.4a.036
      Problem: "\p" in a regexp does not match double-width characters.
      (Yukihiro Nakadaira)
      Solution: Don't count display cells, use vim_isprintc().
      Files: src/regexp.c, src/regexp_nfa.c, src/testdir/test64.in,
      src/testdir/test64.ok, src/testdir/test95.in,
      src/testdir/test95.ok


      *** ../vim-7.4a.035/src/regexp.c 2013-06-26 17:55:23.000000000 +0200
      --- src/regexp.c 2013-07-21 16:59:00.000000000 +0200
      ***************
      *** 4563,4576 ****
      break;

      case PRINT:
      ! if (ptr2cells(reginput) != 1)
      status = RA_NOMATCH;
      else
      ADVANCE_REGINPUT();
      break;

      case SPRINT:
      ! if (VIM_ISDIGIT(*reginput) || ptr2cells(reginput) != 1)
      status = RA_NOMATCH;
      else
      ADVANCE_REGINPUT();
      --- 4563,4576 ----
      break;

      case PRINT:
      ! if (!vim_isprintc(PTR2CHAR(reginput)))
      status = RA_NOMATCH;
      else
      ADVANCE_REGINPUT();
      break;

      case SPRINT:
      ! if (VIM_ISDIGIT(*reginput) || !vim_isprintc(PTR2CHAR(reginput)))
      status = RA_NOMATCH;
      else
      ADVANCE_REGINPUT();
      ***************
      *** 5944,5950 ****
      if (got_int)
      break;
      }
      ! else if (ptr2cells(scan) == 1 && (testval || !VIM_ISDIGIT(*scan)))
      {
      mb_ptr_adv(scan);
      }
      --- 5944,5951 ----
      if (got_int)
      break;
      }
      ! else if (vim_isprintc(PTR2CHAR(scan)) == 1
      ! && (testval || !VIM_ISDIGIT(*scan)))
      {
      mb_ptr_adv(scan);
      }
      *** ../vim-7.4a.035/src/regexp_nfa.c 2013-07-17 21:10:47.000000000 +0200
      --- src/regexp_nfa.c 2013-07-21 16:54:40.000000000 +0200
      ***************
      *** 5749,5760 ****
      break;

      case NFA_PRINT: /* \p */
      ! result = ptr2cells(reginput) == 1;
      ADD_STATE_IF_MATCH(t->state);
      break;

      case NFA_SPRINT: /* \P */
      ! result = !VIM_ISDIGIT(curc) && ptr2cells(reginput) == 1;
      ADD_STATE_IF_MATCH(t->state);
      break;

      --- 5749,5760 ----
      break;

      case NFA_PRINT: /* \p */
      ! result = vim_isprintc(PTR2CHAR(reginput));
      ADD_STATE_IF_MATCH(t->state);
      break;

      case NFA_SPRINT: /* \P */
      ! result = !VIM_ISDIGIT(curc) && vim_isprintc(PTR2CHAR(reginput));
      ADD_STATE_IF_MATCH(t->state);
      break;

      *** ../vim-7.4a.035/src/testdir/test64.in 2013-07-17 22:35:35.000000000 +0200
      --- src/testdir/test64.in 2013-07-21 16:40:23.000000000 +0200
      ***************
      *** 228,233 ****
      --- 228,234 ----
      :call add(tl, [2, '\v((ab)|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
      :call add(tl, [2, '\v(a(c*)+b)+', 'acbababaaa', 'acbabab', 'ab', ''])
      :call add(tl, [2, '\v(a|b*)+', 'aaaa', 'aaaa', ''])
      + :call add(tl, [2, '\p*', 'aá ', 'aá '])
      :"
      :" Test greedy-ness and lazy-ness
      :call add(tl, [2, 'a\{-2,7}','aaaaaaaaaaaaa', 'aa'])
      *** ../vim-7.4a.035/src/testdir/test64.ok 2013-07-17 22:35:35.000000000 +0200
      --- src/testdir/test64.ok 2013-07-21 17:00:44.000000000 +0200
      ***************
      *** 506,511 ****
      --- 506,514 ----
      OK 0 - \v(a|b*)+
      OK 1 - \v(a|b*)+
      OK 2 - \v(a|b*)+
      + OK 0 - \p*
      + OK 1 - \p*
      + OK 2 - \p*
      OK 0 - a\{-2,7}
      OK 1 - a\{-2,7}
      OK 2 - a\{-2,7}
      *** ../vim-7.4a.035/src/testdir/test95.in 2013-05-30 18:13:59.000000000 +0200
      --- src/testdir/test95.in 2013-07-21 16:53:52.000000000 +0200
      ***************
      *** 29,34 ****
      --- 29,35 ----

      :" this is not a normal "i" but 0xec
      :call add(tl, [2, '\p\+', 'ìa', 'ìa'])
      + :call add(tl, [2, '\p*', 'aあ', 'aあ'])

      :"""" Test recognition of some character classes
      :call add(tl, [2, '\i\+', '&*¨xx ', 'xx'])
      ***************
      *** 118,123 ****
      --- 119,134 ----
      :endfor
      :unlet t tl e l

      + :" check that 'ambiwidth' does not change the meaning of \p
      + :set regexpengine=1 ambiwidth=single
      + :$put ='eng 1 ambi single: ' . match(\"\u00EC\", '\p')
      + :set regexpengine=1 ambiwidth=double
      + :$put ='eng 1 ambi double: ' . match(\"\u00EC\", '\p')
      + :set regexpengine=2 ambiwidth=single
      + :$put ='eng 2 ambi single: ' . match(\"\u00EC\", '\p')
      + :set regexpengine=2 ambiwidth=double
      + :$put ='eng 2 ambi double: ' . match(\"\u00EC\", '\p')
      +
      :/\%#=1^Results/,$wq! test.out
      ENDTEST

      *** ../vim-7.4a.035/src/testdir/test95.ok 2013-05-26 15:12:17.000000000 +0200
      --- src/testdir/test95.ok 2013-07-21 17:01:22.000000000 +0200
      ***************
      *** 17,22 ****
      --- 17,25 ----
      OK 0 - \p\+
      OK 1 - \p\+
      OK 2 - \p\+
      + OK 0 - \p*
      + OK 1 - \p*
      + OK 2 - \p*
      OK 0 - \i\+
      OK 1 - \i\+
      OK 2 - \i\+
      ***************
      *** 113,115 ****
      --- 116,122 ----
      OK 0 - [^[=a=]]\+
      OK 1 - [^[=a=]]\+
      OK 2 - [^[=a=]]\+
      + eng 1 ambi single: 0
      + eng 1 ambi double: 0
      + eng 2 ambi single: 0
      + eng 2 ambi double: 0
      *** ../vim-7.4a.035/src/version.c 2013-07-17 22:35:35.000000000 +0200
      --- src/version.c 2013-07-21 16:55:42.000000000 +0200
      ***************
      *** 729,730 ****
      --- 729,732 ----
      { /* Add new patch number below this line */
      + /**/
      + 36,
      /**/

      --
      hundred-and-one symptoms of being an internet addict:
      3. Your bookmark takes 15 minutes to scroll from top to bottom.

      /// Bram Moolenaar -- Bram@... -- 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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.