9a8ec17
To: vim_dev@googlegroups.com
9a8ec17
Subject: Patch 7.3.164
9a8ec17
Fcc: outbox
9a8ec17
From: Bram Moolenaar <Bram@moolenaar.net>
9a8ec17
Mime-Version: 1.0
9a8ec17
Content-Type: text/plain; charset=UTF-8
9a8ec17
Content-Transfer-Encoding: 8bit
9a8ec17
------------
9a8ec17
9a8ec17
Patch 7.3.164
9a8ec17
Problem:    C-indenting: a preprocessor statement confuses detection of a
9a8ec17
	    function delcaration.
9a8ec17
Solution:   Ignore preprocessor lines. (Lech Lorens)  Also recognize the style
9a8ec17
	    to put a comma before the argument name.
9a8ec17
Files:	    src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
9a8ec17
9a8ec17
9a8ec17
*** ../vim-7.3.163/src/misc1.c	2011-04-11 16:56:29.000000000 +0200
9a8ec17
--- src/misc1.c	2011-04-28 12:49:55.000000000 +0200
9a8ec17
***************
9a8ec17
*** 5396,5403 ****
9a8ec17
  cin_ispreproc(s)
9a8ec17
      char_u *s;
9a8ec17
  {
9a8ec17
!     s = skipwhite(s);
9a8ec17
!     if (*s == '#')
9a8ec17
  	return TRUE;
9a8ec17
      return FALSE;
9a8ec17
  }
9a8ec17
--- 5396,5402 ----
9a8ec17
  cin_ispreproc(s)
9a8ec17
      char_u *s;
9a8ec17
  {
9a8ec17
!     if (*skipwhite(s) == '#')
9a8ec17
  	return TRUE;
9a8ec17
      return FALSE;
9a8ec17
  }
9a8ec17
***************
9a8ec17
*** 5513,5518 ****
9a8ec17
--- 5512,5521 ----
9a8ec17
      else
9a8ec17
  	s = *sp;
9a8ec17
  
9a8ec17
+     /* Ignore line starting with #. */
9a8ec17
+     if (cin_ispreproc(s))
9a8ec17
+ 	return FALSE;
9a8ec17
+ 
9a8ec17
      while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
9a8ec17
      {
9a8ec17
  	if (cin_iscomment(s))	/* ignore comments */
9a8ec17
***************
9a8ec17
*** 5538,5550 ****
9a8ec17
  		retval = TRUE;
9a8ec17
  	    goto done;
9a8ec17
  	}
9a8ec17
! 	if (*s == ',' && cin_nocode(s + 1))
9a8ec17
  	{
9a8ec17
! 	    /* ',' at the end: continue looking in the next line */
9a8ec17
  	    if (lnum >= curbuf->b_ml.ml_line_count)
9a8ec17
  		break;
9a8ec17
! 
9a8ec17
! 	    s = ml_get(++lnum);
9a8ec17
  	}
9a8ec17
  	else if (cin_iscomment(s))	/* ignore comments */
9a8ec17
  	    s = cin_skipcomment(s);
9a8ec17
--- 5541,5569 ----
9a8ec17
  		retval = TRUE;
9a8ec17
  	    goto done;
9a8ec17
  	}
9a8ec17
! 	if ((*s == ',' && cin_nocode(s + 1)) || s[1] == NUL || cin_nocode(s))
9a8ec17
  	{
9a8ec17
! 	    int comma = (*s == ',');
9a8ec17
! 
9a8ec17
! 	    /* ',' at the end: continue looking in the next line.
9a8ec17
! 	     * At the end: check for ',' in the next line, for this style:
9a8ec17
! 	     * func(arg1
9a8ec17
! 	     *       , arg2) */
9a8ec17
! 	    for (;;)
9a8ec17
! 	    {
9a8ec17
! 		if (lnum >= curbuf->b_ml.ml_line_count)
9a8ec17
! 		    break;
9a8ec17
! 		s = ml_get(++lnum);
9a8ec17
! 		if (!cin_ispreproc(s))
9a8ec17
! 		    break;
9a8ec17
! 	    }
9a8ec17
  	    if (lnum >= curbuf->b_ml.ml_line_count)
9a8ec17
  		break;
9a8ec17
! 	    /* Require a comma at end of the line or a comma or ')' at the
9a8ec17
! 	     * start of next line. */
9a8ec17
! 	    s = skipwhite(s);
9a8ec17
! 	    if (!comma && *s != ',' && *s != ')')
9a8ec17
! 		break;
9a8ec17
  	}
9a8ec17
  	else if (cin_iscomment(s))	/* ignore comments */
9a8ec17
  	    s = cin_skipcomment(s);
9a8ec17
*** ../vim-7.3.163/src/testdir/test3.in	2010-08-15 21:57:29.000000000 +0200
9a8ec17
--- src/testdir/test3.in	2011-04-28 12:15:12.000000000 +0200
9a8ec17
***************
9a8ec17
*** 1315,1320 ****
9a8ec17
--- 1315,1349 ----
9a8ec17
  }
9a8ec17
  
9a8ec17
  STARTTEST
9a8ec17
+ :set cino=(0,ts
9a8ec17
+ 2kdd=][
9a8ec17
+ ENDTEST
9a8ec17
+ 
9a8ec17
+ void func(int a
9a8ec17
+ #if defined(FOO)
9a8ec17
+ 		  , int b
9a8ec17
+ 		  , int c
9a8ec17
+ #endif
9a8ec17
+ 		 )
9a8ec17
+ {
9a8ec17
+ }
9a8ec17
+ 
9a8ec17
+ STARTTEST
9a8ec17
+ :set cino=(0
9a8ec17
+ 2kdd=][
9a8ec17
+ ENDTEST
9a8ec17
+ 
9a8ec17
+ void
9a8ec17
+ func(int a
9a8ec17
+ #if defined(FOO)
9a8ec17
+ 		  , int b
9a8ec17
+ 		  , int c
9a8ec17
+ #endif
9a8ec17
+ 		 )
9a8ec17
+ {
9a8ec17
+ }
9a8ec17
+ 
9a8ec17
+ STARTTEST
9a8ec17
  :g/^STARTTEST/.,/^ENDTEST/d
9a8ec17
  :1;/start of AUTO/,$wq! test.out
9a8ec17
  ENDTEST
9a8ec17
*** ../vim-7.3.163/src/testdir/test3.ok	2010-08-15 21:57:29.000000000 +0200
9a8ec17
--- src/testdir/test3.ok	2011-04-28 12:54:04.000000000 +0200
9a8ec17
***************
9a8ec17
*** 1183,1185 ****
9a8ec17
--- 1183,1206 ----
9a8ec17
  		foo;
9a8ec17
  }
9a8ec17
  
9a8ec17
+ 
9a8ec17
+ void func(int a
9a8ec17
+ #if defined(FOO)
9a8ec17
+ 		  , int b
9a8ec17
+ 		  , int c
9a8ec17
+ #endif
9a8ec17
+ 		 )
9a8ec17
+ {
9a8ec17
+ }
9a8ec17
+ 
9a8ec17
+ 
9a8ec17
+ 	void
9a8ec17
+ func(int a
9a8ec17
+ #if defined(FOO)
9a8ec17
+ 	 , int b
9a8ec17
+ 	 , int c
9a8ec17
+ #endif
9a8ec17
+ 	)
9a8ec17
+ {
9a8ec17
+ }
9a8ec17
+ 
9a8ec17
*** ../vim-7.3.163/src/version.c	2011-04-28 12:56:57.000000000 +0200
9a8ec17
--- src/version.c	2011-04-28 12:59:55.000000000 +0200
9a8ec17
***************
9a8ec17
*** 716,717 ****
9a8ec17
--- 716,719 ----
9a8ec17
  {   /* Add new patch number below this line */
9a8ec17
+ /**/
9a8ec17
+     164,
9a8ec17
  /**/
9a8ec17
9a8ec17
-- 
9a8ec17
Due knot trussed yore spell chequer two fined awl miss steaks.
9a8ec17
9a8ec17
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
9a8ec17
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
9a8ec17
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
9a8ec17
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///