bug-indent
[Top][All Lists]
Advanced

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

[PATCH] Remove dead paren_level code


From: Petr Písař
Subject: [PATCH] Remove dead paren_level code
Date: Thu, 28 Apr 2011 16:54:32 +0200

Local variable `paren_level' in src/output.c:dump_line_code() is
initialized to 0, then compared to bigger than 0 leading to one dead
branch, then the variable is incremented with count_parens() return
value, and then the variable is use never more. Also count_parens()
has no side effect. Thus this patch removes this useless code.
---
 src/output.c |   40 ----------------------------------------
 1 files changed, 0 insertions(+), 40 deletions(-)

diff --git a/src/output.c b/src/output.c
index f0ca617..6c7c330 100644
--- a/src/output.c
+++ b/src/output.c
@@ -773,37 +773,6 @@ static int dump_line_label(void)
  *
  */
 
-static int count_parens(
-    const char * string)
-{
-    int paren_level = 0;
-
-    while (*string)
-    {
-        switch (*string)
-        {
-        case '(':
-        case '[':
-            paren_level++;
-            break;
-        case ')':
-        case ']':
-            paren_level--;
-            break;
-        default:
-            break;
-        }
-
-        string++;
-    }
-
-    return paren_level;
-}
-
-/**
- *
- */
-
 static void dump_line_code(
     int     * pcur_col,
     int     * pnot_truncated,
@@ -811,8 +780,6 @@ static void dump_line_code(
     BOOLEAN * pbreak_line,
     int       target_col_break)
 {
-   int paren_level   = 0;
-
    if (s_code != e_code)
    {                       /* print code section, if any */
       int i;
@@ -835,11 +802,6 @@ static void dump_line_code(
          target_col = compute_code_target (paren_targ);
       }
 
-      if (paren_level > 0)
-      {
-         target_col += 
parser_state_tos->paren_indents[parser_state_tos->p_l_follow + paren_level- 1];
-      }
-
      /* If a line ends in an lparen character, the following line should
       * not line up with the parenthesis, but should be indented by the
       * usual amount.  */
@@ -904,8 +866,6 @@ static void dump_line_code(
 
          *pcur_col = count_columns (*pcur_col, s_code, NULL_CHAR);
 
-         paren_level += count_parens(s_code);
-
          s_code[buf_break->offset] = c;
 
          *pnot_truncated = 0;
-- 
1.7.4.4




reply via email to

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