From owner-svn-src-all@freebsd.org Sat Aug 11 19:20:07 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5114B10773D2; Sat, 11 Aug 2018 19:20:07 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 07B498DA37; Sat, 11 Aug 2018 19:20:07 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C420D1B6CF; Sat, 11 Aug 2018 19:20:06 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7BJK6gi008637; Sat, 11 Aug 2018 19:20:06 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7BJK68P008635; Sat, 11 Aug 2018 19:20:06 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201808111920.w7BJK68P008635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sat, 11 Aug 2018 19:20:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337651 - head/usr.bin/indent X-SVN-Group: head X-SVN-Commit-Author: pstef X-SVN-Commit-Paths: head/usr.bin/indent X-SVN-Commit-Revision: 337651 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Aug 2018 19:20:07 -0000 Author: pstef Date: Sat Aug 11 19:20:06 2018 New Revision: 337651 URL: https://svnweb.freebsd.org/changeset/base/337651 Log: indent(1): revert r334640 and r334632 While STACKSIZE macro is indeed problematic on some systems, the commits were wrong to shrink il[] and cstk[], because they need to be of the same size as p_stack[] as they're accessed with the same index ps.tos. Modified: head/usr.bin/indent/indent_globs.h head/usr.bin/indent/parse.c Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sat Aug 11 17:52:58 2018 (r337650) +++ head/usr.bin/indent/indent_globs.h Sat Aug 11 19:20:06 2018 (r337651) @@ -234,11 +234,13 @@ int inhibit_formatting; /* true if INDENT OFF int suppress_blanklines;/* set iff following blanklines should be * suppressed */ +#define STACKSIZE 256 + struct parser_state { int last_token; - int p_stack[256]; /* this is the parsers stack */ - int il[64]; /* this stack stores indentation levels */ - float cstk[32]; /* used to store case stmt indentation levels */ + int p_stack[STACKSIZE]; /* this is the parsers stack */ + int il[STACKSIZE]; /* this stack stores indentation levels */ + float cstk[STACKSIZE];/* used to store case stmt indentation levels */ int box_com; /* set to true when we are in a "boxed" * comment. In that case, the first non-blank * char should be lined up with the / in / followed by * */ Modified: head/usr.bin/indent/parse.c ============================================================================== --- head/usr.bin/indent/parse.c Sat Aug 11 17:52:58 2018 (r337650) +++ head/usr.bin/indent/parse.c Sat Aug 11 19:20:06 2018 (r337651) @@ -42,12 +42,10 @@ static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/6 #endif #include -#include __FBSDID("$FreeBSD$"); #include #include - #include "indent_globs.h" #include "indent_codes.h" #include "indent.h" @@ -211,7 +209,7 @@ parse(int tk) /* tk: the code for the construct scanne } /* end of switch */ - if (ps.tos >= (int)nitems(ps.p_stack) - 1) + if (ps.tos >= STACKSIZE - 1) errx(1, "Parser stack overflow"); reduce(); /* see if any reduction can be done */