indent(1): move case_indent from parser state to the options struct

This was missed in r334927.
This commit is contained in:
pstef 2018-07-15 21:04:21 +00:00
parent 6d1b2c040a
commit e6f6e3acfa
3 changed files with 7 additions and 7 deletions

View File

@ -255,7 +255,7 @@ set_defaults(void)
* Because ps.case_indent is a float, we can't initialize it from the * Because ps.case_indent is a float, we can't initialize it from the
* table: * table:
*/ */
ps.case_indent = 0.0; /* -cli0.0 */ opt.case_indent = 0.0; /* -cli0.0 */
for (p = pro; p->p_name; p++) for (p = pro; p->p_name; p++)
if (p->p_type != PRO_SPECIAL) if (p->p_type != PRO_SPECIAL)
*p->p_obj = p->p_default; *p->p_obj = p->p_default;
@ -284,7 +284,7 @@ set_option(char *arg)
case CLI: case CLI:
if (*param_start == 0) if (*param_start == 0)
goto need_param; goto need_param;
ps.case_indent = atof(param_start); opt.case_indent = atof(param_start);
break; break;
case STDIN: case STDIN:

View File

@ -165,6 +165,8 @@ struct options {
int cuddle_else; /* true if else should cuddle up to '}' */ int cuddle_else; /* true if else should cuddle up to '}' */
int continuation_indent; /* set to the indentation between the int continuation_indent; /* set to the indentation between the
* edge of code and continuation lines */ * edge of code and continuation lines */
float case_indent; /* The distance to indent case labels from the
* switch statement */
int com_ind; /* the column in which comments to the right int com_ind; /* the column in which comments to the right
* of code should start */ * of code should start */
int decl_indent; /* column to indent declared identifiers to */ int decl_indent; /* column to indent declared identifiers to */
@ -304,8 +306,6 @@ struct parser_state {
* ignored in some cases.) */ * ignored in some cases.) */
int keyword; /* the type of a keyword or 0 */ int keyword; /* the type of a keyword or 0 */
int dumped_decl_indent; int dumped_decl_indent;
float case_indent; /* The distance to indent case labels from the
* switch statement */
int in_parameter_declaration; int in_parameter_declaration;
int tos; /* pointer to top of stack */ int tos; /* pointer to top of stack */
char procname[100]; /* The name of the current procedure */ char procname[100]; /* The name of the current procedure */

View File

@ -128,7 +128,7 @@ parse(int tk) /* tk: the code for the construct scanned */
/* /*
* it is a group as part of a while, for, etc. * it is a group as part of a while, for, etc.
*/ */
if (ps.p_stack[ps.tos] == swstmt && ps.case_indent >= 1) if (ps.p_stack[ps.tos] == swstmt && opt.case_indent >= 1)
--ps.ind_level; --ps.ind_level;
/* /*
* for a switch, brace should be two levels out from the code * for a switch, brace should be two levels out from the code
@ -189,10 +189,10 @@ parse(int tk) /* tk: the code for the construct scanned */
ps.cstk[ps.tos] = case_ind; ps.cstk[ps.tos] = case_ind;
/* save current case indent level */ /* save current case indent level */
ps.il[ps.tos] = ps.i_l_follow; ps.il[ps.tos] = ps.i_l_follow;
case_ind = ps.i_l_follow + ps.case_indent; /* cases should be one case_ind = ps.i_l_follow + opt.case_indent; /* cases should be one
* level down from * level down from
* switch */ * switch */
ps.i_l_follow += ps.case_indent + 1; /* statements should be two ps.i_l_follow += opt.case_indent + 1; /* statements should be two
* levels in */ * levels in */
ps.search_brace = opt.btype_2; ps.search_brace = opt.btype_2;
break; break;