- Changed the placement of closing `while' of `do {} while' command under a

-cdw option. It's now cuddled up to the brace. (#67781)
- Changed the indentation of cuddled `else': the brace is lined up under
    opening brace. Let's see if people like it. It looks less strange than
    before, but still it looks strange.
epel9
Petr Machata 19 years ago
parent 651c25007e
commit a702c51152

@ -0,0 +1,88 @@
diff -burp indent-2.2.9/src/indent.c indent-2.2.9-cdw/src/indent.c
--- indent-2.2.9/src/indent.c 2006-01-18 18:22:36.000000000 +0100
+++ indent-2.2.9-cdw/src/indent.c 2006-01-27 17:13:55.000000000 +0100
@@ -976,13 +976,10 @@ static void handle_token_semicolon(
if (!*sp_sw)
{ /* if not if for (;;) */
- do
- {
if (parse (semicolon) != total_success)
{
*file_exit_value = indent_error;
}
- } while(0);
*force_nl = true; /* force newline after a end of stmt */
}
@@ -2625,6 +2622,18 @@ static exit_values_ty indent_main_loop(v
return file_exit_value; /* RETURN */
}
+ if (type_code == sp_paren
+ && parser_state_tos->p_stack[parser_state_tos->tos] == dohead
+ && parser_state_tos->last_token == rbrace)
+ {
+ /* This is closing `while' of `do {stuff;} while'
+ statement (not `do stuff; while' command). In -cdw, we
+ want to suppress newline. */
+ if (settings.cuddle_do_while)
+ force_nl = false;
+ parser_state_tos->in_closing_br_while = true;
+ }
+
if ((type_code != comment) &&
(type_code != cplus_comment) &&
(type_code != newline) &&
diff -burp indent-2.2.9/src/indent.h indent-2.2.9-cdw/src/indent.h
--- indent-2.2.9/src/indent.h 2006-01-18 18:22:36.000000000 +0100
+++ indent-2.2.9-cdw/src/indent.h 2006-01-27 17:20:14.000000000 +0100
@@ -357,6 +357,9 @@ typedef struct parser_state
BOOLEAN in_decl; /* set to true when we are in a declaration
* statement. The processing of braces is then
* slightly different */
+ BOOLEAN in_closing_br_while; /* set to true when we are parsing
+ * closing while of do {} while
+ * statement*/
int in_stmt; /* set to 1 while in a stmt */
int in_parameter_declaration;
int ind_level; /* the current indentation level in spaces */
diff -burp indent-2.2.9/src/parse.c indent-2.2.9-cdw/src/parse.c
--- indent-2.2.9/src/parse.c 2002-08-04 19:08:41.000000000 +0200
+++ indent-2.2.9-cdw/src/parse.c 2006-01-27 17:18:52.000000000 +0100
@@ -38,6 +38,7 @@ void init_parser (void)
parser_state_tos->cstk = (int *) xmalloc (INITIAL_STACK_SIZE * sizeof (int));
parser_state_tos->paren_indents_size = 8;
parser_state_tos->paren_indents = (short *) xmalloc (parser_state_tos->paren_indents_size * sizeof (short));
+ parser_state_tos->in_closing_br_while = false;
/* Although these are supposed to grow if we reach the end,
* I can find no place in the code which does this. */
@@ -380,6 +381,14 @@ exit_values_ty parse (
parser_state_tos->ind_level = parser_state_tos->i_l_follow;
parser_state_tos->il[parser_state_tos->tos] = parser_state_tos->i_l_follow;
+
+ if (parser_state_tos->in_closing_br_while
+ && settings.cuddle_do_while
+ && !settings.btype_2)
+ {
+ parser_state_tos->ind_level += settings.brace_indent;
+ }
+ parser_state_tos->in_closing_br_while = false;
}
else
{ /* it is a while loop */
@@ -409,6 +418,12 @@ exit_values_ty parse (
parser_state_tos->p_stack[parser_state_tos->tos] = elsehead;
/* remember if with else */
parser_state_tos->search_brace = true;
+
+ if (settings.cuddle_else
+ && !settings.btype_2)
+ {
+ parser_state_tos->ind_level += settings.brace_indent;
+ }
}
break;

@ -1,7 +1,7 @@
Summary: A GNU program for formatting C code. Summary: A GNU program for formatting C code.
Name: indent Name: indent
Version: 2.2.9 Version: 2.2.9
Release: 9 Release: 10
License: GPL License: GPL
Group: Applications/Text Group: Applications/Text
URL: http://www.gnu.org/software/indent/ URL: http://www.gnu.org/software/indent/
@ -9,6 +9,7 @@ Source: ftp://ftp.gnu.org/pub/gnu/indent/indent-%{version}.tar.gz
Patch: indent-2.2.9-fix.patch Patch: indent-2.2.9-fix.patch
Patch2: indent-2.2.9-gcc4.patch Patch2: indent-2.2.9-gcc4.patch
Patch3: indent-2.2.9-explicits.patch Patch3: indent-2.2.9-explicits.patch
Patch4: indent-2.2.9-cdw.patch
Prereq: /sbin/install-info Prereq: /sbin/install-info
BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRoot: %{_tmppath}/%{name}-%{version}-root
@ -26,6 +27,7 @@ you want a program to format your code.
%patch -p1 %patch -p1
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
%patch4 -p1
%build %build
@ -64,7 +66,14 @@ fi
%changelog %changelog
* Wed Jan 18 2006 Petr Machata <pmachata@redhat.com> * Wed Jan 27 2006 Petr Machata <pmachata@redhat.com> 2.2.9-10
- Changed the placement of closing `while' of `do {} while' command
under a -cdw option. It's now cuddled up to the brace. (#67781)
- Changed the indentation of cuddled `else': the brace is lined up
under opening brace. Let's see if people like it. It looks less
strange than before, but still it looks strange.
* Wed Jan 18 2006 Petr Machata <pmachata@redhat.com> 2.2.9-9
- Silenting some warnings, voidifying some functions that were - Silenting some warnings, voidifying some functions that were
implicitly int but didn't actually return anything. (#114376) implicitly int but didn't actually return anything. (#114376)

Loading…
Cancel
Save