bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Double C-comment bug in indent


From: Bluhm, Alex
Subject: Double C-comment bug in indent
Date: Fri, 13 Mar 2009 18:05:02 -0400

GNU Indent list,

 

I've discovered a bug in indent, where it does not correctly handle more
than one block C comment in a single line.

 

For example, running indent on the following code fragment,

 

/****//**

 * comment

 ***/

/****//***/

 

results in

 

      /****//**

 * comment

 ***/

      /****//***/

 

due to changing the comment column to the position of the second
comment.

 

Here is a patch that will fix this issue:

 

--- indent-2.2.10/src/comments.c        2008-03-11 14:50:42.000000000
-0400

+++ indent-2.2.10b/src/comments.c       2009-03-13 17:49:45.000000000
-0400

@@ -155,6 +155,7 @@

    {

      /* Boxed comment.  This block of code will return. */

       int comment_lines_count = 1;

+      char *com_ptr = 0;

       stars        = 0;

       boxed_comment = 0;

       blankline_delims = 0;

@@ -162,6 +163,15 @@

       visible_preamble = 0;

 

       start_column = current_column () - 2;

+

+      /* If preceded by a comment, don't change the comment column*/

+      for (com_ptr = s_com; com_ptr < e_com; com_ptr++) {

+          if ((*com_ptr == '*') && (*(com_ptr + 1) == '/'))

+          {

+              start_column = parser_state_tos->com_col;

+              break;

+          }

+      }

       found_column = start_column;

       parser_state_tos->box_com = 1;

       parser_state_tos->com_col = found_column;

 

Thanks,

Alex

 

 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]