Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1
indent
indent-2.2.10-cdw.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File indent-2.2.10-cdw.diff of Package indent
--- indent-2.2.10/src/indent.c +++ indent-2.2.10/src/indent.c @@ -1033,13 +1033,10 @@ 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 */ } @@ -2818,6 +2815,18 @@ 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) && --- indent-2.2.10/src/indent.h +++ indent-2.2.10/src/indent.h @@ -420,6 +420,9 @@ 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 */ --- indent-2.2.10/src/parse.c +++ indent-2.2.10/src/parse.c @@ -69,6 +69,7 @@ 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. */ @@ -428,6 +429,14 @@ 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 */ @@ -457,6 +466,12 @@ 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;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor