svn commit: r336318 - head/usr.bin/indent

Piotr Pawel Stefaniak pstef at FreeBSD.org
Sun Jul 15 21:04:22 UTC 2018


Author: pstef
Date: Sun Jul 15 21:04:21 2018
New Revision: 336318
URL: https://svnweb.freebsd.org/changeset/base/336318

Log:
  indent(1): move case_indent from parser state to the options struct
  
  This was missed in r334927.

Modified:
  head/usr.bin/indent/args.c
  head/usr.bin/indent/indent_globs.h
  head/usr.bin/indent/parse.c

Modified: head/usr.bin/indent/args.c
==============================================================================
--- head/usr.bin/indent/args.c	Sun Jul 15 20:42:47 2018	(r336317)
+++ head/usr.bin/indent/args.c	Sun Jul 15 21:04:21 2018	(r336318)
@@ -255,7 +255,7 @@ set_defaults(void)
      * Because ps.case_indent is a float, we can't initialize it from the
      * table:
      */
-    ps.case_indent = 0.0;	/* -cli0.0 */
+    opt.case_indent = 0.0;	/* -cli0.0 */
     for (p = pro; p->p_name; p++)
 	if (p->p_type != PRO_SPECIAL)
 	    *p->p_obj = p->p_default;
@@ -284,7 +284,7 @@ found:
 	case CLI:
 	    if (*param_start == 0)
 		goto need_param;
-	    ps.case_indent = atof(param_start);
+	    opt.case_indent = atof(param_start);
 	    break;
 
 	case STDIN:

Modified: head/usr.bin/indent/indent_globs.h
==============================================================================
--- head/usr.bin/indent/indent_globs.h	Sun Jul 15 20:42:47 2018	(r336317)
+++ head/usr.bin/indent/indent_globs.h	Sun Jul 15 21:04:21 2018	(r336318)
@@ -165,6 +165,8 @@ struct options {
     int         cuddle_else;	/* true if else should cuddle up to '}' */
     int         continuation_indent; /* set to the indentation between the
 				 * 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
 				 * of code should start */
     int         decl_indent;	/* column to indent declared identifiers to */
@@ -304,8 +306,6 @@ struct parser_state {
 				 * ignored in some cases.) */
     int         keyword;	/* the type of a keyword or 0 */
     int         dumped_decl_indent;
-    float       case_indent;	/* The distance to indent case labels from the
-				 * switch statement */
     int         in_parameter_declaration;
     int         tos;		/* pointer to top of stack */
     char        procname[100];	/* The name of the current procedure */

Modified: head/usr.bin/indent/parse.c
==============================================================================
--- head/usr.bin/indent/parse.c	Sun Jul 15 20:42:47 2018	(r336317)
+++ head/usr.bin/indent/parse.c	Sun Jul 15 21:04:21 2018	(r336318)
@@ -128,7 +128,7 @@ parse(int tk) /* tk: the code for the construct scanne
 		/*
 		 * 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;
 		/*
 		 * 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 scanne
 	ps.cstk[ps.tos] = case_ind;
 	/* save current case indent level */
 	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
 							 * 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 */
 	ps.search_brace = opt.btype_2;
 	break;


More information about the svn-src-head mailing list