|
Karsten Hopp |
82bd06 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
82bd06 |
Subject: Patch 7.3.195
|
|
Karsten Hopp |
82bd06 |
Fcc: outbox
|
|
Karsten Hopp |
82bd06 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
82bd06 |
Mime-Version: 1.0
|
|
Karsten Hopp |
82bd06 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
82bd06 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
82bd06 |
------------
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
Patch 7.3.195
|
|
Karsten Hopp |
82bd06 |
Problem: "} else" causes following lines to be indented too much. (Rouben
|
|
Karsten Hopp |
82bd06 |
Rostamian)
|
|
Karsten Hopp |
82bd06 |
Solution: Better detection for the "else". (Lech Lorens)
|
|
Karsten Hopp |
82bd06 |
Files: src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
*** ../vim-7.3.194/src/misc1.c 2011-05-10 16:41:13.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
--- src/misc1.c 2011-05-19 16:30:28.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
***************
|
|
Karsten Hopp |
82bd06 |
*** 5482,5489 ****
|
|
Karsten Hopp |
82bd06 |
* Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
|
|
Karsten Hopp |
82bd06 |
* '}'.
|
|
Karsten Hopp |
82bd06 |
* Don't consider "} else" a terminated line.
|
|
Karsten Hopp |
82bd06 |
! * Don't consider a line where there are unmatched opening braces before '}',
|
|
Karsten Hopp |
82bd06 |
! * ';' or ',' a terminated line.
|
|
Karsten Hopp |
82bd06 |
* Return the character terminating the line (ending char's have precedence if
|
|
Karsten Hopp |
82bd06 |
* both apply in order to determine initializations).
|
|
Karsten Hopp |
82bd06 |
*/
|
|
Karsten Hopp |
82bd06 |
--- 5482,5489 ----
|
|
Karsten Hopp |
82bd06 |
* Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
|
|
Karsten Hopp |
82bd06 |
* '}'.
|
|
Karsten Hopp |
82bd06 |
* Don't consider "} else" a terminated line.
|
|
Karsten Hopp |
82bd06 |
! * If a line begins with an "else", only consider it terminated if no unmatched
|
|
Karsten Hopp |
82bd06 |
! * opening braces follow (handle "else { foo();" correctly).
|
|
Karsten Hopp |
82bd06 |
* Return the character terminating the line (ending char's have precedence if
|
|
Karsten Hopp |
82bd06 |
* both apply in order to determine initializations).
|
|
Karsten Hopp |
82bd06 |
*/
|
|
Karsten Hopp |
82bd06 |
***************
|
|
Karsten Hopp |
82bd06 |
*** 5493,5513 ****
|
|
Karsten Hopp |
82bd06 |
int incl_open; /* include '{' at the end as terminator */
|
|
Karsten Hopp |
82bd06 |
int incl_comma; /* recognize a trailing comma */
|
|
Karsten Hopp |
82bd06 |
{
|
|
Karsten Hopp |
82bd06 |
! char_u found_start = 0;
|
|
Karsten Hopp |
82bd06 |
! unsigned n_open = 0;
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
s = cin_skipcomment(s);
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
if (*s == '{' || (*s == '}' && !cin_iselse(s)))
|
|
Karsten Hopp |
82bd06 |
found_start = *s;
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
while (*s)
|
|
Karsten Hopp |
82bd06 |
{
|
|
Karsten Hopp |
82bd06 |
/* skip over comments, "" strings and 'c'haracters */
|
|
Karsten Hopp |
82bd06 |
s = skip_string(cin_skipcomment(s));
|
|
Karsten Hopp |
82bd06 |
if (*s == '}' && n_open > 0)
|
|
Karsten Hopp |
82bd06 |
--n_open;
|
|
Karsten Hopp |
82bd06 |
! if (n_open == 0
|
|
Karsten Hopp |
82bd06 |
&& (*s == ';' || *s == '}' || (incl_comma && *s == ','))
|
|
Karsten Hopp |
82bd06 |
&& cin_nocode(s + 1))
|
|
Karsten Hopp |
82bd06 |
return *s;
|
|
Karsten Hopp |
82bd06 |
--- 5493,5517 ----
|
|
Karsten Hopp |
82bd06 |
int incl_open; /* include '{' at the end as terminator */
|
|
Karsten Hopp |
82bd06 |
int incl_comma; /* recognize a trailing comma */
|
|
Karsten Hopp |
82bd06 |
{
|
|
Karsten Hopp |
82bd06 |
! char_u found_start = 0;
|
|
Karsten Hopp |
82bd06 |
! unsigned n_open = 0;
|
|
Karsten Hopp |
82bd06 |
! int is_else = FALSE;
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
s = cin_skipcomment(s);
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
if (*s == '{' || (*s == '}' && !cin_iselse(s)))
|
|
Karsten Hopp |
82bd06 |
found_start = *s;
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
+ if (!found_start)
|
|
Karsten Hopp |
82bd06 |
+ is_else = cin_iselse(s);
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
while (*s)
|
|
Karsten Hopp |
82bd06 |
{
|
|
Karsten Hopp |
82bd06 |
/* skip over comments, "" strings and 'c'haracters */
|
|
Karsten Hopp |
82bd06 |
s = skip_string(cin_skipcomment(s));
|
|
Karsten Hopp |
82bd06 |
if (*s == '}' && n_open > 0)
|
|
Karsten Hopp |
82bd06 |
--n_open;
|
|
Karsten Hopp |
82bd06 |
! if ((!is_else || n_open == 0)
|
|
Karsten Hopp |
82bd06 |
&& (*s == ';' || *s == '}' || (incl_comma && *s == ','))
|
|
Karsten Hopp |
82bd06 |
&& cin_nocode(s + 1))
|
|
Karsten Hopp |
82bd06 |
return *s;
|
|
Karsten Hopp |
82bd06 |
*** ../vim-7.3.194/src/testdir/test3.in 2011-05-10 13:38:23.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
--- src/testdir/test3.in 2011-05-19 16:29:01.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
***************
|
|
Karsten Hopp |
82bd06 |
*** 1345,1351 ****
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
STARTTEST
|
|
Karsten Hopp |
82bd06 |
:set cino&
|
|
Karsten Hopp |
82bd06 |
! 2kdd=][
|
|
Karsten Hopp |
82bd06 |
ENDTEST
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
void func(void)
|
|
Karsten Hopp |
82bd06 |
--- 1345,1351 ----
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
STARTTEST
|
|
Karsten Hopp |
82bd06 |
:set cino&
|
|
Karsten Hopp |
82bd06 |
! 2kdd=4][
|
|
Karsten Hopp |
82bd06 |
ENDTEST
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
void func(void)
|
|
Karsten Hopp |
82bd06 |
***************
|
|
Karsten Hopp |
82bd06 |
*** 1359,1364 ****
|
|
Karsten Hopp |
82bd06 |
--- 1359,1392 ----
|
|
Karsten Hopp |
82bd06 |
printf("Foo!\n");
|
|
Karsten Hopp |
82bd06 |
}
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
+ void func1(void)
|
|
Karsten Hopp |
82bd06 |
+ {
|
|
Karsten Hopp |
82bd06 |
+ char* tab[] = {"foo", "bar",
|
|
Karsten Hopp |
82bd06 |
+ "baz", "quux",
|
|
Karsten Hopp |
82bd06 |
+ "this line used", "to be indented incorrectly"};
|
|
Karsten Hopp |
82bd06 |
+ foo();
|
|
Karsten Hopp |
82bd06 |
+ }
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ void func2(void)
|
|
Karsten Hopp |
82bd06 |
+ {
|
|
Karsten Hopp |
82bd06 |
+ int tab[] =
|
|
Karsten Hopp |
82bd06 |
+ {1, 2,
|
|
Karsten Hopp |
82bd06 |
+ 3, 4,
|
|
Karsten Hopp |
82bd06 |
+ 5, 6};
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ printf("This line used to be indented incorrectly.\n");
|
|
Karsten Hopp |
82bd06 |
+ }
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ void func3(void)
|
|
Karsten Hopp |
82bd06 |
+ {
|
|
Karsten Hopp |
82bd06 |
+ int tab[] = {
|
|
Karsten Hopp |
82bd06 |
+ 1, 2,
|
|
Karsten Hopp |
82bd06 |
+ 3, 4,
|
|
Karsten Hopp |
82bd06 |
+ 5, 6};
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ printf("Don't you dare indent this line incorrectly!\n);
|
|
Karsten Hopp |
82bd06 |
+ }
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
STARTTEST
|
|
Karsten Hopp |
82bd06 |
:set cino&
|
|
Karsten Hopp |
82bd06 |
2kdd=][
|
|
Karsten Hopp |
82bd06 |
*** ../vim-7.3.194/src/testdir/test3.ok 2011-05-10 13:38:23.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
--- src/testdir/test3.ok 2011-05-19 16:29:01.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
***************
|
|
Karsten Hopp |
82bd06 |
*** 1216,1221 ****
|
|
Karsten Hopp |
82bd06 |
--- 1216,1249 ----
|
|
Karsten Hopp |
82bd06 |
printf("Foo!\n");
|
|
Karsten Hopp |
82bd06 |
}
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
+ void func1(void)
|
|
Karsten Hopp |
82bd06 |
+ {
|
|
Karsten Hopp |
82bd06 |
+ char* tab[] = {"foo", "bar",
|
|
Karsten Hopp |
82bd06 |
+ "baz", "quux",
|
|
Karsten Hopp |
82bd06 |
+ "this line used", "to be indented incorrectly"};
|
|
Karsten Hopp |
82bd06 |
+ foo();
|
|
Karsten Hopp |
82bd06 |
+ }
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ void func2(void)
|
|
Karsten Hopp |
82bd06 |
+ {
|
|
Karsten Hopp |
82bd06 |
+ int tab[] =
|
|
Karsten Hopp |
82bd06 |
+ {1, 2,
|
|
Karsten Hopp |
82bd06 |
+ 3, 4,
|
|
Karsten Hopp |
82bd06 |
+ 5, 6};
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ printf("This line used to be indented incorrectly.\n");
|
|
Karsten Hopp |
82bd06 |
+ }
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ void func3(void)
|
|
Karsten Hopp |
82bd06 |
+ {
|
|
Karsten Hopp |
82bd06 |
+ int tab[] = {
|
|
Karsten Hopp |
82bd06 |
+ 1, 2,
|
|
Karsten Hopp |
82bd06 |
+ 3, 4,
|
|
Karsten Hopp |
82bd06 |
+ 5, 6};
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
+ printf("Don't you dare indent this line incorrectly!\n);
|
|
Karsten Hopp |
82bd06 |
+ }
|
|
Karsten Hopp |
82bd06 |
+
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
void func(void)
|
|
Karsten Hopp |
82bd06 |
{
|
|
Karsten Hopp |
82bd06 |
*** ../vim-7.3.194/src/version.c 2011-05-19 14:59:07.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
--- src/version.c 2011-05-19 16:34:16.000000000 +0200
|
|
Karsten Hopp |
82bd06 |
***************
|
|
Karsten Hopp |
82bd06 |
*** 711,712 ****
|
|
Karsten Hopp |
82bd06 |
--- 711,714 ----
|
|
Karsten Hopp |
82bd06 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
82bd06 |
+ /**/
|
|
Karsten Hopp |
82bd06 |
+ 195,
|
|
Karsten Hopp |
82bd06 |
/**/
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
--
|
|
Karsten Hopp |
82bd06 |
I AM THANKFUL...
|
|
Karsten Hopp |
82bd06 |
...for the taxes that I pay because it means that I am employed.
|
|
Karsten Hopp |
82bd06 |
|
|
Karsten Hopp |
82bd06 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
82bd06 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
82bd06 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
82bd06 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|