|
Karsten Hopp |
aab0cf |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
aab0cf |
Subject: Patch 7.3.180
|
|
Karsten Hopp |
aab0cf |
Fcc: outbox
|
|
Karsten Hopp |
aab0cf |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
aab0cf |
Mime-Version: 1.0
|
|
Karsten Hopp |
aab0cf |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
aab0cf |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
aab0cf |
------------
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
Patch 7.3.180
|
|
Karsten Hopp |
aab0cf |
Problem: When both a middle part of 'comments' matches and an end part, the
|
|
Karsten Hopp |
aab0cf |
middle part was used errornously.
|
|
Karsten Hopp |
aab0cf |
Solution: After finding the middle part match continue looking for a better
|
|
Karsten Hopp |
aab0cf |
end part match. (partly by Lech Lorens)
|
|
Karsten Hopp |
aab0cf |
Files: src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
*** ../vim-7.3.179/src/misc1.c 2011-05-10 11:56:26.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
--- src/misc1.c 2011-05-10 13:24:38.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
***************
|
|
Karsten Hopp |
aab0cf |
*** 1561,1566 ****
|
|
Karsten Hopp |
aab0cf |
--- 1561,1569 ----
|
|
Karsten Hopp |
aab0cf |
char_u part_buf[COM_MAX_LEN]; /* buffer for one option part */
|
|
Karsten Hopp |
aab0cf |
char_u *string; /* pointer to comment string */
|
|
Karsten Hopp |
aab0cf |
char_u *list;
|
|
Karsten Hopp |
aab0cf |
+ int middle_match_len = 0;
|
|
Karsten Hopp |
aab0cf |
+ char_u *prev_list;
|
|
Karsten Hopp |
aab0cf |
+ char_u *saved_flags;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
i = 0;
|
|
Karsten Hopp |
aab0cf |
while (vim_iswhite(line[i])) /* leading white space is ignored */
|
|
Karsten Hopp |
aab0cf |
***************
|
|
Karsten Hopp |
aab0cf |
*** 1569,1575 ****
|
|
Karsten Hopp |
aab0cf |
/*
|
|
Karsten Hopp |
aab0cf |
* Repeat to match several nested comment strings.
|
|
Karsten Hopp |
aab0cf |
*/
|
|
Karsten Hopp |
aab0cf |
! while (line[i])
|
|
Karsten Hopp |
aab0cf |
{
|
|
Karsten Hopp |
aab0cf |
/*
|
|
Karsten Hopp |
aab0cf |
* scan through the 'comments' option for a match
|
|
Karsten Hopp |
aab0cf |
--- 1572,1578 ----
|
|
Karsten Hopp |
aab0cf |
/*
|
|
Karsten Hopp |
aab0cf |
* Repeat to match several nested comment strings.
|
|
Karsten Hopp |
aab0cf |
*/
|
|
Karsten Hopp |
aab0cf |
! while (line[i] != NUL)
|
|
Karsten Hopp |
aab0cf |
{
|
|
Karsten Hopp |
aab0cf |
/*
|
|
Karsten Hopp |
aab0cf |
* scan through the 'comments' option for a match
|
|
Karsten Hopp |
aab0cf |
***************
|
|
Karsten Hopp |
aab0cf |
*** 1577,1658 ****
|
|
Karsten Hopp |
aab0cf |
found_one = FALSE;
|
|
Karsten Hopp |
aab0cf |
for (list = curbuf->b_p_com; *list; )
|
|
Karsten Hopp |
aab0cf |
{
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * Get one option part into part_buf[]. Advance list to next one.
|
|
Karsten Hopp |
aab0cf |
! * put string at start of string.
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
! if (!got_com && flags != NULL) /* remember where flags started */
|
|
Karsten Hopp |
aab0cf |
! *flags = list;
|
|
Karsten Hopp |
aab0cf |
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
|
Karsten Hopp |
aab0cf |
string = vim_strchr(part_buf, ':');
|
|
Karsten Hopp |
aab0cf |
if (string == NULL) /* missing ':', ignore this part */
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
*string++ = NUL; /* isolate flags from string */
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * When already found a nested comment, only accept further
|
|
Karsten Hopp |
aab0cf |
! * nested comments.
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
if (got_com && vim_strchr(part_buf, COM_NEST) == NULL)
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* When 'O' flag used don't use for "O" command */
|
|
Karsten Hopp |
aab0cf |
if (backward && vim_strchr(part_buf, COM_NOBACK) != NULL)
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * Line contents and string must match.
|
|
Karsten Hopp |
aab0cf |
* When string starts with white space, must have some white space
|
|
Karsten Hopp |
aab0cf |
* (but the amount does not need to match, there might be a mix of
|
|
Karsten Hopp |
aab0cf |
! * TABs and spaces).
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
if (vim_iswhite(string[0]))
|
|
Karsten Hopp |
aab0cf |
{
|
|
Karsten Hopp |
aab0cf |
if (i == 0 || !vim_iswhite(line[i - 1]))
|
|
Karsten Hopp |
aab0cf |
! continue;
|
|
Karsten Hopp |
aab0cf |
while (vim_iswhite(string[0]))
|
|
Karsten Hopp |
aab0cf |
++string;
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
|
|
Karsten Hopp |
aab0cf |
;
|
|
Karsten Hopp |
aab0cf |
if (string[j] != NUL)
|
|
Karsten Hopp |
aab0cf |
! continue;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * When 'b' flag used, there must be white space or an
|
|
Karsten Hopp |
aab0cf |
! * end-of-line after the string in the line.
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
if (vim_strchr(part_buf, COM_BLANK) != NULL
|
|
Karsten Hopp |
aab0cf |
&& !vim_iswhite(line[i + j]) && line[i + j] != NUL)
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * We have found a match, stop searching.
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
! i += j;
|
|
Karsten Hopp |
aab0cf |
! got_com = TRUE;
|
|
Karsten Hopp |
aab0cf |
found_one = TRUE;
|
|
Karsten Hopp |
aab0cf |
break;
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * No match found, stop scanning.
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
if (!found_one)
|
|
Karsten Hopp |
aab0cf |
break;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * Include any trailing white space.
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
while (vim_iswhite(line[i]))
|
|
Karsten Hopp |
aab0cf |
++i;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /*
|
|
Karsten Hopp |
aab0cf |
! * If this comment doesn't nest, stop here.
|
|
Karsten Hopp |
aab0cf |
! */
|
|
Karsten Hopp |
aab0cf |
if (vim_strchr(part_buf, COM_NEST) == NULL)
|
|
Karsten Hopp |
aab0cf |
break;
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
return (got_com ? i : 0);
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
#endif
|
|
Karsten Hopp |
aab0cf |
--- 1580,1683 ----
|
|
Karsten Hopp |
aab0cf |
found_one = FALSE;
|
|
Karsten Hopp |
aab0cf |
for (list = curbuf->b_p_com; *list; )
|
|
Karsten Hopp |
aab0cf |
{
|
|
Karsten Hopp |
aab0cf |
! /* Get one option part into part_buf[]. Advance "list" to next
|
|
Karsten Hopp |
aab0cf |
! * one. Put "string" at start of string. */
|
|
Karsten Hopp |
aab0cf |
! if (!got_com && flags != NULL)
|
|
Karsten Hopp |
aab0cf |
! *flags = list; /* remember where flags started */
|
|
Karsten Hopp |
aab0cf |
! prev_list = list;
|
|
Karsten Hopp |
aab0cf |
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
|
Karsten Hopp |
aab0cf |
string = vim_strchr(part_buf, ':');
|
|
Karsten Hopp |
aab0cf |
if (string == NULL) /* missing ':', ignore this part */
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
*string++ = NUL; /* isolate flags from string */
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* If we found a middle match previously, use that match when this
|
|
Karsten Hopp |
aab0cf |
! * is not a middle or end. */
|
|
Karsten Hopp |
aab0cf |
! if (middle_match_len != 0
|
|
Karsten Hopp |
aab0cf |
! && vim_strchr(part_buf, COM_MIDDLE) == NULL
|
|
Karsten Hopp |
aab0cf |
! && vim_strchr(part_buf, COM_END) == NULL)
|
|
Karsten Hopp |
aab0cf |
! break;
|
|
Karsten Hopp |
aab0cf |
!
|
|
Karsten Hopp |
aab0cf |
! /* When we already found a nested comment, only accept further
|
|
Karsten Hopp |
aab0cf |
! * nested comments. */
|
|
Karsten Hopp |
aab0cf |
if (got_com && vim_strchr(part_buf, COM_NEST) == NULL)
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* When 'O' flag present and using "O" command skip this one. */
|
|
Karsten Hopp |
aab0cf |
if (backward && vim_strchr(part_buf, COM_NOBACK) != NULL)
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* Line contents and string must match.
|
|
Karsten Hopp |
aab0cf |
* When string starts with white space, must have some white space
|
|
Karsten Hopp |
aab0cf |
* (but the amount does not need to match, there might be a mix of
|
|
Karsten Hopp |
aab0cf |
! * TABs and spaces). */
|
|
Karsten Hopp |
aab0cf |
if (vim_iswhite(string[0]))
|
|
Karsten Hopp |
aab0cf |
{
|
|
Karsten Hopp |
aab0cf |
if (i == 0 || !vim_iswhite(line[i - 1]))
|
|
Karsten Hopp |
aab0cf |
! continue; /* missing shite space */
|
|
Karsten Hopp |
aab0cf |
while (vim_iswhite(string[0]))
|
|
Karsten Hopp |
aab0cf |
++string;
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
|
|
Karsten Hopp |
aab0cf |
;
|
|
Karsten Hopp |
aab0cf |
if (string[j] != NUL)
|
|
Karsten Hopp |
aab0cf |
! continue; /* string doesn't match */
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* When 'b' flag used, there must be white space or an
|
|
Karsten Hopp |
aab0cf |
! * end-of-line after the string in the line. */
|
|
Karsten Hopp |
aab0cf |
if (vim_strchr(part_buf, COM_BLANK) != NULL
|
|
Karsten Hopp |
aab0cf |
&& !vim_iswhite(line[i + j]) && line[i + j] != NUL)
|
|
Karsten Hopp |
aab0cf |
continue;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* We have found a match, stop searching unless this is a middle
|
|
Karsten Hopp |
aab0cf |
! * comment. The middle comment can be a substring of the end
|
|
Karsten Hopp |
aab0cf |
! * comment in which case it's better to return the length of the
|
|
Karsten Hopp |
aab0cf |
! * end comment and its flags. Thus we keep searching with middle
|
|
Karsten Hopp |
aab0cf |
! * and end matches and use an end match if it matches better. */
|
|
Karsten Hopp |
aab0cf |
! if (vim_strchr(part_buf, COM_MIDDLE) != NULL)
|
|
Karsten Hopp |
aab0cf |
! {
|
|
Karsten Hopp |
aab0cf |
! if (middle_match_len == 0)
|
|
Karsten Hopp |
aab0cf |
! {
|
|
Karsten Hopp |
aab0cf |
! middle_match_len = j;
|
|
Karsten Hopp |
aab0cf |
! saved_flags = prev_list;
|
|
Karsten Hopp |
aab0cf |
! }
|
|
Karsten Hopp |
aab0cf |
! continue;
|
|
Karsten Hopp |
aab0cf |
! }
|
|
Karsten Hopp |
aab0cf |
! if (middle_match_len != 0 && j > middle_match_len)
|
|
Karsten Hopp |
aab0cf |
! /* Use this match instead of the middle match, since it's a
|
|
Karsten Hopp |
aab0cf |
! * longer thus better match. */
|
|
Karsten Hopp |
aab0cf |
! middle_match_len = 0;
|
|
Karsten Hopp |
aab0cf |
!
|
|
Karsten Hopp |
aab0cf |
! if (middle_match_len == 0)
|
|
Karsten Hopp |
aab0cf |
! i += j;
|
|
Karsten Hopp |
aab0cf |
found_one = TRUE;
|
|
Karsten Hopp |
aab0cf |
break;
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! if (middle_match_len != 0)
|
|
Karsten Hopp |
aab0cf |
! {
|
|
Karsten Hopp |
aab0cf |
! /* Use the previously found middle match after failing to find a
|
|
Karsten Hopp |
aab0cf |
! * match with an end. */
|
|
Karsten Hopp |
aab0cf |
! if (!got_com && flags != NULL)
|
|
Karsten Hopp |
aab0cf |
! *flags = saved_flags;
|
|
Karsten Hopp |
aab0cf |
! i += middle_match_len;
|
|
Karsten Hopp |
aab0cf |
! found_one = TRUE;
|
|
Karsten Hopp |
aab0cf |
! }
|
|
Karsten Hopp |
aab0cf |
!
|
|
Karsten Hopp |
aab0cf |
! /* No match found, stop scanning. */
|
|
Karsten Hopp |
aab0cf |
if (!found_one)
|
|
Karsten Hopp |
aab0cf |
break;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* Include any trailing white space. */
|
|
Karsten Hopp |
aab0cf |
while (vim_iswhite(line[i]))
|
|
Karsten Hopp |
aab0cf |
++i;
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
! /* If this comment doesn't nest, stop here. */
|
|
Karsten Hopp |
aab0cf |
! got_com = TRUE;
|
|
Karsten Hopp |
aab0cf |
if (vim_strchr(part_buf, COM_NEST) == NULL)
|
|
Karsten Hopp |
aab0cf |
break;
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
+
|
|
Karsten Hopp |
aab0cf |
return (got_com ? i : 0);
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
#endif
|
|
Karsten Hopp |
aab0cf |
*** ../vim-7.3.179/src/testdir/test3.in 2011-05-10 11:56:26.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
--- src/testdir/test3.in 2011-05-10 12:05:50.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
***************
|
|
Karsten Hopp |
aab0cf |
*** 1373,1378 ****
|
|
Karsten Hopp |
aab0cf |
--- 1373,1390 ----
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
STARTTEST
|
|
Karsten Hopp |
aab0cf |
+ :set com=s1:/*,m:*,ex:*/
|
|
Karsten Hopp |
aab0cf |
+ ]]3jofoo();?
|
|
Karsten Hopp |
aab0cf |
+ ENDTEST
|
|
Karsten Hopp |
aab0cf |
+
|
|
Karsten Hopp |
aab0cf |
+ void func(void)
|
|
Karsten Hopp |
aab0cf |
+ {
|
|
Karsten Hopp |
aab0cf |
+ /*
|
|
Karsten Hopp |
aab0cf |
+ * This is a comment.
|
|
Karsten Hopp |
aab0cf |
+ */
|
|
Karsten Hopp |
aab0cf |
+ }
|
|
Karsten Hopp |
aab0cf |
+
|
|
Karsten Hopp |
aab0cf |
+ STARTTEST
|
|
Karsten Hopp |
aab0cf |
:g/^STARTTEST/.,/^ENDTEST/d
|
|
Karsten Hopp |
aab0cf |
:1;/start of AUTO/,$wq! test.out
|
|
Karsten Hopp |
aab0cf |
ENDTEST
|
|
Karsten Hopp |
aab0cf |
*** ../vim-7.3.179/src/testdir/test3.ok 2011-05-10 11:56:26.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
--- src/testdir/test3.ok 2011-05-10 12:05:50.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
***************
|
|
Karsten Hopp |
aab0cf |
*** 1225,1227 ****
|
|
Karsten Hopp |
aab0cf |
--- 1225,1236 ----
|
|
Karsten Hopp |
aab0cf |
<< "c";
|
|
Karsten Hopp |
aab0cf |
}
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
+
|
|
Karsten Hopp |
aab0cf |
+ void func(void)
|
|
Karsten Hopp |
aab0cf |
+ {
|
|
Karsten Hopp |
aab0cf |
+ /*
|
|
Karsten Hopp |
aab0cf |
+ * This is a comment.
|
|
Karsten Hopp |
aab0cf |
+ */
|
|
Karsten Hopp |
aab0cf |
+ foo();
|
|
Karsten Hopp |
aab0cf |
+ }
|
|
Karsten Hopp |
aab0cf |
+
|
|
Karsten Hopp |
aab0cf |
*** ../vim-7.3.179/src/version.c 2011-05-10 11:56:26.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
--- src/version.c 2011-05-10 13:37:28.000000000 +0200
|
|
Karsten Hopp |
aab0cf |
***************
|
|
Karsten Hopp |
aab0cf |
*** 716,717 ****
|
|
Karsten Hopp |
aab0cf |
--- 716,719 ----
|
|
Karsten Hopp |
aab0cf |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
aab0cf |
+ /**/
|
|
Karsten Hopp |
aab0cf |
+ 180,
|
|
Karsten Hopp |
aab0cf |
/**/
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
--
|
|
Karsten Hopp |
aab0cf |
"Thou shalt not follow the Null Pointer, for at its end Chaos and
|
|
Karsten Hopp |
aab0cf |
Madness lie."
|
|
Karsten Hopp |
aab0cf |
|
|
Karsten Hopp |
aab0cf |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
aab0cf |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
aab0cf |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
aab0cf |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|