home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.1076 < prev    next >
Encoding:
Internet Message Format  |  2013-05-29  |  12.0 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.1076
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.1076
  11. Problem:    New regexp engine: \@= and \& don't work.
  12. Solution:   Make these items work.  Add column info to logging.
  13. Files:        src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
  14.  
  15.  
  16. *** ../vim-7.3.1075/src/regexp_nfa.c    2013-05-30 19:18:27.000000000 +0200
  17. --- src/regexp_nfa.c    2013-05-30 21:41:51.000000000 +0200
  18. ***************
  19. *** 1740,1747 ****
  20.                   STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH"); break;
  21.       case NFA_PREV_ATOM_NO_WIDTH_NEG:
  22.                   STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH_NEG"); break;
  23. !     case NFA_NOPEN:            STRCPY(code, "NFA_MOPEN_INVISIBLE"); break;
  24. !     case NFA_NCLOSE:        STRCPY(code, "NFA_MCLOSE_INVISIBLE"); break;
  25.       case NFA_START_INVISIBLE:   STRCPY(code, "NFA_START_INVISIBLE"); break;
  26.       case NFA_END_INVISIBLE:        STRCPY(code, "NFA_END_INVISIBLE"); break;
  27.   
  28. --- 1740,1747 ----
  29.                   STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH"); break;
  30.       case NFA_PREV_ATOM_NO_WIDTH_NEG:
  31.                   STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH_NEG"); break;
  32. !     case NFA_NOPEN:            STRCPY(code, "NFA_NOPEN"); break;
  33. !     case NFA_NCLOSE:        STRCPY(code, "NFA_NCLOSE"); break;
  34.       case NFA_START_INVISIBLE:   STRCPY(code, "NFA_START_INVISIBLE"); break;
  35.       case NFA_END_INVISIBLE:        STRCPY(code, "NFA_END_INVISIBLE"); break;
  36.   
  37. ***************
  38. *** 2373,2384 ****
  39.           break;
  40.   
  41.       case NFA_PREV_ATOM_NO_WIDTH:
  42. !         /* The \@= operator: match the preceding atom with 0 width.
  43.            * Surrounds the preceding atom with START_INVISIBLE and
  44. !          * END_INVISIBLE, similarly to MOPEN.
  45. !          */
  46. !         /* TODO: Maybe this drops the speed? */
  47. !         goto theend;
  48.   
  49.           if (nfa_calc_size == TRUE)
  50.           {
  51. --- 2373,2381 ----
  52.           break;
  53.   
  54.       case NFA_PREV_ATOM_NO_WIDTH:
  55. !         /* The \@= operator: match the preceding atom with zero width.
  56.            * Surrounds the preceding atom with START_INVISIBLE and
  57. !          * END_INVISIBLE, similarly to MOPEN. */
  58.   
  59.           if (nfa_calc_size == TRUE)
  60.           {
  61. ***************
  62. *** 2745,2750 ****
  63. --- 2742,2750 ----
  64.       int            save_in_use;
  65.       char_u        *save_ptr;
  66.       int            i;
  67. + #ifdef ENABLE_LOG
  68. +     int            did_print = FALSE;
  69. + #endif
  70.   
  71.       if (l == NULL || state == NULL)
  72.       return;
  73. ***************
  74. *** 2782,2788 ****
  75.           /* These nodes do not need to be added, but we need to bail out
  76.            * when it was tried to be added to this list before. */
  77.           if (state->lastlist == l->id)
  78. !         return;
  79.           state->lastlist = l->id;
  80.           break;
  81.   
  82. --- 2782,2788 ----
  83.           /* These nodes do not need to be added, but we need to bail out
  84.            * when it was tried to be added to this list before. */
  85.           if (state->lastlist == l->id)
  86. !         goto skip_add;
  87.           state->lastlist = l->id;
  88.           break;
  89.   
  90. ***************
  91. *** 2792,2798 ****
  92. --- 2792,2806 ----
  93.           /* This state is already in the list, don't add it again,
  94.            * unless it is an MOPEN that is used for a backreference. */
  95.           if (!nfa_has_backref)
  96. +         {
  97. + skip_add:
  98. + #ifdef ENABLE_LOG
  99. +             nfa_set_code(state->c);
  100. +             fprintf(log_fd, "> Not adding state %d to list %d. char %d: %s\n",
  101. +                 abs(state->id), l->id, state->c, code);
  102. + #endif
  103.               return;
  104. +         }
  105.   
  106.           /* See if the same state is already in the list with the same
  107.            * positions. */
  108. ***************
  109. *** 2801,2807 ****
  110.               thread = &l->t[i];
  111.               if (thread->state->id == state->id
  112.                         && sub_equal(&thread->sub, sub))
  113. !             return;
  114.           }
  115.           }
  116.   
  117. --- 2809,2815 ----
  118.               thread = &l->t[i];
  119.               if (thread->state->id == state->id
  120.                         && sub_equal(&thread->sub, sub))
  121. !             goto skip_add;
  122.           }
  123.           }
  124.   
  125. ***************
  126. *** 2832,2843 ****
  127.                   &sub->list.line[0],
  128.                   sizeof(struct linepos) * sub->in_use);
  129.           }
  130.       }
  131.   
  132.   #ifdef ENABLE_LOG
  133. !     nfa_set_code(state->c);
  134. !     fprintf(log_fd, "> Adding state %d to list. Character %d: %s\n",
  135. !     abs(state->id), state->c, code);
  136.   #endif
  137.       switch (state->c)
  138.       {
  139. --- 2840,2878 ----
  140.                   &sub->list.line[0],
  141.                   sizeof(struct linepos) * sub->in_use);
  142.           }
  143. + #ifdef ENABLE_LOG
  144. +         {
  145. +         int col;
  146. +         if (thread->sub.in_use <= 0)
  147. +             col = -1;
  148. +         else if (REG_MULTI)
  149. +             col = thread->sub.list.multi[0].start.col;
  150. +         else
  151. +             col = (int)(thread->sub.list.line[0].start - regline);
  152. +         nfa_set_code(state->c);
  153. +         fprintf(log_fd, "> Adding state %d to list %d. char %d: %s (start col %d)\n",
  154. +                 abs(state->id), l->id, state->c, code, col);
  155. +         did_print = TRUE;
  156. +         }
  157. + #endif
  158.       }
  159.   
  160.   #ifdef ENABLE_LOG
  161. !     if (!did_print)
  162. !     {
  163. !     int col;
  164. !     if (sub->in_use <= 0)
  165. !         col = -1;
  166. !     else if (REG_MULTI)
  167. !         col = sub->list.multi[0].start.col;
  168. !     else
  169. !         col = (int)(sub->list.line[0].start - regline);
  170. !     nfa_set_code(state->c);
  171. !     fprintf(log_fd, "> Processing state %d for list %d. char %d: %s (start col %d)\n",
  172. !         abs(state->id), l->id, state->c, code, col);
  173. !     }
  174.   #endif
  175.       switch (state->c)
  176.       {
  177. ***************
  178. *** 2873,2886 ****
  179.           addstate(l, state->out, sub, off);
  180.           break;
  181.   
  182. -     /* If this state is reached, then a recursive call of nfa_regmatch()
  183. -      * succeeded. the next call saves the found submatches in the
  184. -      * first state after the "invisible" branch. */
  185. - #if 0
  186. -     case NFA_END_INVISIBLE:
  187. -         break;
  188. - #endif
  189.       case NFA_MOPEN + 0:
  190.       case NFA_MOPEN + 1:
  191.       case NFA_MOPEN + 2:
  192. --- 2908,2913 ----
  193. ***************
  194. *** 3450,3458 ****
  195.           fprintf(debug, "%s, ", code);
  196.   #endif
  197.   #ifdef ENABLE_LOG
  198. !         nfa_set_code(t->state->c);
  199. !         fprintf(log_fd, "(%d) %s, code %d ... \n", abs(t->state->id),
  200. !                               code, (int)t->state->c);
  201.   #endif
  202.   
  203.           /*
  204. --- 3477,3495 ----
  205.           fprintf(debug, "%s, ", code);
  206.   #endif
  207.   #ifdef ENABLE_LOG
  208. !         {
  209. !         int col;
  210. !         if (t->sub.in_use <= 0)
  211. !             col = -1;
  212. !         else if (REG_MULTI)
  213. !             col = t->sub.list.multi[0].start.col;
  214. !         else
  215. !             col = (int)(t->sub.list.line[0].start - regline);
  216. !         nfa_set_code(t->state->c);
  217. !         fprintf(log_fd, "(%d) char %d %s (start col %d) ... \n",
  218. !             abs(t->state->id), (int)t->state->c, code, col);
  219. !         }
  220.   #endif
  221.   
  222.           /*
  223. ***************
  224. *** 3504,3509 ****
  225. --- 3541,3547 ----
  226.               addstate_here(thislist, t->state->out, &t->sub, &listidx);
  227.           else
  228.           {
  229. +             /* TODO: only copy positions in use. */
  230.               *m = t->sub;
  231.               nfa_match = TRUE;
  232.           }
  233. ***************
  234. *** 3538,3543 ****
  235. --- 3576,3582 ----
  236.           result = nfa_regmatch(t->state->out, submatch, m);
  237.           nfa_set_neg_listids(start);
  238.           nfa_restore_listids(start, listids);
  239. +         nfa_match = FALSE;
  240.   
  241.   #ifdef ENABLE_LOG
  242.           log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
  243. ***************
  244. *** 3575,3583 ****
  245.                   t->sub.list.line[j].start = m->list.line[j].start;
  246.                   t->sub.list.line[j].end = m->list.line[j].end;
  247.               }
  248. !             t->sub.in_use = m->in_use;
  249.   
  250. !             /* t->state->out1 is the corresponding END_INVISIBLE node */
  251.               addstate_here(thislist, t->state->out1->out, &t->sub,
  252.                                       &listidx);
  253.           }
  254. --- 3614,3624 ----
  255.                   t->sub.list.line[j].start = m->list.line[j].start;
  256.                   t->sub.list.line[j].end = m->list.line[j].end;
  257.               }
  258. !             if (m->in_use > t->sub.in_use)
  259. !             t->sub.in_use = m->in_use;
  260.   
  261. !             /* t->state->out1 is the corresponding END_INVISIBLE node;
  262. !              * Add it to the current list (zero-width match). */
  263.               addstate_here(thislist, t->state->out1->out, &t->sub,
  264.                                       &listidx);
  265.           }
  266. ***************
  267. *** 4146,4152 ****
  268.       fprintf(f, "\tRegexp is \"%s\"\n", nfa_regengine.expr);
  269.   #endif
  270.       fprintf(f, "\tInput text is \"%s\" \n", reginput);
  271. !     fprintf(f, "        =======================================================\n\n\n\n\n\n\n");
  272.       nfa_print_state(f, start);
  273.       fprintf(f, "\n\n");
  274.       fclose(f);
  275. --- 4187,4193 ----
  276.       fprintf(f, "\tRegexp is \"%s\"\n", nfa_regengine.expr);
  277.   #endif
  278.       fprintf(f, "\tInput text is \"%s\" \n", reginput);
  279. !     fprintf(f, "        =======================================================\n\n");
  280.       nfa_print_state(f, start);
  281.       fprintf(f, "\n\n");
  282.       fclose(f);
  283. *** ../vim-7.3.1075/src/testdir/test64.in    2013-05-30 18:45:20.000000000 +0200
  284. --- src/testdir/test64.in    2013-05-30 21:28:06.000000000 +0200
  285. ***************
  286. *** 294,315 ****
  287.   :call add(tl, [2, '\v(a \zsif .*){2}', 'a if then a if last', 'if last', 'a if last'])
  288.   :call add(tl, [2, '\>\zs.', 'aword. ', '.'])
  289.   :"
  290. ! :"""" Tests for \@ features
  291. ! :call add(tl, [0, 'abc\@=', 'abc', 'ab'])
  292. ! :call add(tl, [0, 'abc\@=cd', 'abcd', 'abcd'])
  293. ! :call add(tl, [0, 'abc\@=', 'ababc', 'ab'])
  294.   :" will never match, no matter the input text
  295.   :call add(tl, [2, 'abcd\@=e', 'abcd'])
  296.   :" will never match
  297.   :call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
  298. ! :call add(tl, [0, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
  299.   :" no match
  300.   :call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
  301. ! :call add(tl, [0, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
  302.   :" no match
  303.   :call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
  304. ! :call add(tl, [0, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
  305. ! :call add(tl, [0, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
  306.   :"
  307.   :"""" Combining different tests and features
  308.   :call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
  309. --- 294,315 ----
  310.   :call add(tl, [2, '\v(a \zsif .*){2}', 'a if then a if last', 'if last', 'a if last'])
  311.   :call add(tl, [2, '\>\zs.', 'aword. ', '.'])
  312.   :"
  313. ! :"""" Tests for \@= and \& features
  314. ! :call add(tl, [2, 'abc\@=', 'abc', 'ab'])
  315. ! :call add(tl, [2, 'abc\@=cd', 'abcd', 'abcd'])
  316. ! :call add(tl, [2, 'abc\@=', 'ababc', 'ab'])
  317.   :" will never match, no matter the input text
  318.   :call add(tl, [2, 'abcd\@=e', 'abcd'])
  319.   :" will never match
  320.   :call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
  321. ! :call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
  322.   :" no match
  323.   :call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
  324. ! :call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
  325.   :" no match
  326.   :call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
  327. ! :call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
  328. ! :call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
  329.   :"
  330.   :"""" Combining different tests and features
  331.   :call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
  332. *** ../vim-7.3.1075/src/testdir/test64.ok    2013-05-30 18:45:20.000000000 +0200
  333. --- src/testdir/test64.ok    2013-05-30 21:29:06.000000000 +0200
  334. ***************
  335. *** 647,656 ****
  336. --- 647,659 ----
  337.   OK 2 - \>\zs.
  338.   OK 0 - abc\@=
  339.   OK 1 - abc\@=
  340. + OK 2 - abc\@=
  341.   OK 0 - abc\@=cd
  342.   OK 1 - abc\@=cd
  343. + OK 2 - abc\@=cd
  344.   OK 0 - abc\@=
  345.   OK 1 - abc\@=
  346. + OK 2 - abc\@=
  347.   OK 0 - abcd\@=e
  348.   OK 1 - abcd\@=e
  349.   OK 2 - abcd\@=e
  350. ***************
  351. *** 659,676 ****
  352. --- 662,683 ----
  353.   OK 2 - abcd\@=e
  354.   OK 0 - \v(abc)@=..
  355.   OK 1 - \v(abc)@=..
  356. + OK 2 - \v(abc)@=..
  357.   OK 0 - \(.*John\)\@=.*Bob
  358.   OK 1 - \(.*John\)\@=.*Bob
  359.   OK 2 - \(.*John\)\@=.*Bob
  360.   OK 0 - \(John.*\)\@=.*Bob
  361.   OK 1 - \(John.*\)\@=.*Bob
  362. + OK 2 - \(John.*\)\@=.*Bob
  363.   OK 0 - .*John\&.*Bob
  364.   OK 1 - .*John\&.*Bob
  365.   OK 2 - .*John\&.*Bob
  366.   OK 0 - .*John\&.*Bob
  367.   OK 1 - .*John\&.*Bob
  368. + OK 2 - .*John\&.*Bob
  369.   OK 0 - \v(test1)@=.*yep
  370.   OK 1 - \v(test1)@=.*yep
  371. + OK 2 - \v(test1)@=.*yep
  372.   OK 0 - [[:alpha:]]\{-2,6}
  373.   OK 1 - [[:alpha:]]\{-2,6}
  374.   OK 2 - [[:alpha:]]\{-2,6}
  375. *** ../vim-7.3.1075/src/version.c    2013-05-30 19:18:27.000000000 +0200
  376. --- src/version.c    2013-05-30 21:34:53.000000000 +0200
  377. ***************
  378. *** 730,731 ****
  379. --- 730,733 ----
  380.   {   /* Add new patch number below this line */
  381. + /**/
  382. +     1076,
  383.   /**/
  384.  
  385. -- 
  386. I'm not familiar with this proof, but I'm aware of a significant
  387. following of toddlers who believe that peanut butter is the solution
  388. to all of life's problems...         -- Tim Hammerquist
  389.  
  390.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  391. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  392. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  393.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  394.