From owner-svn-src-head@freebsd.org Sun Jun 3 02:58:55 2018 Return-Path: Delivered-To: svn-src-head@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 EEF8FFE7D63; Sun, 3 Jun 2018 02:58:54 +0000 (UTC) (envelope-from eadler@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 9E92C693CB; Sun, 3 Jun 2018 02:58:54 +0000 (UTC) (envelope-from eadler@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 66CCD18BDE; Sun, 3 Jun 2018 02:58:54 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w532ws3q070243; Sun, 3 Jun 2018 02:58:54 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w532wrss070240; Sun, 3 Jun 2018 02:58:53 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806030258.w532wrss070240@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 3 Jun 2018 02:58:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334549 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334549 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 02:58:55 -0000 Author: eadler Date: Sun Jun 3 02:58:53 2018 New Revision: 334549 URL: https://svnweb.freebsd.org/changeset/base/334549 Log: top(1): misc minor improvements - use bool instead of int [0] - use calloc correctly [0] (this also caught an incorrect sizeof argument) [1] - use size_t over int [2] - correct style Reported by: pfg [0], scan-build [1], gcc [2] Modified: head/usr.bin/top/commands.c head/usr.bin/top/machine.c head/usr.bin/top/utils.c Modified: head/usr.bin/top/commands.c ============================================================================== --- head/usr.bin/top/commands.c Sun Jun 3 00:42:36 2018 (r334548) +++ head/usr.bin/top/commands.c Sun Jun 3 02:58:53 2018 (r334549) @@ -43,7 +43,7 @@ struct errs /* structure for a system-call error */ static char *err_string(void); static int str_adderr(char *str, int len, int err); -static int str_addarg(char *str, int len, char *arg, int first); +static int str_addarg(char *str, int len, char *arg, bool first); /* * show_help() - display the help screen; invoked in response to @@ -199,9 +199,9 @@ static char err_listem[] = char *err_string(void) { struct errs *errp; - int cnt = 0; - int first = true; - int currerr = -1; + int cnt = 0; + bool first = true; + int currerr = -1; int stringlen; /* characters still available in "string" */ static char string[STRMAX]; @@ -279,7 +279,7 @@ str_adderr(char *str, int len, int err) */ static int -str_addarg(char str[], int len, char arg[], int first) +str_addarg(char str[], int len, char arg[], bool first) { int arglen; Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sun Jun 3 00:42:36 2018 (r334548) +++ head/usr.bin/top/machine.c Sun Jun 3 02:58:53 2018 (r334549) @@ -381,8 +381,7 @@ machine_init(struct statics *statics) cpumask = 0; ncpus = 0; GETSYSCTL("kern.smp.maxcpus", maxcpu); - size = sizeof(long) * maxcpu * CPUSTATES; - times = calloc(size, 1); + times = calloc(maxcpu * CPUSTATES, sizeof(long)); if (times == NULL) err(1, "calloc %zu bytes", size); if (sysctlbyname("kern.cp_times", times, &size, NULL, 0) == -1) @@ -400,11 +399,10 @@ machine_init(struct statics *statics) ncpus++; } } - size = sizeof(long) * ncpus * CPUSTATES; - assert(size > 0); - pcpu_cp_old = calloc(1, size); - pcpu_cp_diff = calloc(1, size); - pcpu_cpu_states = calloc(1, size); + assert(ncpus > 0); + pcpu_cp_old = calloc(ncpus * CPUSTATES, sizeof(long)); + pcpu_cp_diff = calloc(ncpus * CPUSTATES, sizeof(long)); + pcpu_cpu_states = calloc(ncpus * CPUSTATES, sizeof(int)); statics->ncpus = ncpus; update_layout(); Modified: head/usr.bin/top/utils.c ============================================================================== --- head/usr.bin/top/utils.c Sun Jun 3 00:42:36 2018 (r334548) +++ head/usr.bin/top/utils.c Sun Jun 3 02:58:53 2018 (r334549) @@ -29,7 +29,7 @@ int atoiwi(const char *str) { - int len; + size_t len; len = strlen(str); if (len != 0) From owner-svn-src-head@freebsd.org Sun Jun 3 02:42:42 2018 Return-Path: Delivered-To: svn-src-head@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 31259FE6D85 for ; Sun, 3 Jun 2018 02:42:42 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D114768A7C for ; Sun, 3 Jun 2018 02:42:41 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: from mail-yw0-f176.google.com (mail-yw0-f176.google.com [209.85.161.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: eadler) by smtp.freebsd.org (Postfix) with ESMTPSA id A038327157 for ; Sun, 3 Jun 2018 02:42:41 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: by mail-yw0-f176.google.com with SMTP id r19-v6so6165318ywc.10 for ; Sat, 02 Jun 2018 19:42:41 -0700 (PDT) X-Gm-Message-State: ALKqPwe5t9e7c974UpgNk70LmjvbmMc6+M35kn7LaWn7Wnm7UrBVaWGa CDKLnwqgXtaTHqzk0DHiTfYXQypVyN//2k6/SG2kow== X-Google-Smtp-Source: ADUXVKL0qYfXIX5HpvGVvlRryB3EGSDiQKPgqhQAGOoUGMDHxCfPGvJRXVDsTTKW9TURcmj/B2Rg/gFg+WlAJCHEFes= X-Received: by 2002:a81:b70b:: with SMTP id v11-v6mr8248434ywh.182.1527993760847; Sat, 02 Jun 2018 19:42:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:ef50:0:0:0:0:0 with HTTP; Sat, 2 Jun 2018 19:42:10 -0700 (PDT) In-Reply-To: <201806022353.w52Nr1LA088636@pdx.rh.CN85.dnsmgr.net> References: <201806022140.w52LejjF005616@repo.freebsd.org> <201806022353.w52Nr1LA088636@pdx.rh.CN85.dnsmgr.net> From: Eitan Adler Date: Sat, 2 Jun 2018 19:42:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r334540 - head/usr.bin/top To: "Rodney W. Grimes" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 02:42:42 -0000 On 2 June 2018 at 16:53, Rodney W. Grimes wrote: > [ Charset UTF-8 unsupported, converting... ] >> Author: eadler >> Date: Sat Jun 2 21:40:45 2018 >> New Revision: 334540 >> URL: https://svnweb.freebsd.org/changeset/base/334540 >> >> Log: >> top(1): cleanup memory allocation and warnings >> >> - Prefer calloc over malloc. This is more predicable and we're not in a >> performance sensitive context. [1] >> - Remove bogus comment (obsolete from prior commit). [2] >> - Remove void casts and type casts of NULL >> - Remove redundant declaration of 'quit' >> - Add additional const >> >> Reported by: kib [1], vangyzen [2] >> >> Modified: >> head/usr.bin/top/display.c >> head/usr.bin/top/machine.c >> head/usr.bin/top/screen.c >> head/usr.bin/top/screen.h >> head/usr.bin/top/utils.c > ... > >> >> Modified: head/usr.bin/top/screen.c >> ============================================================================== >> --- head/usr.bin/top/screen.c Sat Jun 2 21:16:20 2018 (r334539) >> +++ head/usr.bin/top/screen.c Sat Jun 2 21:40:45 2018 (r334540) >> @@ -3,7 +3,7 @@ >> * Version 3 >> * >> * This program may be freely redistributed, >> - * but this entire comment MUST remain intact. >> + * but this entire ceomment MUST remain intact. > > I know you have already fixed this spelling error, > but I believe there are some other commits that actually > removed either this string, or some part of "this entire" > comment that is to "remain intact". I just went through my commits to top(1) and don't see any others. Did I miss any? Eitan Adler Source, Ports, Doc committer Bugmeister, Ports Security teams From owner-svn-src-head@freebsd.org Sun Jun 3 03:53:12 2018 Return-Path: Delivered-To: svn-src-head@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 740C8FEC392; Sun, 3 Jun 2018 03:53:12 +0000 (UTC) (envelope-from jhibbits@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 275D96BC03; Sun, 3 Jun 2018 03:53:12 +0000 (UTC) (envelope-from jhibbits@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 089161966B; Sun, 3 Jun 2018 03:53:12 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w533rBd7001443; Sun, 3 Jun 2018 03:53:11 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w533rBEX001442; Sun, 3 Jun 2018 03:53:11 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201806030353.w533rBEX001442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sun, 3 Jun 2018 03:53:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334550 - head/sys/cddl/dev/profile X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/cddl/dev/profile X-SVN-Commit-Revision: 334550 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 03:53:12 -0000 Author: jhibbits Date: Sun Jun 3 03:53:11 2018 New Revision: 334550 URL: https://svnweb.freebsd.org/changeset/base/334550 Log: Revert r326083, it doesn't behave as expected. Even though there do appear to be more artificial frames, with 12, stack traces no longer list at all. Revert until a better, more stable value can be determined. Modified: head/sys/cddl/dev/profile/profile.c Modified: head/sys/cddl/dev/profile/profile.c ============================================================================== --- head/sys/cddl/dev/profile/profile.c Sun Jun 3 02:58:53 2018 (r334549) +++ head/sys/cddl/dev/profile/profile.c Sun Jun 3 03:53:11 2018 (r334550) @@ -124,7 +124,7 @@ /* * This value is bogus just to make module compilable on powerpc */ -#define PROF_ARTIFICIAL_FRAMES 12 +#define PROF_ARTIFICIAL_FRAMES 3 #endif struct profile_probe_percpu; From owner-svn-src-head@freebsd.org Sun Jun 3 04:14:49 2018 Return-Path: Delivered-To: svn-src-head@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 DA02AFEECFF; Sun, 3 Jun 2018 04:14:49 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C1C096CC22; Sun, 3 Jun 2018 04:14:48 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w534EkeW089416; Sat, 2 Jun 2018 21:14:46 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w534EksY089415; Sat, 2 Jun 2018 21:14:46 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201806030414.w534EksY089415@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r334540 - head/usr.bin/top In-Reply-To: To: Eitan Adler Date: Sat, 2 Jun 2018 21:14:45 -0700 (PDT) CC: "Rodney W. Grimes" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 04:14:50 -0000 > On 2 June 2018 at 16:53, Rodney W. Grimes > wrote: > > [ Charset UTF-8 unsupported, converting... ] > >> Author: eadler > >> Date: Sat Jun 2 21:40:45 2018 > >> New Revision: 334540 > >> URL: https://svnweb.freebsd.org/changeset/base/334540 > >> > >> Log: > >> top(1): cleanup memory allocation and warnings > >> > >> - Prefer calloc over malloc. This is more predicable and we're not in a > >> performance sensitive context. [1] > >> - Remove bogus comment (obsolete from prior commit). [2] > >> - Remove void casts and type casts of NULL > >> - Remove redundant declaration of 'quit' > >> - Add additional const > >> > >> Reported by: kib [1], vangyzen [2] > >> > >> Modified: > >> head/usr.bin/top/display.c > >> head/usr.bin/top/machine.c > >> head/usr.bin/top/screen.c > >> head/usr.bin/top/screen.h > >> head/usr.bin/top/utils.c > > ... > > > >> > >> Modified: head/usr.bin/top/screen.c > >> ============================================================================== > >> --- head/usr.bin/top/screen.c Sat Jun 2 21:16:20 2018 (r334539) > >> +++ head/usr.bin/top/screen.c Sat Jun 2 21:40:45 2018 (r334540) > >> @@ -3,7 +3,7 @@ > >> * Version 3 > >> * > >> * This program may be freely redistributed, > >> - * but this entire comment MUST remain intact. > >> + * but this entire ceomment MUST remain intact. > > > > I know you have already fixed this spelling error, > > but I believe there are some other commits that actually > > removed either this string, or some part of "this entire" > > comment that is to "remain intact". > > I just went through my commits to top(1) and don't see any others. Did > I miss any? Index: commands.c =================================================================== --- commands.c (revision 333898) +++ commands.c (working copy) @@ -1,6 +1,5 @@ /* * Top users/processes display for Unix - * Version 3 * * This program may be freely redistributed, * but this entire comment MUST remain intact. Found with a cd usr.bin/top; svn diff -r 333898 which is when you moved it to usr.bin. Further investigation shows that this line was deleted at r333909. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-head@freebsd.org Sun Jun 3 05:01:51 2018 Return-Path: Delivered-To: svn-src-head@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 222E0FF3B6C for ; Sun, 3 Jun 2018 05:01:51 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C35356ED00 for ; Sun, 3 Jun 2018 05:01:50 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: from mail-yw0-f170.google.com (mail-yw0-f170.google.com [209.85.161.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: eadler) by smtp.freebsd.org (Postfix) with ESMTPSA id 8C4F327E56 for ; Sun, 3 Jun 2018 05:01:50 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: by mail-yw0-f170.google.com with SMTP id u124-v6so8388719ywg.0 for ; Sat, 02 Jun 2018 22:01:50 -0700 (PDT) X-Gm-Message-State: APt69E2U1pFGjNZdqH1ej9/ajxmjEeBgn5xc7ozYT1rzsVm5VvS+mRfc 7Is13VnM3Q3SY1d7kwrCWNj61jmgxSqiScy/aezcSg== X-Google-Smtp-Source: ADUXVKKiPCNA4hxl1PwMajl+zWH+PeW4+txwLdurxPMjbuzPxDOPnbfli0QzfpIfQWgzXtpKtRP2gIYRvTC98CiqD8s= X-Received: by 2002:a0d:cf01:: with SMTP id r1-v6mr2998369ywd.162.1528002110052; Sat, 02 Jun 2018 22:01:50 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:ef50:0:0:0:0:0 with HTTP; Sat, 2 Jun 2018 22:01:19 -0700 (PDT) In-Reply-To: <201806030414.w534EksY089415@pdx.rh.CN85.dnsmgr.net> References: <201806030414.w534EksY089415@pdx.rh.CN85.dnsmgr.net> From: Eitan Adler Date: Sat, 2 Jun 2018 22:01:19 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r334540 - head/usr.bin/top To: "Rodney W. Grimes" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 05:01:51 -0000 On 2 June 2018 at 21:14, Rodney W. Grimes wrote: >> On 2 June 2018 at 16:53, Rodney W. Grimes >> wrote: >> > [ Charset UTF-8 unsupported, converting... ] >> >> Author: eadler >> >> Date: Sat Jun 2 21:40:45 2018 >> >> New Revision: 334540 >> >> URL: https://svnweb.freebsd.org/changeset/base/334540 >> >> >> >> Log: >> >> top(1): cleanup memory allocation and warnings >> >> >> >> - Prefer calloc over malloc. This is more predicable and we're not in a >> >> performance sensitive context. [1] >> >> - Remove bogus comment (obsolete from prior commit). [2] >> >> - Remove void casts and type casts of NULL >> >> - Remove redundant declaration of 'quit' >> >> - Add additional const >> >> >> >> Reported by: kib [1], vangyzen [2] >> >> >> >> Modified: >> >> head/usr.bin/top/display.c >> >> head/usr.bin/top/machine.c >> >> head/usr.bin/top/screen.c >> >> head/usr.bin/top/screen.h >> >> head/usr.bin/top/utils.c >> > ... >> > >> >> >> >> Modified: head/usr.bin/top/screen.c >> >> ============================================================================== >> >> --- head/usr.bin/top/screen.c Sat Jun 2 21:16:20 2018 (r334539) >> >> +++ head/usr.bin/top/screen.c Sat Jun 2 21:40:45 2018 (r334540) >> >> @@ -3,7 +3,7 @@ >> >> * Version 3 >> >> * >> >> * This program may be freely redistributed, >> >> - * but this entire comment MUST remain intact. >> >> + * but this entire ceomment MUST remain intact. >> > >> > I know you have already fixed this spelling error, >> > but I believe there are some other commits that actually >> > removed either this string, or some part of "this entire" >> > comment that is to "remain intact". >> >> I just went through my commits to top(1) and don't see any others. Did >> I miss any? > > Index: commands.c > =================================================================== > --- commands.c (revision 333898) > +++ commands.c (working copy) > @@ -1,6 +1,5 @@ > /* > * Top users/processes display for Unix > - * Version 3 > * > * This program may be freely redistributed, > * but this entire comment MUST remain intact. > > Found with a cd usr.bin/top; svn diff -r 333898 which is > when you moved it to usr.bin. Further investigation > shows that this line was deleted at r333909. I removed the version line, not the license line. Do you believe "entire comment" includes the version information? -- Eitan Adler Source, Ports, Doc committer Bugmeister, Ports Security teams From owner-svn-src-head@freebsd.org Sun Jun 3 05:07:40 2018 Return-Path: Delivered-To: svn-src-head@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 5CFF6FF452C; Sun, 3 Jun 2018 05:07:40 +0000 (UTC) (envelope-from eadler@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 0D19C6F0A7; Sun, 3 Jun 2018 05:07:40 +0000 (UTC) (envelope-from eadler@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 E3A341A1D4; Sun, 3 Jun 2018 05:07:39 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5357djc036536; Sun, 3 Jun 2018 05:07:39 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5357dA1036534; Sun, 3 Jun 2018 05:07:39 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806030507.w5357dA1036534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 3 Jun 2018 05:07:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334551 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334551 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 05:07:40 -0000 Author: eadler Date: Sun Jun 3 05:07:39 2018 New Revision: 334551 URL: https://svnweb.freebsd.org/changeset/base/334551 Log: top(1): use greater warnings One of the downsides of using numeric WARNS is that if we only have a single type of issue we get no protection from other changes. For example, we got no warning for missing variable declaration, due to the issues with "const". For this utility, explicitly list out the warnings which are failing. They should still be fixed, so only reduce them to warning instead of error. Tested with: clang base (amd64, i386), gcc6, gcc7, gcc9, gcc base (mips) Modified: head/usr.bin/top/Makefile head/usr.bin/top/machine.c Modified: head/usr.bin/top/Makefile ============================================================================== --- head/usr.bin/top/Makefile Sun Jun 3 03:53:11 2018 (r334550) +++ head/usr.bin/top/Makefile Sun Jun 3 05:07:39 2018 (r334551) @@ -1,12 +1,22 @@ # $FreeBSD$ +.include + PROG= top SRCS= commands.c display.c machine.c screen.c top.c \ username.c utils.c sigdesc.h CFLAGS+= -I ${.OBJDIR} MAN= top.1 -WARNS?= 3 +WARNS?= 6 + +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50000 +CFLAGS.gcc=-Wno-error=cast-align -Wno-error=cast-qual -Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types \ + -Wno-error=maybe-uninitialized +.else #base gcc +NO_WERROR= +.endif +CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers -Wno-error=cast-qual -Wno-error=cast-align LIBADD= ncursesw m kvm jail Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sun Jun 3 03:53:11 2018 (r334550) +++ head/usr.bin/top/machine.c Sun Jun 3 05:07:39 2018 (r334551) @@ -229,7 +229,7 @@ static int pageshift; /* log base 2 of the pagesize * /* * Sorting orders. The first element is the default. */ -char *ordernames[] = { +static const char *ordernames[] = { "cpu", "size", "res", "time", "pri", "threads", "total", "read", "write", "fault", "vcsw", "ivcsw", "jid", "swap", "pid", NULL From owner-svn-src-head@freebsd.org Sun Jun 3 05:07:48 2018 Return-Path: Delivered-To: svn-src-head@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 A30D2FF45A1; Sun, 3 Jun 2018 05:07:48 +0000 (UTC) (envelope-from eadler@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 7DDD36F168; Sun, 3 Jun 2018 05:07:47 +0000 (UTC) (envelope-from eadler@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 4A48C1A1D5; Sun, 3 Jun 2018 05:07:47 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5357ke2036584; Sun, 3 Jun 2018 05:07:46 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5357kMm036583; Sun, 3 Jun 2018 05:07:46 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806030507.w5357kMm036583@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 3 Jun 2018 05:07:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334552 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334552 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 05:07:48 -0000 Author: eadler Date: Sun Jun 3 05:07:46 2018 New Revision: 334552 URL: https://svnweb.freebsd.org/changeset/base/334552 Log: top(1): remove chdir to / While this came out of a conversation in IRC, it turn out that some people don't like it. Since this was a courtesy feature, just remove it. Modified: head/usr.bin/top/top.c Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Sun Jun 3 05:07:39 2018 (r334551) +++ head/usr.bin/top/top.c Sun Jun 3 05:07:46 2018 (r334552) @@ -260,15 +260,6 @@ main(int argc, char *argv[]) #define CMD_order 26 #define CMD_pid 27 - /* - * Since top(1) is often long running and - * doesn't typically care about where its running from - * chdir to the root to allow unmounting of its - * original wd. Failure is alright as this is - * just a courtesy for users. - */ - chdir("/"); - /* set the buffer for stdout */ #ifdef DEBUG extern FILE *debug; From owner-svn-src-head@freebsd.org Sun Jun 3 05:08:45 2018 Return-Path: Delivered-To: svn-src-head@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 7B957FF478D for ; Sun, 3 Jun 2018 05:08:45 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2409C6F339 for ; Sun, 3 Jun 2018 05:08:45 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: from mail-yb0-f170.google.com (mail-yb0-f170.google.com [209.85.213.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: eadler) by smtp.freebsd.org (Postfix) with ESMTPSA id E337527F68 for ; Sun, 3 Jun 2018 05:08:44 +0000 (UTC) (envelope-from eadler@freebsd.org) Received: by mail-yb0-f170.google.com with SMTP id v17-v6so752404ybe.7 for ; Sat, 02 Jun 2018 22:08:44 -0700 (PDT) X-Gm-Message-State: APt69E10wtdYacFqounUIa5v4BJNdyHORYvzwpREXkGA4hmN+PTVT5W0 Uy3gGn+s8jVVlV5UaSLmdWVSNEHOSxsDbD1OymW9Kg== X-Google-Smtp-Source: ADUXVKLDdXmY9SOq50CtxxE+nnk0QbREk2V0LWceBILmv9Pu/dGY30s8+A93PPDQFHO/V0qUx5QRf+cv6XsJcAvp+gI= X-Received: by 2002:a5b:64c:: with SMTP id o12-v6mr5873213ybq.460.1528002524399; Sat, 02 Jun 2018 22:08:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:ef50:0:0:0:0:0 with HTTP; Sat, 2 Jun 2018 22:08:13 -0700 (PDT) In-Reply-To: <201806022356.w52NuiFK088665@pdx.rh.CN85.dnsmgr.net> References: <201806022206.w52M6S98020830@repo.freebsd.org> <201806022356.w52NuiFK088665@pdx.rh.CN85.dnsmgr.net> From: Eitan Adler Date: Sat, 2 Jun 2018 22:08:13 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r334543 - head/usr.bin/top To: "Rodney W. Grimes" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 05:08:45 -0000 On 2 June 2018 at 16:56, Rodney W. Grimes wrote: >> Author: eadler >> Date: Sat Jun 2 22:06:27 2018 >> New Revision: 334543 >> URL: https://svnweb.freebsd.org/changeset/base/334543 >> >> Log: >> top(1): chdir to / as init; remove unneeded comment >> >> - chdir to / to allow unmounting of wd >> - remove warning about running top(1) as setuid. If this is a concern we >> should just drop privs instead. >> >> Modified: >> head/usr.bin/top/machine.c >> head/usr.bin/top/top.c >> >> Modified: head/usr.bin/top/machine.c >> ============================================================================== >> --- head/usr.bin/top/machine.c Sat Jun 2 21:50:00 2018 (r334542) >> +++ head/usr.bin/top/machine.c Sat Jun 2 22:06:27 2018 (r334543) >> @@ -1613,11 +1613,6 @@ compare_ivcsw(const void *arg1, const void *arg2) >> /* >> * proc_owner(pid) - returns the uid that owns process "pid", or -1 if >> * the process does not exist. >> - * It is EXTREMELY IMPORTANT that this function work correctly. >> - * If top runs setuid root (as in SVR4), then this function >> - * is the only thing that stands in the way of a serious >> - * security problem. It validates requests for the "kill" >> - * and "renice" commands. >> */ >> >> int >> >> Modified: head/usr.bin/top/top.c >> ============================================================================== >> --- head/usr.bin/top/top.c Sat Jun 2 21:50:00 2018 (r334542) >> +++ head/usr.bin/top/top.c Sat Jun 2 22:06:27 2018 (r334543) >> @@ -260,6 +260,15 @@ main(int argc, char *argv[]) >> #define CMD_order 26 >> #define CMD_pid 27 >> >> + /* >> + * Since top(1) is often long running and >> + * doesn't typically care about where its running from >> + * chdir to the root to allow unmounting of its >> + * originall wd. Failure is alright as this is >> + * just a courtesy for users. >> + */ >> + chdir("/"); >> + > > Bad side effect of doing that is it is not hard to get a "core" > from top when run as a user, as it is going to try to write > to /, and it probably does not have permission for that. Another person made the point that other similar applications don't do this, so I just reverted it. thanks! -- Eitan Adler Source, Ports, Doc committer Bugmeister, Ports Security teams From owner-svn-src-head@freebsd.org Sun Jun 3 05:20:13 2018 Return-Path: Delivered-To: svn-src-head@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 AE7B7FF5858; Sun, 3 Jun 2018 05:20:13 +0000 (UTC) (envelope-from eadler@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 5F9CC6FB62; Sun, 3 Jun 2018 05:20:13 +0000 (UTC) (envelope-from eadler@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 240A91A382; Sun, 3 Jun 2018 05:20:13 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w535KCSF041724; Sun, 3 Jun 2018 05:20:12 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w535KB8c041717; Sun, 3 Jun 2018 05:20:11 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806030520.w535KB8c041717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 3 Jun 2018 05:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334553 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334553 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 05:20:14 -0000 Author: eadler Date: Sun Jun 3 05:20:11 2018 New Revision: 334553 URL: https://svnweb.freebsd.org/changeset/base/334553 Log: top(1): partial revert of r334517 In fixing issues with uid > INT_MAX, I broke the uid without username case. The latter is more important so return the old state. Discussed with: allanjude Modified: head/usr.bin/top/machine.c head/usr.bin/top/machine.h head/usr.bin/top/top.c head/usr.bin/top/username.c head/usr.bin/top/username.h head/usr.bin/top/utils.c head/usr.bin/top/utils.h Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sun Jun 3 05:07:46 2018 (r334552) +++ head/usr.bin/top/machine.c Sun Jun 3 05:20:11 2018 (r334553) @@ -918,7 +918,7 @@ get_process_info(struct system_info *si, struct proces static char fmt[512]; /* static area where result is built */ char * -format_next_process(caddr_t xhandle, char *(*get_userid)(uid_t), int flags) +format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags) { struct kinfo_proc *pp; const struct kinfo_proc *oldp; Modified: head/usr.bin/top/machine.h ============================================================================== --- head/usr.bin/top/machine.h Sun Jun 3 05:07:46 2018 (r334552) +++ head/usr.bin/top/machine.h Sun Jun 3 05:20:11 2018 (r334553) @@ -76,7 +76,7 @@ struct process_select /* routines defined by the machine dependent module */ char *format_header(char *uname_field); -char *format_next_process(caddr_t handle, char *(*get_userid)(uid_t), +char *format_next_process(caddr_t handle, char *(*get_userid)(int), int flags); void toggle_pcpustats(void); void get_system_info(struct system_info *si); Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Sun Jun 3 05:07:46 2018 (r334552) +++ head/usr.bin/top/top.c Sun Jun 3 05:20:11 2018 (r334553) @@ -206,7 +206,7 @@ main(int argc, char *argv[]) int displays = 0; /* indicates unspecified */ int sel_ret = 0; time_t curr_time; - char *(*get_userid)(uid_t) = username; + char *(*get_userid)(int) = username; char *uname_field = "USERNAME"; char *header_text; char *env_top; Modified: head/usr.bin/top/username.c ============================================================================== --- head/usr.bin/top/username.c Sun Jun 3 05:07:46 2018 (r334552) +++ head/usr.bin/top/username.c Sun Jun 3 05:20:11 2018 (r334553) @@ -37,27 +37,26 @@ #include #include #include -#include #include "utils.h" #include "username.h" struct hash_el { - uid_t uid; + int uid; char name[MAXLOGNAME]; }; #define is_empty_hash(x) (hash_table[x].name[0] == 0) /* simple minded hashing function */ -#define hashit(i) (i % Table_size) +#define hashit(i) (abs(i) % Table_size) /* K&R requires that statically declared tables be initialized to zero. */ /* We depend on that for hash_table and YOUR compiler had BETTER do it! */ static struct hash_el hash_table[Table_size]; -char *username(uid_t uid) +char *username(int uid) { int hashindex; @@ -70,7 +69,7 @@ char *username(uid_t uid) return(hash_table[hashindex].name); } -uid_t userid(char username[]) +int userid(char username[]) { struct passwd *pwd; @@ -91,7 +90,7 @@ uid_t userid(char username[]) } /* wecare 1 = enter it always, 0 = nice to have */ -int enter_user(uid_t uid, char name[], bool wecare) +int enter_user(int uid, char name[], bool wecare) { int hashindex; @@ -122,7 +121,7 @@ int enter_user(uid_t uid, char name[], bool wecare) */ int -get_user(uid_t uid) +get_user(int uid) { struct passwd *pwd; Modified: head/usr.bin/top/username.h ============================================================================== --- head/usr.bin/top/username.h Sun Jun 3 05:07:46 2018 (r334552) +++ head/usr.bin/top/username.h Sun Jun 3 05:20:11 2018 (r334553) @@ -12,13 +12,12 @@ #define USERNAME_H #include -#include -int enter_user(uid_t uid, char *name, bool wecare); -int get_user(uid_t uid); +int enter_user(int uid, char *name, bool wecare); +int get_user(int uid); void init_hash(void); -char *username(uid_t uid); -uid_t userid(char *username); +char *username(int uid); +int userid(char *username); /* * "Table_size" defines the size of the hash tables used to map uid to Modified: head/usr.bin/top/utils.c ============================================================================== --- head/usr.bin/top/utils.c Sun Jun 3 05:07:46 2018 (r334552) +++ head/usr.bin/top/utils.c Sun Jun 3 05:20:11 2018 (r334553) @@ -89,12 +89,12 @@ char *itoa(unsigned int val) } /* - * itoa7(val) - like itoa, except the number is right justified in a 7 + * (val) - like itoa, except the number is right justified in a 7 * character field. This code is a duplication of itoa instead of * a front end to a more general routine for efficiency. */ -char *itoa7(unsigned int val) +char *itoa7(int val) { char *ptr; static char buffer[16]; /* result is built here */ Modified: head/usr.bin/top/utils.h ============================================================================== --- head/usr.bin/top/utils.h Sun Jun 3 05:07:46 2018 (r334552) +++ head/usr.bin/top/utils.h Sun Jun 3 05:20:11 2018 (r334553) @@ -14,7 +14,7 @@ int atoiwi(const char *); char *itoa(unsigned int); -char *itoa7(unsigned int); +char *itoa7(int); int digits(int); char **argparse(char *, int *); long percentages(int, int *, long *, long *, long *); From owner-svn-src-head@freebsd.org Sun Jun 3 06:02:32 2018 Return-Path: Delivered-To: svn-src-head@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 4A3F3EFA4A8; Sun, 3 Jun 2018 06:02:32 +0000 (UTC) (envelope-from eadler@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 F0E9C71991; Sun, 3 Jun 2018 06:02:31 +0000 (UTC) (envelope-from eadler@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 D1EA81AB8A; Sun, 3 Jun 2018 06:02:31 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5362VdQ066717; Sun, 3 Jun 2018 06:02:31 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5362VuJ066716; Sun, 3 Jun 2018 06:02:31 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806030602.w5362VuJ066716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 3 Jun 2018 06:02:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334554 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334554 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 06:02:32 -0000 Author: eadler Date: Sun Jun 3 06:02:31 2018 New Revision: 334554 URL: https://svnweb.freebsd.org/changeset/base/334554 Log: top(1): Only use NO_WERROR for base gcc This is what was intended. If statements are hard. Modified: head/usr.bin/top/Makefile Modified: head/usr.bin/top/Makefile ============================================================================== --- head/usr.bin/top/Makefile Sun Jun 3 05:20:11 2018 (r334553) +++ head/usr.bin/top/Makefile Sun Jun 3 06:02:31 2018 (r334554) @@ -10,11 +10,13 @@ MAN= top.1 WARNS?= 6 -.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50000 +.if ${COMPILER_TYPE} == "gcc" +.if ${COMPILER_VERSION} >= 50000 CFLAGS.gcc=-Wno-error=cast-align -Wno-error=cast-qual -Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types \ -Wno-error=maybe-uninitialized .else #base gcc NO_WERROR= +.endif .endif CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers -Wno-error=cast-qual -Wno-error=cast-align From owner-svn-src-head@freebsd.org Sun Jun 3 06:51:16 2018 Return-Path: Delivered-To: svn-src-head@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 A0ACDEFF9C8; Sun, 3 Jun 2018 06:51:16 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D703473CB6; Sun, 3 Jun 2018 06:51:15 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w536pCoC089862; Sat, 2 Jun 2018 23:51:12 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w536pCYd089861; Sat, 2 Jun 2018 23:51:12 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201806030651.w536pCYd089861@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r334540 - head/usr.bin/top In-Reply-To: To: Eitan Adler Date: Sat, 2 Jun 2018 23:51:12 -0700 (PDT) CC: "Rodney W. Grimes" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 06:51:16 -0000 [ Charset UTF-8 unsupported, converting... ] > On 2 June 2018 at 21:14, Rodney W. Grimes > wrote: > >> On 2 June 2018 at 16:53, Rodney W. Grimes > >> wrote: > >> > [ Charset UTF-8 unsupported, converting... ] > >> >> Author: eadler > >> >> Date: Sat Jun 2 21:40:45 2018 > >> >> New Revision: 334540 > >> >> URL: https://svnweb.freebsd.org/changeset/base/334540 > >> >> > >> >> Log: > >> >> top(1): cleanup memory allocation and warnings > >> >> > >> >> - Prefer calloc over malloc. This is more predicable and we're not in a > >> >> performance sensitive context. [1] > >> >> - Remove bogus comment (obsolete from prior commit). [2] > >> >> - Remove void casts and type casts of NULL > >> >> - Remove redundant declaration of 'quit' > >> >> - Add additional const > >> >> > >> >> Reported by: kib [1], vangyzen [2] > >> >> > >> >> Modified: > >> >> head/usr.bin/top/display.c > >> >> head/usr.bin/top/machine.c > >> >> head/usr.bin/top/screen.c > >> >> head/usr.bin/top/screen.h > >> >> head/usr.bin/top/utils.c > >> > ... > >> > > >> >> > >> >> Modified: head/usr.bin/top/screen.c > >> >> ============================================================================== > >> >> --- head/usr.bin/top/screen.c Sat Jun 2 21:16:20 2018 (r334539) > >> >> +++ head/usr.bin/top/screen.c Sat Jun 2 21:40:45 2018 (r334540) > >> >> @@ -3,7 +3,7 @@ > >> >> * Version 3 > >> >> * > >> >> * This program may be freely redistributed, > >> >> - * but this entire comment MUST remain intact. > >> >> + * but this entire ceomment MUST remain intact. > >> > > >> > I know you have already fixed this spelling error, > >> > but I believe there are some other commits that actually > >> > removed either this string, or some part of "this entire" > >> > comment that is to "remain intact". > >> > >> I just went through my commits to top(1) and don't see any others. Did > >> I miss any? > > > > Index: commands.c > > =================================================================== > > --- commands.c (revision 333898) > > +++ commands.c (working copy) > > @@ -1,6 +1,5 @@ > > /* > > * Top users/processes display for Unix > > - * Version 3 > > * > > * This program may be freely redistributed, > > * but this entire comment MUST remain intact. > > > > Found with a cd usr.bin/top; svn diff -r 333898 which is > > when you moved it to usr.bin. Further investigation > > shows that this line was deleted at r333909. > > I removed the version line, not the license line. Do you believe > "entire comment" includes the version information? I would interpret entire to be anything between /* and */. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-head@freebsd.org Sun Jun 3 10:04:50 2018 Return-Path: Delivered-To: svn-src-head@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 2CB6CFDF1D2; Sun, 3 Jun 2018 10:04:50 +0000 (UTC) (envelope-from Michael.Tuexen@macmic.franken.de) Received: from drew.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.franken.de", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A880E7C50D; Sun, 3 Jun 2018 10:04:49 +0000 (UTC) (envelope-from Michael.Tuexen@macmic.franken.de) Received: from [10.54.165.156] (unknown [88.128.80.153]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTPSA id 6234C72106C13; Sun, 3 Jun 2018 12:04:46 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.4 \(3445.8.2\)) Subject: Re: svn commit: r334554 - head/usr.bin/top From: Michael Tuexen In-Reply-To: <201806030602.w5362VuJ066716@repo.freebsd.org> Date: Sun, 3 Jun 2018 12:04:45 +0200 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <780B5AE9-CB7E-4668-9BF2-4E6FC62DD2E3@macmic.franken.de> References: <201806030602.w5362VuJ066716@repo.freebsd.org> To: Eitan Adler X-Mailer: Apple Mail (2.3445.8.2) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail-n.franken.de X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 10:04:50 -0000 top doesn't work on a amd64 (64 logical cores) and on an arm64 (8 cores) system anymore (world and kernel are in sync): tuexen@epyc:~ % uname -a FreeBSD epyc.nplab.de 12.0-CURRENT FreeBSD 12.0-CURRENT #5 r334554: Sun = Jun 3 11:26:58 CEST 2018 = root@epyc.nplab.de:/usr/obj/usr/home/tuexen/head/amd64.amd64/sys/GENERIC = amd64 tuexen@epyc:~ % top top: sysctlbyname kern.cp_times: Cannot allocate memory FreeBSD bsd14.fh-muenster.de 12.0-CURRENT FreeBSD 12.0-CURRENT #16 = r334554: Sun Jun 3 11:47:38 CEST 2018 = root@bsd14.fh-muenster.de:/usr/obj/usr/home/tuexen/head/arm64.aarch64/sys/= GENERIC arm64 tuexen@bsd14:~ % top top: sysctlbyname kern.cp_times: Cannot allocate memory Best regards Michael > On 3. Jun 2018, at 08:02, Eitan Adler wrote: >=20 > Author: eadler > Date: Sun Jun 3 06:02:31 2018 > New Revision: 334554 > URL: https://svnweb.freebsd.org/changeset/base/334554 >=20 > Log: > top(1): Only use NO_WERROR for base gcc >=20 > This is what was intended. If statements are hard. >=20 > Modified: > head/usr.bin/top/Makefile >=20 > Modified: head/usr.bin/top/Makefile > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/usr.bin/top/Makefile Sun Jun 3 05:20:11 2018 = (r334553) > +++ head/usr.bin/top/Makefile Sun Jun 3 06:02:31 2018 = (r334554) > @@ -10,11 +10,13 @@ MAN=3D top.1 >=20 > WARNS?=3D 6 >=20 > -.if ${COMPILER_TYPE} =3D=3D "gcc" && ${COMPILER_VERSION} >=3D 50000 > +.if ${COMPILER_TYPE} =3D=3D "gcc" > +.if ${COMPILER_VERSION} >=3D 50000 > CFLAGS.gcc=3D-Wno-error=3Dcast-align -Wno-error=3Dcast-qual = -Wno-error=3Ddiscarded-qualifiers -Wno-error=3Dincompatible-pointer-types = \ > -Wno-error=3Dmaybe-uninitialized > .else #base gcc > NO_WERROR=3D > +.endif > .endif > CFLAGS.clang=3D-Wno-error=3Dincompatible-pointer-types-discards-qualifie= rs -Wno-error=3Dcast-qual -Wno-error=3Dcast-align >=20 >=20 From owner-svn-src-head@freebsd.org Sun Jun 3 10:53:11 2018 Return-Path: Delivered-To: svn-src-head@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 39DDFEF7FB8; Sun, 3 Jun 2018 10:53:11 +0000 (UTC) (envelope-from wulf@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 E38007E765; Sun, 3 Jun 2018 10:53:10 +0000 (UTC) (envelope-from wulf@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 C49621DAC6; Sun, 3 Jun 2018 10:53:10 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w53ArAFY015446; Sun, 3 Jun 2018 10:53:10 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53ArALl015445; Sun, 3 Jun 2018 10:53:10 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201806031053.w53ArALl015445@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sun, 3 Jun 2018 10:53:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334555 - head/sys/dev/evdev X-SVN-Group: head X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: head/sys/dev/evdev X-SVN-Commit-Revision: 334555 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 10:53:11 -0000 Author: wulf Date: Sun Jun 3 10:53:10 2018 New Revision: 334555 URL: https://svnweb.freebsd.org/changeset/base/334555 Log: [evdev] Sync event codes with Linux kernel 4.16 MFC after: 2 weeks Modified: head/sys/dev/evdev/input-event-codes.h head/sys/dev/evdev/input.h Modified: head/sys/dev/evdev/input-event-codes.h ============================================================================== --- head/sys/dev/evdev/input-event-codes.h Sun Jun 3 06:02:31 2018 (r334554) +++ head/sys/dev/evdev/input-event-codes.h Sun Jun 3 10:53:10 2018 (r334555) @@ -421,6 +421,7 @@ #define BTN_TOOL_MOUSE 0x146 #define BTN_TOOL_LENS 0x147 #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ +#define BTN_STYLUS3 0x149 #define BTN_TOUCH 0x14a #define BTN_STYLUS 0x14b #define BTN_STYLUS2 0x14c @@ -607,6 +608,7 @@ #define BTN_DPAD_RIGHT 0x223 #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ +#define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ #define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ #define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ @@ -615,6 +617,7 @@ #define KEY_APPSELECT 0x244 /* AL Select Task/Application */ #define KEY_SCREENSAVER 0x245 /* AL Screen Saver */ #define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ +#define KEY_ASSISTANT 0x247 /* AL Context-aware desktop assistant */ #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ @@ -626,6 +629,38 @@ #define KEY_KBDINPUTASSIST_ACCEPT 0x264 #define KEY_KBDINPUTASSIST_CANCEL 0x265 +/* Diagonal movement keys */ +#define KEY_RIGHT_UP 0x266 +#define KEY_RIGHT_DOWN 0x267 +#define KEY_LEFT_UP 0x268 +#define KEY_LEFT_DOWN 0x269 + +#define KEY_ROOT_MENU 0x26a /* Show Device's Root Menu */ +/* Show Top Menu of the Media (e.g. DVD) */ +#define KEY_MEDIA_TOP_MENU 0x26b +#define KEY_NUMERIC_11 0x26c +#define KEY_NUMERIC_12 0x26d +/* + * Toggle Audio Description: refers to an audio service that helps blind and + * visually impaired consumers understand the action in a program. Note: in + * some countries this is referred to as "Video Description". + */ +#define KEY_AUDIO_DESC 0x26e +#define KEY_3D_MODE 0x26f +#define KEY_NEXT_FAVORITE 0x270 +#define KEY_STOP_RECORD 0x271 +#define KEY_PAUSE_RECORD 0x272 +#define KEY_VOD 0x273 /* Video on Demand */ +#define KEY_UNMUTE 0x274 +#define KEY_FASTREVERSE 0x275 +#define KEY_SLOWREVERSE 0x276 +/* + * Control a data application associated with the currently viewed channel, + * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.) + */ +#define KEY_DATA 0x277 +#define KEY_ONSCREEN_KEYBOARD 0x278 + #define BTN_TRIGGER_HAPPY 0x2c0 #define BTN_TRIGGER_HAPPY1 0x2c0 #define BTN_TRIGGER_HAPPY2 0x2c1 @@ -763,6 +798,7 @@ #define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */ #define SW_LINEIN_INSERT 0x0d /* set = inserted */ #define SW_MUTE_DEVICE 0x0e /* set = device disabled */ +#define SW_PEN_INSERTED 0x0f /* set = pen inserted */ #define SW_MAX 0x0f #define SW_CNT (SW_MAX+1) Modified: head/sys/dev/evdev/input.h ============================================================================== --- head/sys/dev/evdev/input.h Sun Jun 3 06:02:31 2018 (r334554) +++ head/sys/dev/evdev/input.h Sun Jun 3 10:53:10 2018 (r334555) @@ -38,6 +38,9 @@ #include "input-event-codes.h" +#define input_event_sec time.tv_sec +#define input_event_usec time.tv_usec + struct input_event { struct timeval time; uint16_t type; @@ -138,6 +141,9 @@ struct input_keymap_entry { #define BUS_GSC 0x1A #define BUS_ATARI 0x1B #define BUS_SPI 0x1C +#define BUS_RMI 0x1D +#define BUS_CEC 0x1E +#define BUS_INTEL_ISHTP 0x1F /* * MT_TOOL types From owner-svn-src-head@freebsd.org Sun Jun 3 13:41:00 2018 Return-Path: Delivered-To: svn-src-head@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 73EE4F7F557; Sun, 3 Jun 2018 13:41:00 +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 255AD85CE0; Sun, 3 Jun 2018 13:41:00 +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 E191F1F4E2; Sun, 3 Jun 2018 13:40:59 +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 w53DexTk000757; Sun, 3 Jun 2018 13:40:59 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53DexRQ000755; Sun, 3 Jun 2018 13:40:59 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031340.w53DexRQ000755@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 13:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334556 - 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: 334556 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 13:41:00 -0000 Author: pstef Date: Sun Jun 3 13:40:58 2018 New Revision: 334556 URL: https://svnweb.freebsd.org/changeset/base/334556 Log: indent(1): remove undocumented and rather useless option (-ps) It's used to treat the "->" access operator as a binary operator and put space characters around it. Modified: head/usr.bin/indent/args.c head/usr.bin/indent/indent_globs.h head/usr.bin/indent/lexi.c Modified: head/usr.bin/indent/args.c ============================================================================== --- head/usr.bin/indent/args.c Sun Jun 3 10:53:10 2018 (r334555) +++ head/usr.bin/indent/args.c Sun Jun 3 13:40:58 2018 (r334556) @@ -154,7 +154,6 @@ struct pro { {"npcs", PRO_BOOL, false, OFF, &proc_calls_space}, {"npro", PRO_SPECIAL, 0, IGN, 0}, {"npsl", PRO_BOOL, true, OFF, &procnames_start_line}, - {"nps", PRO_BOOL, false, OFF, &pointer_as_binop}, {"nsac", PRO_BOOL, false, OFF, &space_after_cast}, {"nsc", PRO_BOOL, true, OFF, &star_comment_cont}, {"nsob", PRO_BOOL, false, OFF, &swallow_optional_blanklines}, @@ -162,7 +161,6 @@ struct pro { {"nv", PRO_BOOL, false, OFF, &verbose}, {"pcs", PRO_BOOL, false, ON, &proc_calls_space}, {"psl", PRO_BOOL, true, ON, &procnames_start_line}, - {"ps", PRO_BOOL, false, ON, &pointer_as_binop}, {"sac", PRO_BOOL, false, ON, &space_after_cast}, {"sc", PRO_BOOL, true, ON, &star_comment_cont}, {"sob", PRO_BOOL, false, ON, &swallow_optional_blanklines}, Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jun 3 10:53:10 2018 (r334555) +++ head/usr.bin/indent/indent_globs.h Sun Jun 3 13:40:58 2018 (r334556) @@ -136,7 +136,6 @@ char *be_save; /* similarly saved value of buf_ int found_err; -int pointer_as_binop; int blanklines_after_declarations; int blanklines_before_blockcomments; int blanklines_after_procs; Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 10:53:10 2018 (r334555) +++ head/usr.bin/indent/lexi.c Sun Jun 3 13:40:58 2018 (r334556) @@ -546,11 +546,9 @@ stop_lit: else if (*buf_ptr == '>') { /* check for operator -> */ *e_token++ = *buf_ptr++; - if (!pointer_as_binop) { - unary_delim = false; - code = unary_op; - ps.want_blank = false; - } + unary_delim = false; + code = unary_op; + ps.want_blank = false; } break; /* buffer overflow will be checked at end of * switch */ From owner-svn-src-head@freebsd.org Sun Jun 3 13:41:24 2018 Return-Path: Delivered-To: svn-src-head@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 CF789F7F6B8; Sun, 3 Jun 2018 13:41:24 +0000 (UTC) (envelope-from eadler@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 7CE8F85E8F; Sun, 3 Jun 2018 13:41:24 +0000 (UTC) (envelope-from eadler@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 5D6CD1F507; Sun, 3 Jun 2018 13:41:24 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w53DfO6m000820; Sun, 3 Jun 2018 13:41:24 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53DfOAD000819; Sun, 3 Jun 2018 13:41:24 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806031341.w53DfOAD000819@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 3 Jun 2018 13:41:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334557 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334557 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 13:41:25 -0000 Author: eadler Date: Sun Jun 3 13:41:23 2018 New Revision: 334557 URL: https://svnweb.freebsd.org/changeset/base/334557 Log: top(1): restore size for kern.cp_times Restore last minute change that broke top(1). Modified: head/usr.bin/top/machine.c Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sun Jun 3 13:40:58 2018 (r334556) +++ head/usr.bin/top/machine.c Sun Jun 3 13:41:23 2018 (r334557) @@ -384,6 +384,7 @@ machine_init(struct statics *statics) times = calloc(maxcpu * CPUSTATES, sizeof(long)); if (times == NULL) err(1, "calloc %zu bytes", size); + size = sizeof(long) * maxcpu * CPUSTATES; if (sysctlbyname("kern.cp_times", times, &size, NULL, 0) == -1) err(1, "sysctlbyname kern.cp_times"); pcpu_cp_time = calloc(1, size); From owner-svn-src-head@freebsd.org Sun Jun 3 14:03:21 2018 Return-Path: Delivered-To: svn-src-head@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 7D608FD175A; Sun, 3 Jun 2018 14:03:21 +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 30AFD8713B; Sun, 3 Jun 2018 14:03:21 +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 1334E1F993; Sun, 3 Jun 2018 14:03:21 +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 w53E3Kak011135; Sun, 3 Jun 2018 14:03:20 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53E3KnZ011132; Sun, 3 Jun 2018 14:03:20 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031403.w53E3KnZ011132@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 14:03:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334559 - in head/usr.bin/indent: . tests X-SVN-Group: head X-SVN-Commit-Author: pstef X-SVN-Commit-Paths: in head/usr.bin/indent: . tests X-SVN-Commit-Revision: 334559 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 14:03:21 -0000 Author: pstef Date: Sun Jun 3 14:03:20 2018 New Revision: 334559 URL: https://svnweb.freebsd.org/changeset/base/334559 Log: indent(1): improve handling of comments and newlines between "if (...)" or "while (...)" and "else" or "{" * Don't flush newlines - there can be multiple of them and they can happen before a token that isn't else or {. Instead, always store them in save_com. * Don't dump the buffer's contents on newline assuming that there is only one comment before else or {. * Avoid producing surplus newlines, especially before else when -ce is on. * When -bl is on, don't treat { as a comment (was implemented by falling through "case lbrace:" to "case comment:"). This commit fixes the above, but exposes another bug and thus breaks several other tests. Another commit will make them pass again. Modified: head/usr.bin/indent/indent.c head/usr.bin/indent/tests/elsecomment.0 head/usr.bin/indent/tests/elsecomment.0.stdout Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 13:54:22 2018 (r334558) +++ head/usr.bin/indent/indent.c Sun Jun 3 14:03:20 2018 (r334559) @@ -84,8 +84,6 @@ main(int argc, char **argv) int dec_ind; /* current indentation for declarations */ int di_stack[20]; /* a stack of structure indentation levels */ - int flushed_nl; /* used when buffering up comments to remember - * that a newline was passed over */ int force_nl; /* when true, code must be broken */ int hd_type = 0; /* used to store type of stmt for if (...), * for (...), etc */ @@ -324,6 +322,7 @@ main(int argc, char **argv) while (1) { /* this is the main loop. it will go until we * reach eof */ int is_procname; + int comment_buffered = false; type_code = lexi(); /* lexi reads one token. The actual * characters read are stored in "token". lexi @@ -331,132 +330,139 @@ main(int argc, char **argv) is_procname = ps.procname[0]; /* - * The following code moves everything following an if (), while (), - * else, etc. up to the start of the following stmt to a buffer. This - * allows proper handling of both kinds of brace placement. + * The following code moves newlines and comments following an if (), + * while (), else, etc. up to the start of the following stmt to + * a buffer. This allows proper handling of both kinds of brace + * placement (-br, -bl) and cuddling "else" (-ce). */ - flushed_nl = false; - while (ps.search_brace) { /* if we scanned an if(), while(), - * etc., we might need to copy stuff - * into a buffer we must loop, copying - * stuff into save_com, until we find - * the start of the stmt which follows - * the if, or whatever */ + while (ps.search_brace) { switch (type_code) { case newline: - ++line_no; - if (sc_end != NULL) { /* dump comment, if any */ - *sc_end++ = '\n'; /* newlines are needed in this case */ - goto sw_buffer; + if (sc_end == NULL) { + save_com[0] = save_com[1] = ' '; + sc_end = &save_com[2]; } - flushed_nl = true; + *sc_end++ = '\n'; + /* + * We may have inherited a force_nl == true from the previous + * token (like a semicolon). But once we know that a newline + * has been scanned in this loop, force_nl should be false. + * + * However, the force_nl == true must be preserved if newline + * is never scanned in this loop, so this assignment cannot be + * done earlier. + */ + force_nl = false; case form_feed: - break; /* form feeds and newlines found here will be - * ignored */ - - case lbrace: /* this is a brace that starts the compound - * stmt */ - if (sc_end == NULL) { /* ignore buffering if a comment wasn't - * stored up */ - ps.search_brace = false; - goto check_type; + break; + case comment: + if (sc_end == NULL) { + save_com[0] = save_com[1] = ' '; + sc_end = &save_com[2]; } - if (btype_2) { - save_com[0] = '{'; /* we either want to put the brace - * right after the if */ - goto sw_buffer; /* go to common code to get out of - * this loop */ - } - case comment: /* we have a comment, so we must copy it into - * the buffer */ - if (!flushed_nl || sc_end != NULL) { - if (sc_end == NULL) { /* if this is the first comment, we - * must set up the buffer */ - save_com[0] = save_com[1] = ' '; - sc_end = &(save_com[2]); + comment_buffered = true; + *sc_end++ = '/'; /* copy in start of comment */ + *sc_end++ = '*'; + for (;;) { /* loop until we get to the end of the comment */ + *sc_end = *buf_ptr++; + if (buf_ptr >= buf_end) + fill_buffer(); + if (*sc_end++ == '*' && *buf_ptr == '/') + break; /* we are at end of comment */ + if (sc_end >= &save_com[sc_size]) { /* check for temp buffer + * overflow */ + diag2(1, "Internal buffer overflow - Move big comment from right after if, while, or whatever"); + fflush(output); + exit(1); } - else { - *sc_end++ = '\n'; /* add newline between - * comments */ - *sc_end++ = ' '; - --line_no; - } - *sc_end++ = '/'; /* copy in start of comment */ - *sc_end++ = '*'; - - for (;;) { /* loop until we get to the end of the comment */ - *sc_end = *buf_ptr++; - if (buf_ptr >= buf_end) + } + *sc_end++ = '/'; /* add ending slash */ + if (++buf_ptr >= buf_end) /* get past / in buffer */ + fill_buffer(); + break; + case lbrace: + /* + * Put KNF-style lbraces before the buffered up tokens and + * jump out of this loop in order to avoid copying the token + * again under the default case of the switch below. + */ + if (sc_end != NULL && btype_2) { + save_com[0] = '{'; + /* + * Originally the lbrace may have been alone on its own + * line, but it will be moved into "the else's line", so + * if there was a newline resulting from the "{" before, + * it must be scanned now and ignored. + */ + while (isspace((int)*buf_ptr)) { + if (++buf_ptr >= buf_end) fill_buffer(); - - if (*sc_end++ == '*' && *buf_ptr == '/') - break; /* we are at end of comment */ - - if (sc_end >= &(save_com[sc_size])) { /* check for temp buffer - * overflow */ - diag2(1, "Internal buffer overflow - Move big comment from right after if, while, or whatever"); - fflush(output); - exit(1); - } + if (*buf_ptr == '\n') + break; } - *sc_end++ = '/'; /* add ending slash */ - if (++buf_ptr >= buf_end) /* get past / in buffer */ - fill_buffer(); - break; + goto sw_buffer; } + /* FALLTHROUGH */ default: /* it is the start of a normal statement */ - if (flushed_nl) /* if we flushed a newline, make sure it is - * put back */ - force_nl = true; - if ((type_code == sp_paren && *token == 'i' - && last_else && ps.else_if) - || (type_code == sp_nparen && *token == 'e' - && e_code != s_code && e_code[-1] == '}')) - force_nl = false; + { + int remove_newlines; - if (sc_end == NULL) { /* ignore buffering if comment wasn't - * saved up */ - ps.search_brace = false; - goto check_type; - } - if (force_nl) { /* if we should insert a nl here, put it into - * the buffer */ - force_nl = false; - --line_no; /* this will be re-increased when the nl is - * read from the buffer */ - *sc_end++ = '\n'; - *sc_end++ = ' '; - if (verbose && !flushed_nl) /* print error msg if the line - * was not already broken */ - diag2(0, "Line broken"); - flushed_nl = false; - } - for (t_ptr = token; *t_ptr; ++t_ptr) - *sc_end++ = *t_ptr; /* copy token into temp buffer */ - ps.procname[0] = 0; + remove_newlines = + /* "} else" */ + (type_code == sp_nparen && *token == 'e' && + e_code != s_code && e_code[-1] == '}') + /* "else if" */ + || (type_code == sp_paren && *token == 'i' && + last_else && ps.else_if); + if (remove_newlines) + force_nl = false; + if (sc_end == NULL) { /* ignore buffering if + * comment wasn't saved up */ + ps.search_brace = false; + goto check_type; + } + while (sc_end > save_com && isblank((int)sc_end[-1])) { + sc_end--; + } + if (swallow_optional_blanklines || + (!comment_buffered && remove_newlines)) { + force_nl = !remove_newlines; + while (sc_end > save_com && sc_end[-1] == '\n') { + sc_end--; + } + } + if (force_nl) { /* if we should insert a nl here, put + * it into the buffer */ + force_nl = false; + --line_no; /* this will be re-increased when the + * newline is read from the buffer */ + *sc_end++ = '\n'; + *sc_end++ = ' '; + if (verbose) /* print error msg if the line was + * not already broken */ + diag2(0, "Line broken"); + } + for (t_ptr = token; *t_ptr; ++t_ptr) + *sc_end++ = *t_ptr; - sw_buffer: - ps.search_brace = false; /* stop looking for start of + sw_buffer: + ps.search_brace = false; /* stop looking for start of * stmt */ - bp_save = buf_ptr; /* save current input buffer */ - be_save = buf_end; - buf_ptr = save_com; /* fix so that subsequent calls to + bp_save = buf_ptr; /* save current input buffer */ + be_save = buf_end; + buf_ptr = save_com; /* fix so that subsequent calls to * lexi will take tokens out of * save_com */ - *sc_end++ = ' ';/* add trailing blank, just in case */ - buf_end = sc_end; - sc_end = NULL; - break; + *sc_end++ = ' ';/* add trailing blank, just in case */ + buf_end = sc_end; + sc_end = NULL; + break; + } } /* end of switch */ if (type_code != 0) /* we must make this check, just in case there * was an unexpected EOF */ type_code = lexi(); /* read another token */ - /* if (ps.search_brace) ps.procname[0] = 0; */ - if ((is_procname = ps.procname[0]) && flushed_nl - && !procnames_start_line && ps.in_decl - && type_code == ident) - flushed_nl = 0; } /* end of while (search_brace) */ last_else = 0; check_type: @@ -485,9 +491,8 @@ check_type: (type_code != semicolon) && (type_code != lbrace || !btype_2)) { /* we should force a broken line here */ - if (verbose && !flushed_nl) + if (verbose) diag2(0, "Line broken"); - flushed_nl = false; dump_line(); ps.want_blank = false; /* dont insert blank at line start */ force_nl = false; @@ -1211,11 +1216,6 @@ check_type: * character will cause the line to be printed */ case comment: /* we have gotten a / followed by * this is a biggie */ - if (flushed_nl) { /* we should force a broken line here */ - dump_line(); - ps.want_blank = false; /* dont insert blank at line start */ - force_nl = false; - } pr_comment(); break; } /* end of big switch stmt */ Modified: head/usr.bin/indent/tests/elsecomment.0 ============================================================================== --- head/usr.bin/indent/tests/elsecomment.0 Sun Jun 3 13:54:22 2018 (r334558) +++ head/usr.bin/indent/tests/elsecomment.0 Sun Jun 3 14:03:20 2018 (r334559) @@ -1,18 +1,42 @@ /* $FreeBSD$ */ /* See r303484 and r309342 */ void t(void) { - if (0) { + /* The two if statements below excercise two different code paths. */ - } /* Old indent would remove the following blank line */ + if (1) /* a */ int a; else /* b */ int b; - /* - * test - */ + if (1) /* a */ + int a; + else /* b */ + int b; + if (1) { + + } + + + + /* Old indent would remove the 3 blank lines above, awaiting "else". */ + + if (1) { + int a; + } + + + else if (0) { + int b; + } + /* test */ + else + ; + if (1) ; else /* Old indent would get very confused here */ + /* We also mustn't assume that there's only one comment */ + /* before the left brace. */ { + } } Modified: head/usr.bin/indent/tests/elsecomment.0.stdout ============================================================================== --- head/usr.bin/indent/tests/elsecomment.0.stdout Sun Jun 3 13:54:22 2018 (r334558) +++ head/usr.bin/indent/tests/elsecomment.0.stdout Sun Jun 3 14:03:20 2018 (r334559) @@ -3,20 +3,45 @@ void t(void) { - if (0) + /* The two if statements below excercise two different code paths. */ + + if (1) /* a */ + int a; + else /* b */ + int b; + + if (1) /* a */ + int a; + else /* b */ + int b; + + if (1) { - } /* Old indent would remove the following - * blank line */ + } - /* - * test - */ + + /* Old indent would remove the 3 blank lines above, awaiting "else". */ + if (1) + { + int a; + } else if (0) + { + int b; + } + /* test */ + else ; + + if (1) + ; else /* Old indent would get very confused here */ + /* We also mustn't assume that there's only one comment */ + /* before the left brace. */ { + } } From owner-svn-src-head@freebsd.org Sun Jun 3 14:13:12 2018 Return-Path: Delivered-To: svn-src-head@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 7D8FBFD3C68; Sun, 3 Jun 2018 14:13:12 +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 2B9BE87935; Sun, 3 Jun 2018 14:13:12 +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 0CA171FB2F; Sun, 3 Jun 2018 14:13:12 +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 w53EDBp2016255; Sun, 3 Jun 2018 14:13:11 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53EDBIH016253; Sun, 3 Jun 2018 14:13:11 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031413.w53EDBIH016253@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 14:13:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334560 - 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: 334560 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 14:13:12 -0000 Author: pstef Date: Sun Jun 3 14:13:11 2018 New Revision: 334560 URL: https://svnweb.freebsd.org/changeset/base/334560 Log: indent(1): improve predictability of lexi() lexi() reads the input stream and categorizes the next token. indent will sometimes buffer up a sequence of tokens in order rearrange them. That is needed for properly cuddling else or placing braces correctly according to the chosen style (KNF vs Allman) when comments are around. The loop that buffers tokens up uses lexi() to decide if it's time to stop buffering. Then the temporary buffer is used to feed lexi() the same tokens again, this time for normal processing. The problem is that lexi() apart from recognizing the token, can change a lot of information about the current state, for example ps.last_nl, ps.keyword, buf_ptr. It also abandons leading whitespace, which is needed mainly for comment-related considerations. So the call to lexi() while tokens are buffered up and categorized can change the state before they're read again for normal processing which may easily result in changing interpretation of the current state and lead to incorrect output. To work around the problems: 1) copy the whitespace into the save_com buffer so that it will be read again when processed 2) trick lexi() into modifying a temporary copy of the parser state instead of the original. Modified: head/usr.bin/indent/indent.c head/usr.bin/indent/indent.h head/usr.bin/indent/lexi.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 14:03:20 2018 (r334559) +++ head/usr.bin/indent/indent.c Sun Jun 3 14:13:11 2018 (r334560) @@ -102,6 +102,7 @@ main(int argc, char **argv) int last_else = 0; /* true iff last keyword was an else */ const char *profile_name = NULL; const char *envval = NULL; + struct parser_state transient_state; /* a copy for lookup */ /*-----------------------------------------------*\ | INITIALIZATION | @@ -324,7 +325,7 @@ main(int argc, char **argv) int is_procname; int comment_buffered = false; - type_code = lexi(); /* lexi reads one token. The actual + type_code = lexi(&ps); /* lexi reads one token. The actual * characters read are stored in "token". lexi * returns a code indicating the type of token */ is_procname = ps.procname[0]; @@ -460,9 +461,48 @@ main(int argc, char **argv) break; } } /* end of switch */ - if (type_code != 0) /* we must make this check, just in case there - * was an unexpected EOF */ - type_code = lexi(); /* read another token */ + /* + * We must make this check, just in case there was an unexpected + * EOF. + */ + if (type_code != 0) { + /* + * The only intended purpose of calling lexi() below is to + * categorize the next token in order to decide whether to + * continue buffering forthcoming tokens. Once the buffering + * is over, lexi() will be called again elsewhere on all of + * the tokens - this time for normal processing. + * + * Calling it for this purpose is a bug, because lexi() also + * changes the parser state and discards leading whitespace, + * which is needed mostly for comment-related considerations. + * + * Work around the former problem by giving lexi() a copy of + * the current parser state and discard it if the call turned + * out to be just a look ahead. + * + * Work around the latter problem by copying all whitespace + * characters into the buffer so that the later lexi() call + * will read them. + */ + if (sc_end != NULL) { + while (*buf_ptr == ' ' || *buf_ptr == '\t') { + *sc_end++ = *buf_ptr++; + if (sc_end >= &save_com[sc_size]) { + abort(); + } + } + if (buf_ptr >= buf_end) { + fill_buffer(); + } + } + transient_state = ps; + type_code = lexi(&transient_state); /* read another token */ + if (type_code != newline && type_code != form_feed && + type_code != comment && !transient_state.search_brace) { + ps = transient_state; + } + } } /* end of while (search_brace) */ last_else = 0; check_type: Modified: head/usr.bin/indent/indent.h ============================================================================== --- head/usr.bin/indent/indent.h Sun Jun 3 14:03:20 2018 (r334559) +++ head/usr.bin/indent/indent.h Sun Jun 3 14:13:11 2018 (r334560) @@ -36,7 +36,7 @@ int compute_code_target(void); int compute_label_target(void); int count_spaces(int, char *); int count_spaces_until(int, char *, char *); -int lexi(void); +int lexi(struct parser_state *); void diag2(int, const char *); void diag3(int, const char *, int); void diag4(int, const char *, int, int); Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 14:03:20 2018 (r334559) +++ head/usr.bin/indent/lexi.c Sun Jun 3 14:13:11 2018 (r334560) @@ -141,7 +141,7 @@ strcmp_type(const void *e1, const void *e2) } int -lexi(void) +lexi(struct parser_state *state) { int unary_delim; /* this is set to 1 if the current token * forces a following operator to be unary */ @@ -152,12 +152,13 @@ lexi(void) e_token = s_token; /* point to start of place to save token */ unary_delim = false; - ps.col_1 = ps.last_nl; /* tell world that this token started in - * column 1 iff the last thing scanned was nl */ - ps.last_nl = false; + state->col_1 = state->last_nl; /* tell world that this token started + * in column 1 iff the last thing + * scanned was a newline */ + state->last_nl = false; while (*buf_ptr == ' ' || *buf_ptr == '\t') { /* get rid of blanks */ - ps.col_1 = false; /* leading blanks imply token is not in column + state->col_1 = false; /* leading blanks imply token is not in column * 1 */ if (++buf_ptr >= buf_end) fill_buffer(); @@ -281,18 +282,19 @@ lexi(void) if (++buf_ptr >= buf_end) fill_buffer(); } - ps.keyword = 0; - if (l_struct && !ps.p_l_follow) { + state->keyword = 0; + if (l_struct && !state->p_l_follow) { /* if last token was 'struct' and we're not * in parentheses, then this token * should be treated as a declaration */ l_struct = false; last_code = ident; - ps.last_u_d = true; + state->last_u_d = true; return (decl); } - ps.last_u_d = l_struct; /* Operator after identifier is binary - * unless last token was 'struct' */ + state->last_u_d = l_struct; /* Operator after identifier is + * binary unless last token was + * 'struct' */ l_struct = false; last_code = ident; /* Remember that this is the code we will * return */ @@ -310,13 +312,13 @@ lexi(void) strcmp(u, "_t") == 0) || (typename_top >= 0 && bsearch(s_token, typenames, typename_top + 1, sizeof(typenames[0]), strcmp_type))) { - ps.keyword = 4; /* a type name */ - ps.last_u_d = true; + state->keyword = 4; /* a type name */ + state->last_u_d = true; goto found_typename; } } else { /* we have a keyword */ - ps.keyword = p->rwcode; - ps.last_u_d = true; + state->keyword = p->rwcode; + state->last_u_d = true; switch (p->rwcode) { case 7: /* it is a switch */ return (swstmt); @@ -333,9 +335,9 @@ lexi(void) case 4: /* one of the declaration keywords */ found_typename: - if (ps.p_l_follow) { + if (state->p_l_follow) { /* inside parens: cast, param list, offsetof or sizeof */ - ps.cast_mask |= (1 << ps.p_l_follow) & ~ps.not_cast_mask; + state->cast_mask |= (1 << state->p_l_follow) & ~state->not_cast_mask; break; } last_code = decl; @@ -358,15 +360,15 @@ lexi(void) return (ident); } /* end of switch */ } /* end of if (found_it) */ - if (*buf_ptr == '(' && ps.tos <= 1 && ps.ind_level == 0 && - ps.in_parameter_declaration == 0 && ps.block_init == 0) { + if (*buf_ptr == '(' && state->tos <= 1 && state->ind_level == 0 && + state->in_parameter_declaration == 0 && state->block_init == 0) { char *tp = buf_ptr; while (tp < buf_end) if (*tp++ == ')' && (*tp == ';' || *tp == ',')) goto not_proc; - strncpy(ps.procname, token, sizeof ps.procname - 1); - if (ps.in_decl) - ps.in_parameter_declaration = 1; + strncpy(state->procname, token, sizeof state->procname - 1); + if (state->in_decl) + state->in_parameter_declaration = 1; return (last_code = funcname); not_proc:; } @@ -376,19 +378,19 @@ lexi(void) * typedefd */ if (((*buf_ptr == '*' && buf_ptr[1] != '=') || isalpha(*buf_ptr) || *buf_ptr == '_') - && !ps.p_l_follow - && !ps.block_init - && (ps.last_token == rparen || ps.last_token == semicolon || - ps.last_token == decl || - ps.last_token == lbrace || ps.last_token == rbrace)) { - ps.keyword = 4; /* a type name */ - ps.last_u_d = true; + && !state->p_l_follow + && !state->block_init + && (state->last_token == rparen || state->last_token == semicolon || + state->last_token == decl || + state->last_token == lbrace || state->last_token == rbrace)) { + state->keyword = 4; /* a type name */ + state->last_u_d = true; last_code = decl; return decl; } if (last_code == decl) /* if this is a declared variable, then * following sign is unary */ - ps.last_u_d = true; /* will make "int a -1" work */ + state->last_u_d = true; /* will make "int a -1" work */ last_code = ident; return (ident); /* the ident is not in the list */ } /* end of procesing for alpanum character */ @@ -403,8 +405,8 @@ lexi(void) switch (*token) { case '\n': - unary_delim = ps.last_u_d; - ps.last_nl = true; /* remember that we just had a newline */ + unary_delim = state->last_u_d; + state->last_nl = true; /* remember that we just had a newline */ code = (had_eof ? 0 : newline); /* @@ -473,7 +475,7 @@ stop_lit: break; case '#': - unary_delim = ps.last_u_d; + unary_delim = state->last_u_d; code = preesc; break; @@ -496,21 +498,21 @@ stop_lit: unary_delim = true; /* - * if (ps.in_or_st) ps.block_init = 1; + * if (state->in_or_st) state->block_init = 1; */ - /* ? code = ps.block_init ? lparen : lbrace; */ + /* ? code = state->block_init ? lparen : lbrace; */ code = lbrace; break; case ('}'): unary_delim = true; - /* ? code = ps.block_init ? rparen : rbrace; */ + /* ? code = state->block_init ? rparen : rbrace; */ code = rbrace; break; case 014: /* a form feed */ - unary_delim = ps.last_u_d; - ps.last_nl = true; /* remember this so we can set 'ps.col_1' + unary_delim = state->last_u_d; + state->last_nl = true; /* remember this so we can set 'state->col_1' * right */ code = form_feed; break; @@ -527,7 +529,7 @@ stop_lit: case '-': case '+': /* check for -, +, --, ++ */ - code = (ps.last_u_d ? unary_op : binary_op); + code = (state->last_u_d ? unary_op : binary_op); unary_delim = true; if (*buf_ptr == token[0]) { @@ -535,7 +537,7 @@ stop_lit: *e_token++ = *buf_ptr++; /* buffer overflow will be checked at end of loop */ if (last_code == ident || last_code == rparen) { - code = (ps.last_u_d ? unary_op : postop); + code = (state->last_u_d ? unary_op : postop); /* check for following ++ or -- */ unary_delim = false; } @@ -548,14 +550,14 @@ stop_lit: *e_token++ = *buf_ptr++; unary_delim = false; code = unary_op; - ps.want_blank = false; + state->want_blank = false; } break; /* buffer overflow will be checked at end of * switch */ case '=': - if (ps.in_or_st) - ps.block_init = 1; + if (state->in_or_st) + state->block_init = 1; #ifdef undef if (chartype[*buf_ptr] == opchar) { /* we have two char assignment */ e_token[-1] = *buf_ptr++; @@ -586,7 +588,7 @@ stop_lit: } if (*buf_ptr == '=') *e_token++ = *buf_ptr++; - code = (ps.last_u_d ? unary_op : binary_op); + code = (state->last_u_d ? unary_op : binary_op); unary_delim = true; break; @@ -599,7 +601,7 @@ stop_lit: fill_buffer(); code = comment; - unary_delim = ps.last_u_d; + unary_delim = state->last_u_d; break; } while (*(e_token - 1) == *buf_ptr || *buf_ptr == '=') { @@ -610,7 +612,7 @@ stop_lit: if (++buf_ptr >= buf_end) fill_buffer(); } - code = (ps.last_u_d ? unary_op : binary_op); + code = (state->last_u_d ? unary_op : binary_op); unary_delim = true; @@ -621,7 +623,7 @@ stop_lit: } if (buf_ptr >= buf_end) /* check for input buffer empty */ fill_buffer(); - ps.last_u_d = unary_delim; + state->last_u_d = unary_delim; *e_token = '\0'; /* null terminate the token */ return (code); } From owner-svn-src-head@freebsd.org Sun Jun 3 15:28:57 2018 Return-Path: Delivered-To: svn-src-head@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 C6A93FE1FA9; Sun, 3 Jun 2018 15:28:56 +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 796A36B168; Sun, 3 Jun 2018 15:28:56 +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 5A8E620678; Sun, 3 Jun 2018 15:28:56 +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 w53FSusO051782; Sun, 3 Jun 2018 15:28:56 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53FSttd051776; Sun, 3 Jun 2018 15:28:55 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031528.w53FSttd051776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 15:28:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334563 - in head/usr.bin/indent: . tests X-SVN-Group: head X-SVN-Commit-Author: pstef X-SVN-Commit-Paths: in head/usr.bin/indent: . tests X-SVN-Commit-Revision: 334563 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 15:28:57 -0000 Author: pstef Date: Sun Jun 3 15:28:55 2018 New Revision: 334563 URL: https://svnweb.freebsd.org/changeset/base/334563 Log: indent(1): improve handling of boxed comments indentation The trick is to copy everything from the start of the line into the buffer that stores newlines and comments until indent finds a brace or an else. pr_comment() will use that information to calculate the original indentation of the boxed comment. This requires storing two pieces of information: the real start of the buffer (sc_buf) and the start of the comment (save_com). Modified: head/usr.bin/indent/indent.c head/usr.bin/indent/indent_globs.h head/usr.bin/indent/pr_comment.c head/usr.bin/indent/tests/comments.0 head/usr.bin/indent/tests/comments.0.stdout Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 15:12:40 2018 (r334562) +++ head/usr.bin/indent/indent.c Sun Jun 3 15:28:55 2018 (r334563) @@ -341,6 +341,7 @@ main(int argc, char **argv) switch (type_code) { case newline: if (sc_end == NULL) { + save_com = sc_buf; save_com[0] = save_com[1] = ' '; sc_end = &save_com[2]; } @@ -359,6 +360,13 @@ main(int argc, char **argv) break; case comment: if (sc_end == NULL) { + /* + * Copy everything from the start of the line, because + * pr_comment() will use that to calculate original + * indentation of a boxed comment. + */ + memcpy(sc_buf, in_buffer, buf_ptr - in_buffer - 4); + save_com = sc_buf + (buf_ptr - in_buffer - 4); save_com[0] = save_com[1] = ' '; sc_end = &save_com[2]; } @@ -1172,9 +1180,11 @@ check_type: e_lab--; if (e_lab - s_lab == com_end && bp_save == NULL) { /* comment on preprocessor line */ - if (sc_end == NULL) /* if this is the first comment, we - * must set up the buffer */ - sc_end = &(save_com[0]); + if (sc_end == NULL) { /* if this is the first comment, + * we must set up the buffer */ + save_com = sc_buf; + sc_end = &save_com[0]; + } else { *sc_end++ = '\n'; /* add newline between * comments */ Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jun 3 15:12:40 2018 (r334562) +++ head/usr.bin/indent/indent_globs.h Sun Jun 3 15:28:55 2018 (r334563) @@ -126,8 +126,9 @@ char *buf_ptr; /* ptr to next character to be t * in_buffer */ char *buf_end; /* ptr to first after last char in in_buffer */ -char save_com[sc_size]; /* input text is saved here when looking for +char sc_buf[sc_size]; /* input text is saved here when looking for * the brace after an if, while, etc */ +char *save_com; /* start of the comment stored in sc_buf */ char *sc_end; /* pointer into save_com buffer */ char *bp_save; /* saved value of buf_ptr when taking input @@ -241,8 +242,12 @@ struct parser_state { 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 * */ - int comment_delta, - n_comment_delta; + int comment_delta; /* used to set up indentation for all lines + * of a boxed comment after the first one */ + int n_comment_delta;/* remembers how many columns there were + * before the start of a box comment so that + * forthcoming lines of the comment are + * indented properly */ int cast_mask; /* indicates which close parens potentially * close off casts */ int not_cast_mask; /* indicates which close parens definitely Modified: head/usr.bin/indent/pr_comment.c ============================================================================== --- head/usr.bin/indent/pr_comment.c Sun Jun 3 15:12:40 2018 (r334562) +++ head/usr.bin/indent/pr_comment.c Sun Jun 3 15:28:55 2018 (r334563) @@ -158,8 +158,11 @@ pr_comment(void) * The comment we're about to read usually comes from in_buffer, * unless it has been copied into save_com. */ - char *start = buf_ptr >= save_com && buf_ptr < save_com + sc_size ? bp_save : buf_ptr; - ps.n_comment_delta = 1 - count_spaces_until(1, in_buffer, start - 2); + char *start; + + start = buf_ptr >= save_com && buf_ptr < save_com + sc_size ? + sc_buf : in_buffer; + ps.n_comment_delta = 1 - count_spaces_until(1, start, buf_ptr - 2); } else { ps.n_comment_delta = 0; Modified: head/usr.bin/indent/tests/comments.0 ============================================================================== --- head/usr.bin/indent/tests/comments.0 Sun Jun 3 15:12:40 2018 (r334562) +++ head/usr.bin/indent/tests/comments.0 Sun Jun 3 15:28:55 2018 (r334563) @@ -30,3 +30,23 @@ void t(void) { /* r309343 */ } + +int c(void) +{ + if (1) { /*- a christmas tree * + *** + ***** */ + /*- another one * + *** + ***** */ + 7; + } + + if (1) /*- a christmas tree * + *** + ***** */ + /*- another one * + *** + ***** */ + 1; +} Modified: head/usr.bin/indent/tests/comments.0.stdout ============================================================================== --- head/usr.bin/indent/tests/comments.0.stdout Sun Jun 3 15:12:40 2018 (r334562) +++ head/usr.bin/indent/tests/comments.0.stdout Sun Jun 3 15:28:55 2018 (r334563) @@ -37,3 +37,24 @@ t(void) /* r309343 */ } + +int +c(void) +{ + if (1) { /*- a christmas tree * + *** + ***** */ + /*- another one * + *** + ***** */ + 7; + } + + if (1) /*- a christmas tree * + *** + ***** */ + /*- another one * + *** + ***** */ + 1; +} From owner-svn-src-head@freebsd.org Sun Jun 3 16:21:17 2018 Return-Path: Delivered-To: svn-src-head@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 D3ED5FD582E; Sun, 3 Jun 2018 16:21:16 +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 8A1656D41C; Sun, 3 Jun 2018 16:21:16 +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 6C67C20ED4; Sun, 3 Jun 2018 16:21:16 +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 w53GLGRr077471; Sun, 3 Jun 2018 16:21:16 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53GLFWj077466; Sun, 3 Jun 2018 16:21:15 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031621.w53GLFWj077466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 16:21:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334564 - in head/usr.bin/indent: . tests X-SVN-Group: head X-SVN-Commit-Author: pstef X-SVN-Commit-Paths: in head/usr.bin/indent: . tests X-SVN-Commit-Revision: 334564 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 16:21:17 -0000 Author: pstef Date: Sun Jun 3 16:21:15 2018 New Revision: 334564 URL: https://svnweb.freebsd.org/changeset/base/334564 Log: indent(1): disjoint parser state from lexi() The function is sometimes used as a look-ahead, so ideally it should bear no information about parser state. Modified: head/usr.bin/indent/indent.c head/usr.bin/indent/indent_codes.h head/usr.bin/indent/lexi.c head/usr.bin/indent/tests/struct.0 head/usr.bin/indent/tests/struct.0.stdout Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 15:28:55 2018 (r334563) +++ head/usr.bin/indent/indent.c Sun Jun 3 16:21:15 2018 (r334564) @@ -995,6 +995,9 @@ check_type: prefix_blankline_requested = 0; goto copy_id; + case structure: + if (ps.p_l_follow > 0) + goto copy_id; case decl: /* we have a declaration type (int, etc.) */ parse(decl); /* let parser worry about indentation */ if (ps.last_token == rparen && ps.tos <= 1) { Modified: head/usr.bin/indent/indent_codes.h ============================================================================== --- head/usr.bin/indent/indent_codes.h Sun Jun 3 15:28:55 2018 (r334563) +++ head/usr.bin/indent/indent_codes.h Sun Jun 3 16:21:15 2018 (r334564) @@ -74,4 +74,4 @@ #define storage 34 #define funcname 35 #define type_def 36 - +#define structure 37 Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 15:28:55 2018 (r334563) +++ head/usr.bin/indent/lexi.c Sun Jun 3 16:21:15 2018 (r334564) @@ -145,8 +145,6 @@ lexi(struct parser_state *state) { int unary_delim; /* this is set to 1 if the current token * forces a following operator to be unary */ - static int last_code; /* the last token type returned */ - static int l_struct; /* set to 1 if the last token was 'struct' */ int code; /* internal code to be returned */ char qchar; /* the delimiter character for a string */ @@ -283,21 +281,17 @@ lexi(struct parser_state *state) fill_buffer(); } state->keyword = 0; - if (l_struct && !state->p_l_follow) { + if (state->last_token == structure && !state->p_l_follow) { /* if last token was 'struct' and we're not * in parentheses, then this token * should be treated as a declaration */ - l_struct = false; - last_code = ident; state->last_u_d = true; return (decl); } - state->last_u_d = l_struct; /* Operator after identifier is - * binary unless last token was - * 'struct' */ - l_struct = false; - last_code = ident; /* Remember that this is the code we will - * return */ + /* + * Operator after identifier is binary unless last token was 'struct' + */ + state->last_u_d = (state->last_token == structure); p = bsearch(s_token, specials, @@ -326,21 +320,17 @@ lexi(struct parser_state *state) return (casestmt); case 3: /* a "struct" */ - /* - * Next time around, we will want to know that we have had a - * 'struct' - */ - l_struct = true; /* FALLTHROUGH */ - case 4: /* one of the declaration keywords */ found_typename: if (state->p_l_follow) { /* inside parens: cast, param list, offsetof or sizeof */ state->cast_mask |= (1 << state->p_l_follow) & ~state->not_cast_mask; - break; } - last_code = decl; + if (p != NULL && p->rwcode == 3) + return (structure); + if (state->p_l_follow) + break; return (decl); case 5: /* if, while, for */ @@ -369,7 +359,7 @@ lexi(struct parser_state *state) strncpy(state->procname, token, sizeof state->procname - 1); if (state->in_decl) state->in_parameter_declaration = 1; - return (last_code = funcname); + return (funcname); not_proc:; } /* @@ -385,13 +375,11 @@ lexi(struct parser_state *state) state->last_token == lbrace || state->last_token == rbrace)) { state->keyword = 4; /* a type name */ state->last_u_d = true; - last_code = decl; return decl; } - if (last_code == decl) /* if this is a declared variable, then - * following sign is unary */ + if (state->last_token == decl) /* if this is a declared variable, + * then following sign is unary */ state->last_u_d = true; /* will make "int a -1" work */ - last_code = ident; return (ident); /* the ident is not in the list */ } /* end of procesing for alpanum character */ @@ -536,7 +524,7 @@ stop_lit: /* check for doubled character */ *e_token++ = *buf_ptr++; /* buffer overflow will be checked at end of loop */ - if (last_code == ident || last_code == rparen) { + if (state->last_token == ident || state->last_token == rparen) { code = (state->last_u_d ? unary_op : postop); /* check for following ++ or -- */ unary_delim = false; @@ -617,10 +605,6 @@ stop_lit: } /* end of switch */ - if (code != newline) { - l_struct = false; - last_code = code; - } if (buf_ptr >= buf_end) /* check for input buffer empty */ fill_buffer(); state->last_u_d = unary_delim; Modified: head/usr.bin/indent/tests/struct.0 ============================================================================== --- head/usr.bin/indent/tests/struct.0 Sun Jun 3 15:28:55 2018 (r334563) +++ head/usr.bin/indent/tests/struct.0 Sun Jun 3 16:21:15 2018 (r334564) @@ -1,4 +1,7 @@ /* $FreeBSD$ */ + +int f(struct x *a); + /* See r303485 */ void t(void) @@ -10,4 +13,9 @@ t(void) { D, E }, { F, G } }; +} + +void u(struct x a) { + int b; + struct y c = (struct y *)&a; } Modified: head/usr.bin/indent/tests/struct.0.stdout ============================================================================== --- head/usr.bin/indent/tests/struct.0.stdout Sun Jun 3 15:28:55 2018 (r334563) +++ head/usr.bin/indent/tests/struct.0.stdout Sun Jun 3 16:21:15 2018 (r334564) @@ -1,4 +1,7 @@ /* $FreeBSD$ */ + +int f(struct x *a); + /* See r303485 */ void t(void) @@ -10,4 +13,11 @@ t(void) {D, E}, {F, G} }; +} + +void +u(struct x a) +{ + int b; + struct y c = (struct y *)&a; } From owner-svn-src-head@freebsd.org Sun Jun 3 16:27:41 2018 Return-Path: Delivered-To: svn-src-head@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 166A2FDB682; Sun, 3 Jun 2018 16:27:41 +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 C0EF76D852; Sun, 3 Jun 2018 16:27:40 +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 A22AE21027; Sun, 3 Jun 2018 16:27:40 +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 w53GRerG081524; Sun, 3 Jun 2018 16:27:40 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53GRebs081523; Sun, 3 Jun 2018 16:27:40 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031627.w53GRebs081523@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 16:27:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334565 - 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: 334565 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 16:27:41 -0000 Author: pstef Date: Sun Jun 3 16:27:40 2018 New Revision: 334565 URL: https://svnweb.freebsd.org/changeset/base/334565 Log: indent(1): remove is_procname. It was a shorthand for checking if ps.procname is a non-empty string; the same can be done with ps.procname[0] which avoids the need for updating is_procname after every call to lexi(). Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 16:21:15 2018 (r334564) +++ head/usr.bin/indent/indent.c Sun Jun 3 16:27:40 2018 (r334565) @@ -322,13 +322,11 @@ main(int argc, char **argv) while (1) { /* this is the main loop. it will go until we * reach eof */ - int is_procname; int comment_buffered = false; type_code = lexi(&ps); /* lexi reads one token. The actual * characters read are stored in "token". lexi * returns a code indicating the type of token */ - is_procname = ps.procname[0]; /* * The following code moves newlines and comments following an if (), @@ -596,7 +594,7 @@ check_type: ps.p_l_follow--; } if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent && - !is_procname && ps.paren_level == 0) { + ps.procname[0] == '\0' && ps.paren_level == 0) { /* function pointer declarations */ if (troff) { sprintf(e_code, "\n.Du %dp+\200p \"%s\"\n", dec_ind * 7, token); @@ -672,8 +670,8 @@ check_type: break; case unary_op: /* this could be any unary operation */ - if (!ps.dumped_decl_indent && ps.in_decl && !is_procname && - !ps.block_init && ps.paren_level == 0) { + if (!ps.dumped_decl_indent && ps.in_decl && !ps.block_init && + ps.procname[0] == '\0' && ps.paren_level == 0) { /* pointer declarations */ if (troff) { if (ps.want_blank) @@ -1105,7 +1103,7 @@ check_type: ps.want_blank = (s_code != e_code); /* only put blank after comma * if comma does not start the * line */ - if (ps.in_decl && is_procname == 0 && !ps.block_init && + if (ps.in_decl && ps.procname[0] == '\0' && !ps.block_init && !ps.dumped_decl_indent && ps.paren_level == 0) { /* indent leading commas and not the actual identifiers */ indent_declaration(dec_ind - 1, tabs_to_var); From owner-svn-src-head@freebsd.org Sun Jun 3 16:43:00 2018 Return-Path: Delivered-To: svn-src-head@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 52D08FDD5BF; Sun, 3 Jun 2018 16:43:00 +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 029796E403; Sun, 3 Jun 2018 16:43:00 +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 D652021365; Sun, 3 Jun 2018 16:42:59 +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 w53Ggxju091474; Sun, 3 Jun 2018 16:42:59 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53Ggwac091469; Sun, 3 Jun 2018 16:42:58 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031642.w53Ggwac091469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 16:42:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334566 - in head/usr.bin/indent: . tests X-SVN-Group: head X-SVN-Commit-Author: pstef X-SVN-Commit-Paths: in head/usr.bin/indent: . tests X-SVN-Commit-Revision: 334566 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 16:43:00 -0000 Author: pstef Date: Sun Jun 3 16:42:58 2018 New Revision: 334566 URL: https://svnweb.freebsd.org/changeset/base/334566 Log: indent(1): don't format function declarations as variables Added: head/usr.bin/indent/tests/f_decls.0 (contents, props changed) head/usr.bin/indent/tests/f_decls.0.stdout (contents, props changed) Modified: head/usr.bin/indent/indent.c head/usr.bin/indent/lexi.c head/usr.bin/indent/tests/Makefile Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 16:27:40 2018 (r334565) +++ head/usr.bin/indent/indent.c Sun Jun 3 16:42:58 2018 (r334566) @@ -1029,30 +1029,31 @@ check_type: case funcname: case ident: /* got an identifier or constant */ - if (ps.in_decl) { /* if we are in a declaration, we must indent - * identifier */ - if (type_code != funcname || !procnames_start_line) { - if (!ps.block_init && !ps.dumped_decl_indent && ps.paren_level == 0) { - if (troff) { - if (ps.want_blank) - *e_code++ = ' '; - sprintf(e_code, "\n.De %dp+\200p\n", dec_ind * 7); - e_code += strlen(e_code); - } else - indent_declaration(dec_ind, tabs_to_var); - ps.dumped_decl_indent = true; - ps.want_blank = false; - } - } else { - if (ps.want_blank && !(procnames_start_line && - type_code == funcname)) - *e_code++ = ' '; - ps.want_blank = false; - if (dec_ind && s_code != e_code) { + if (ps.in_decl) { + if (type_code == funcname) { + ps.in_decl = false; + if (procnames_start_line && s_code != e_code) { *e_code = '\0'; dump_line(); } - dec_ind = 0; + else if (ps.want_blank) { + *e_code++ = ' '; + } + ps.want_blank = false; + } + else if (!ps.block_init && !ps.dumped_decl_indent && + ps.paren_level == 0) { /* if we are in a declaration, we + * must indent identifier */ + + if (troff) { + if (ps.want_blank) + *e_code++ = ' '; + sprintf(e_code, "\n.De %dp+\200p\n", dec_ind * 7); + e_code += strlen(e_code); + } else + indent_declaration(dec_ind, tabs_to_var); + ps.dumped_decl_indent = true; + ps.want_blank = false; } } else if (sp_sw && ps.p_l_follow == 0) { Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 16:27:40 2018 (r334565) +++ head/usr.bin/indent/lexi.c Sun Jun 3 16:42:58 2018 (r334566) @@ -367,12 +367,12 @@ lexi(struct parser_state *state) * token is in fact a declaration keyword -- one that has been * typedefd */ - if (((*buf_ptr == '*' && buf_ptr[1] != '=') || isalpha(*buf_ptr) || *buf_ptr == '_') - && !state->p_l_follow - && !state->block_init - && (state->last_token == rparen || state->last_token == semicolon || - state->last_token == decl || - state->last_token == lbrace || state->last_token == rbrace)) { + else if (!state->p_l_follow && !state->block_init && + !state->in_stmt && + ((*buf_ptr == '*' && buf_ptr[1] != '=') || + isalpha((unsigned char)*buf_ptr)) && + (state->last_token == semicolon || state->last_token == lbrace || + state->last_token == rbrace)) { state->keyword = 4; /* a type name */ state->last_u_d = true; return decl; @@ -578,6 +578,34 @@ stop_lit: *e_token++ = *buf_ptr++; code = (state->last_u_d ? unary_op : binary_op); unary_delim = true; + break; + + case '*': + unary_delim = true; + if (!state->last_u_d) { + if (*buf_ptr == '=') + *e_token++ = *buf_ptr++; + code = binary_op; + break; + } + while (*buf_ptr == '*' || isspace((unsigned char)*buf_ptr)) { + if (*buf_ptr == '*') + *e_token++ = *buf_ptr; + if (++buf_ptr >= buf_end) + fill_buffer(); + } + if (ps.in_decl) { + char *tp = buf_ptr; + + while (isalpha((unsigned char)*tp) || + isspace((unsigned char)*tp)) { + if (++tp >= buf_end) + fill_buffer(); + } + if (*tp == '(') + ps.procname[0] = ' '; + } + code = unary_op; break; default: Modified: head/usr.bin/indent/tests/Makefile ============================================================================== --- head/usr.bin/indent/tests/Makefile Sun Jun 3 16:27:40 2018 (r334565) +++ head/usr.bin/indent/tests/Makefile Sun Jun 3 16:42:58 2018 (r334566) @@ -11,6 +11,8 @@ ${PACKAGE}FILES+= declarations.0.stdout ${PACKAGE}FILES+= elsecomment.0 ${PACKAGE}FILES+= elsecomment.0.stdout ${PACKAGE}FILES+= elsecomment.0.pro +${PACKAGE}FILES+= f_decls.0 +${PACKAGE}FILES+= f_decls.0.stdout ${PACKAGE}FILES+= float.0 ${PACKAGE}FILES+= float.0.stdout ${PACKAGE}FILES+= label.0 Added: head/usr.bin/indent/tests/f_decls.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/indent/tests/f_decls.0 Sun Jun 3 16:42:58 2018 (r334566) @@ -0,0 +1,29 @@ +/* $FreeBSD$ */ + +char * x(void) +{ + type identifier; + type *pointer; + unused * value; + (void)unused * value; + + dmax = (double)3 * 10.0; + dmin = (double)dmax * 10.0; + davg = (double)dmax * dmin; + + return NULL; +} + +int * +y(void) { + +} + +int +z(void) { + +} + +int x; +int *y; +int * * * * z; Added: head/usr.bin/indent/tests/f_decls.0.stdout ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/indent/tests/f_decls.0.stdout Sun Jun 3 16:42:58 2018 (r334566) @@ -0,0 +1,32 @@ +/* $FreeBSD$ */ + +char * +x(void) +{ + type identifier; + type *pointer; + unused *value; + (void)unused * value; + + dmax = (double)3 * 10.0; + dmin = (double)dmax * 10.0; + davg = (double)dmax * dmin; + + return NULL; +} + +int * +y(void) +{ + +} + +int +z(void) +{ + +} + +int x; +int *y; +int ****z; From owner-svn-src-head@freebsd.org Sun Jun 3 16:52:31 2018 Return-Path: Delivered-To: svn-src-head@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 B677BFDE97D; Sun, 3 Jun 2018 16:52:31 +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 6843A6EAE4; Sun, 3 Jun 2018 16:52:31 +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 4B02E21501; Sun, 3 Jun 2018 16:52:31 +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 w53GqVlf096264; Sun, 3 Jun 2018 16:52:31 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53GqVMW096263; Sun, 3 Jun 2018 16:52:31 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031652.w53GqVMW096263@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 16:52:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334567 - 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: 334567 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 16:52:31 -0000 Author: pstef Date: Sun Jun 3 16:52:30 2018 New Revision: 334567 URL: https://svnweb.freebsd.org/changeset/base/334567 Log: indent(1): recognize more type names Most are from C99. Modified: head/usr.bin/indent/lexi.c Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 16:42:58 2018 (r334566) +++ head/usr.bin/indent/lexi.c Sun Jun 3 16:52:30 2018 (r334567) @@ -74,11 +74,17 @@ struct templ { */ struct templ specials[] = { + {"_Bool", 4}, + {"_Complex", 4}, + {"_Imaginary", 4}, {"auto", 10}, + {"bool", 4}, {"break", 9}, {"case", 8}, {"char", 4}, + {"complex", 4}, {"const", 4}, + {"continue", 12}, {"default", 8}, {"do", 6}, {"double", 4}, @@ -90,12 +96,16 @@ struct templ specials[] = {"global", 4}, {"goto", 9}, {"if", 5}, + {"imaginary", 4}, + {"inline", 12}, {"int", 4}, {"long", 4}, {"offsetof", 1}, {"register", 10}, + {"restrict", 12}, {"return", 9}, {"short", 4}, + {"signed", 4}, {"sizeof", 2}, {"static", 10}, {"struct", 3}, From owner-svn-src-head@freebsd.org Sun Jun 3 17:03:57 2018 Return-Path: Delivered-To: svn-src-head@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 67E98FDFD4F; Sun, 3 Jun 2018 17:03:57 +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 1E81E6F1E9; Sun, 3 Jun 2018 17:03:57 +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 D9A2421693; Sun, 3 Jun 2018 17:03:56 +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 w53H3uDH001538; Sun, 3 Jun 2018 17:03:56 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53H3ufe001534; Sun, 3 Jun 2018 17:03:56 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031703.w53H3ufe001534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 17:03:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334568 - 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: 334568 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 17:03:57 -0000 Author: pstef Date: Sun Jun 3 17:03:55 2018 New Revision: 334568 URL: https://svnweb.freebsd.org/changeset/base/334568 Log: indent(1): limit character classification functions' input to unsigned char Modified: head/usr.bin/indent/args.c head/usr.bin/indent/indent.c head/usr.bin/indent/io.c head/usr.bin/indent/lexi.c Modified: head/usr.bin/indent/args.c ============================================================================== --- head/usr.bin/indent/args.c Sun Jun 3 16:52:30 2018 (r334567) +++ head/usr.bin/indent/args.c Sun Jun 3 17:03:55 2018 (r334568) @@ -217,7 +217,7 @@ scan_profile(FILE *f) } else if (i == '/' && comment && p > buf && p[-1] == '*') { p = buf + comment - 1; comment = 0; - } else if (isspace(i)) { + } else if (isspace((unsigned char)i)) { if (p > buf && !comment) break; } else { @@ -321,7 +321,7 @@ found: break; case PRO_INT: - if (!isdigit(*param_start)) { + if (!isdigit((unsigned char)*param_start)) { need_param: errx(1, "%s: ``%s'' requires a parameter", option_source, p->p_name); } Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 16:52:30 2018 (r334567) +++ head/usr.bin/indent/indent.c Sun Jun 3 17:03:55 2018 (r334568) @@ -402,7 +402,7 @@ main(int argc, char **argv) * if there was a newline resulting from the "{" before, * it must be scanned now and ignored. */ - while (isspace((int)*buf_ptr)) { + while (isspace((unsigned char)*buf_ptr)) { if (++buf_ptr >= buf_end) fill_buffer(); if (*buf_ptr == '\n') @@ -429,7 +429,7 @@ main(int argc, char **argv) ps.search_brace = false; goto check_type; } - while (sc_end > save_com && isblank((int)sc_end[-1])) { + while (sc_end > save_com && isblank((unsigned char)sc_end[-1])) { sc_end--; } if (swallow_optional_blanklines || @@ -1070,7 +1070,7 @@ check_type: e_code = chfont(&bodyf, &keywordf, e_code); for (t_ptr = token; *t_ptr; ++t_ptr) { CHECK_SIZE_CODE; - *e_code++ = keywordf.allcaps && islower(*t_ptr) + *e_code++ = keywordf.allcaps && islower((unsigned char)*t_ptr) ? toupper(*t_ptr) : *t_ptr; } e_code = chfont(&keywordf, &bodyf, e_code); Modified: head/usr.bin/indent/io.c ============================================================================== --- head/usr.bin/indent/io.c Sun Jun 3 16:52:30 2018 (r334567) +++ head/usr.bin/indent/io.c Sun Jun 3 17:03:55 2018 (r334568) @@ -243,7 +243,7 @@ dump_line(void) cur_col = 1; ++ps.out_lines; } - while (e_com > com_st && isspace(e_com[-1])) + while (e_com > com_st && isspace((unsigned char)e_com[-1])) e_com--; (void)pad_output(cur_col, target); fwrite(com_st, e_com - com_st, 1, output); @@ -638,9 +638,9 @@ parsefont(struct fstate *f, const char *s0) memset(f, '\0', sizeof(*f)); while (*s) { - if (isdigit(*s)) + if (isdigit((unsigned char)*s)) f->size = f->size * 10 + *s - '0'; - else if (isupper(*s)) + else if (isupper((unsigned char)*s)) if (f->font[0]) f->font[1] = *s; else Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 16:52:30 2018 (r334567) +++ head/usr.bin/indent/lexi.c Sun Jun 3 17:03:55 2018 (r334568) @@ -173,13 +173,15 @@ lexi(struct parser_state *state) } /* Scan an alphanumeric token */ - if (chartype[(int)*buf_ptr] == alphanum || (buf_ptr[0] == '.' && isdigit(buf_ptr[1]))) { + if (chartype[*buf_ptr & 127] == alphanum || + (buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) { /* * we have a character or number */ struct templ *p; - if (isdigit(*buf_ptr) || (buf_ptr[0] == '.' && isdigit(buf_ptr[1]))) { + if (isdigit((unsigned char)*buf_ptr) || + (buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) { enum base { BASE_2, BASE_8, BASE_10, BASE_16 }; @@ -193,7 +195,7 @@ lexi(struct parser_state *state) in_base = BASE_2; else if (buf_ptr[1] == 'x' || buf_ptr[1] == 'X') in_base = BASE_16; - else if (isdigit(buf_ptr[1])) + else if (isdigit((unsigned char)buf_ptr[1])) in_base = BASE_8; } switch (in_base) { @@ -215,7 +217,7 @@ lexi(struct parser_state *state) case BASE_16: *e_token++ = *buf_ptr++; *e_token++ = *buf_ptr++; - while (isxdigit(*buf_ptr)) { + while (isxdigit((unsigned char)*buf_ptr)) { CHECK_SIZE_TOKEN; *e_token++ = *buf_ptr++; } @@ -230,7 +232,7 @@ lexi(struct parser_state *state) } CHECK_SIZE_TOKEN; *e_token++ = *buf_ptr++; - if (!isdigit(*buf_ptr) && *buf_ptr != '.') { + if (!isdigit((unsigned char)*buf_ptr) && *buf_ptr != '.') { if ((*buf_ptr != 'E' && *buf_ptr != 'e') || seenexp) break; else { @@ -264,7 +266,7 @@ lexi(struct parser_state *state) } } else - while (chartype[(int)*buf_ptr] == alphanum || *buf_ptr == BACKSLASH) { + while (chartype[*buf_ptr & 127] == alphanum || *buf_ptr == BACKSLASH) { /* fill_buffer() terminates buffer with newline */ if (*buf_ptr == BACKSLASH) { if (*(buf_ptr + 1) == '\n') { @@ -557,7 +559,7 @@ stop_lit: if (state->in_or_st) state->block_init = 1; #ifdef undef - if (chartype[*buf_ptr] == opchar) { /* we have two char assignment */ + if (chartype[*buf_ptr & 127] == opchar) { /* we have two char assignment */ e_token[-1] = *buf_ptr++; if ((e_token[-1] == '<' || e_token[-1] == '>') && e_token[-1] == *buf_ptr) *e_token++ = *buf_ptr++; From owner-svn-src-head@freebsd.org Sun Jun 3 17:05:56 2018 Return-Path: Delivered-To: svn-src-head@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 25806FE00B5; Sun, 3 Jun 2018 17:05:56 +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 BD5AF6F3C5; Sun, 3 Jun 2018 17:05:55 +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 9C39621696; Sun, 3 Jun 2018 17:05:55 +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 w53H5tJr001659; Sun, 3 Jun 2018 17:05:55 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53H5t26001658; Sun, 3 Jun 2018 17:05:55 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031705.w53H5t26001658@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 17:05:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334569 - 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: 334569 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 17:05:56 -0000 Author: pstef Date: Sun Jun 3 17:05:55 2018 New Revision: 334569 URL: https://svnweb.freebsd.org/changeset/base/334569 Log: indent(1): use errx() instead of abort() Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 17:03:55 2018 (r334568) +++ head/usr.bin/indent/indent.c Sun Jun 3 17:05:55 2018 (r334569) @@ -495,7 +495,7 @@ main(int argc, char **argv) while (*buf_ptr == ' ' || *buf_ptr == '\t') { *sc_end++ = *buf_ptr++; if (sc_end >= &save_com[sc_size]) { - abort(); + errx(1, "input too long"); } } if (buf_ptr >= buf_end) { @@ -1196,7 +1196,7 @@ check_type: bcopy(s_lab + com_start, sc_end, com_end - com_start); sc_end += com_end - com_start; if (sc_end >= &save_com[sc_size]) - abort(); + errx(1, "input too long"); e_lab = s_lab + com_start; while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t')) e_lab--; From owner-svn-src-head@freebsd.org Sun Jun 3 17:07:57 2018 Return-Path: Delivered-To: svn-src-head@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 77E81FE0579; Sun, 3 Jun 2018 17:07:57 +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 2E5B16F5D9; Sun, 3 Jun 2018 17:07:57 +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 0F9CF21699; Sun, 3 Jun 2018 17:07:57 +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 w53H7u3j001773; Sun, 3 Jun 2018 17:07:56 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53H7udd001772; Sun, 3 Jun 2018 17:07:56 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031707.w53H7udd001772@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 17:07:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334570 - 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: 334570 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 17:07:57 -0000 Author: pstef Date: Sun Jun 3 17:07:56 2018 New Revision: 334570 URL: https://svnweb.freebsd.org/changeset/base/334570 Log: indent(1): the check for buffer overflow has to be done before copy Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 17:05:55 2018 (r334569) +++ head/usr.bin/indent/indent.c Sun Jun 3 17:07:56 2018 (r334570) @@ -1193,10 +1193,10 @@ check_type: *sc_end++ = ' '; --line_no; } + if (sc_end - save_com + com_end - com_start > sc_size) + errx(1, "input too long"); bcopy(s_lab + com_start, sc_end, com_end - com_start); sc_end += com_end - com_start; - if (sc_end >= &save_com[sc_size]) - errx(1, "input too long"); e_lab = s_lab + com_start; while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t')) e_lab--; From owner-svn-src-head@freebsd.org Sun Jun 3 17:11:02 2018 Return-Path: Delivered-To: svn-src-head@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 47F37FE0AE1; Sun, 3 Jun 2018 17:11:02 +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 EC5A06F9E7; Sun, 3 Jun 2018 17:11:01 +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 CD214216C3; Sun, 3 Jun 2018 17:11:01 +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 w53HB1oB005542; Sun, 3 Jun 2018 17:11:01 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53HB1vN005541; Sun, 3 Jun 2018 17:11:01 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031711.w53HB1vN005541@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 17:11:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334571 - 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: 334571 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 17:11:02 -0000 Author: pstef Date: Sun Jun 3 17:11:01 2018 New Revision: 334571 URL: https://svnweb.freebsd.org/changeset/base/334571 Log: indent(1): avoid resetting last_bl to a bogus value when reallocating underlying buffer Modified: head/usr.bin/indent/indent_globs.h Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jun 3 17:07:56 2018 (r334570) +++ head/usr.bin/indent/indent_globs.h Sun Jun 3 17:11:01 2018 (r334571) @@ -67,12 +67,17 @@ FILE *output; /* the output file */ if (e_com >= l_com) { \ int nsize = l_com-s_com+400; \ int com_len = e_com - s_com; \ - int blank_pos = last_bl - s_com; \ + int blank_pos; \ + if (last_bl != NULL) \ + blank_pos = last_bl - combuf; \ + else \ + blank_pos = -1; \ combuf = (char *) realloc(combuf, nsize); \ if (combuf == NULL) \ err(1, NULL); \ e_com = combuf + com_len + 1; \ - last_bl = combuf + blank_pos + 1; \ + if (blank_pos > 0) \ + last_bl = combuf + blank_pos; \ l_com = combuf + nsize - 5; \ s_com = combuf + 1; \ } From owner-svn-src-head@freebsd.org Sun Jun 3 17:20:24 2018 Return-Path: Delivered-To: svn-src-head@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 DCB92FE1C0B; Sun, 3 Jun 2018 17:20:23 +0000 (UTC) (envelope-from flo@smeets.xyz) Received: from mail-out.smeets.xyz (mail-out.smeets.xyz [5.9.17.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C4797015A; Sun, 3 Jun 2018 17:20:23 +0000 (UTC) (envelope-from flo@smeets.xyz) Received: from mail.smeets.xyz (mail6 [IPv6:2a01:4f8:160:918a::25:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-out.smeets.xyz (Postfix) with ESMTPS id 26147298DD; Sun, 3 Jun 2018 19:20:16 +0200 (CEST) Received: from amavis.smeets.xyz (amavis.smeets.xyz [IPv6:2a01:4f8:160:918a::aa:4]) by mail.smeets.xyz (Postfix) with ESMTP id DC9C59CC62; Sun, 3 Jun 2018 19:20:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at smeets.xyz Received: from mail.smeets.xyz ([IPv6:2a01:4f8:160:918a::25:3]) by amavis.smeets.xyz (amavis.smeets.xyz [IPv6:2a01:4f8:160:918a::aa:4]) (amavisd-new, port 10025) with ESMTP id km7gqWSgln_d; Sun, 3 Jun 2018 19:20:15 +0200 (CEST) Received: from nibbler-osx.fritz.box (p5DF5CD2D.dip0.t-ipconnect.de [93.245.205.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.smeets.xyz (Postfix) with ESMTPSA id 0954F9CC43; Sun, 3 Jun 2018 19:20:14 +0200 (CEST) Subject: Re: svn commit: r334474 - head/usr.bin/top To: Eitan Adler , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201806010551.w515pfoB090926@repo.freebsd.org> From: Florian Smeets Autocrypt: addr=flo@smeets.xyz; keydata= xsFNBFpyBwsBEADLq0c46orEtbMn4SptX+VJxR1wB4YwaErZme1bqF4nZHIhlRNET22HsHdQ doagaB4uACq0Rj5kHcu614ZnnNkLPyCxWQATx+cbdiFO4/hfT8tAvKnBtiy3awKJ5uGCNO2E zJwXW6KwdDA8XPRySqN8m1yPl+dW0Cls+/vO/QL/6+YLMupmEpSvFxRzAZTQuKyX4+xl+dYI d24JiPd1yfCuDNOY3+OZ3QBMT00u/699N8lUWRtiTwaQMwAOww8r/26YM6/SgcgFuLH2E/CV plY0sDvfoISlAj8agxdomNXfPjCMQ6w5yGZmA+huFpPCVBTi3on/SWgbQO7dLVpN4BNPuScP osCb/dsOg0S74zCClsIU3gdUGh9rwJY00/Ebid6V0R3c1Czwbg8LQedzlGDuXYXmzp6W2ujg r1cqbUD6lUWikUv2IMdCbb8MxYhHLi3GYUs5Xpi+W7vM6T45KbuMr7O/1SjtcGOlNeDvGNgj cDk20fOgPPZ+M6i9vX5Q2oI9HoYaeTiYNwILkBLVP/L40kTo5EkiQOt4OW6BMbylqXPOaQMW uGVbmhCJQpbx8Vo80s2yiBBVWkLkWQIcIm3KZlLldJqKEFpQBWLBE1eFFqboYgAWzFn73CaV 5tihobijMmmOV3a8cI1fI4kREyl3g+8bW+O0u3m3tuzVOpDpjwARAQABzR9GbG9yaWFuIFNt ZWV0cyA8ZmxvQHNtZWV0cy54eXo+wsGXBBMBCgBBAhsDBQkHhh+ABQsJCAcDBRUKCQgLBRYD AgEAAh4BAheAFiEE7LNouHkIv7aRTXJp71uk3NWp88AFAlpyB1gCGQEACgkQ71uk3NWp88DB 8RAAuwXf65kTtVwDAJEFnXQmRx8q/bfV5WWMVVZMM9zMOmLM006PlJlns9vDEwfXkUsTOKpC 9GEREdCVxsqQ/WqYrO0O8yLYRMY0IQ6w2B5cVzvf1DwY6Foc7zOpEgvAt5mCR9BoJ1eHf90K rHYUxf8AaWjJ/CE4EdN4wDvEY23tQ1ov0ReiNZokKfKKRF8rRbBhpwRcRyzV4eah3WvKKyOy PIGKquXG0GWhgty3rfNtion8AomFoQlK0lCq57okQj0HLS3vLTzXexvfWsLc+nLXT8eo87cl MQaYz7h5EjqM0r4FPRmGJ18nQ5wArt5vOf5oRv90RSH3QJLaxVdvt0BCDr2s1J5tTG7gZP/r Kyz9BrPtVvBwiHEW8jhw4lDbV3xIUEVkj4UEsM9XkHrHqd8JiFNZZOPE25VkuAeoeyB3j9km fZczF/f41cHp5v5RyTavta9QWA6Q07ARPu2JCBMMN+lJ9G/Ok8JlUgSGOwHZ+3R7jjvDMEFh 4DJhF2B77DdLxpLVJS0h5cS8WM6a/jm1Sk6DAi4bgksetvdyE/N/yxQmHokdKYW2LGDgd7cw dM2X660avFRe4ogZ0PeLRimPbyJuSN2+hZC/fy5jEv5PvZ+6spuwYMYDClefRpvBDqmCCxtf M1LNFRiXjdYvUdHvQ3facDzNpOkPLp0VexjJJ2HOwU0EWnIHCwEQANHrOm5vydK/ij1zkDyL Zzbogk5zjMh6oAr3cH4oGbJHPLlyFZTCVBYUwD4kh6NV1sKuZOeX/aygyVg1RyLulnzsc6Yj XOIxlqhqQwGI8k8ssAIpMSf029781CNF2HC42CrJeHtXNONDNOjsMuoxzga9zLQCh4jLTlE/ TUJo6KVABWBVRtTVh2Z77pKtN7j2NPFBHvp7K0WHfV+TYnlsgjhUA0ACZnUdHS2YRzBhCzzQ eludxBz54S9xbUq1mfZfVx8AbAGXF2zxo68nvvAAJn48HiBS3dMhCGYJDdZdja6QdUFPiemi nOxwkUzCqmKxm+Aj7USue1SbZZqJxmMI1eF4Ork/BJJI74Z/FnJgYR4UkEiD3J/KUocQCIH3 daB1+/CXlh99Ib7AP+QGuKk3vnNHh7VBq3E+VAiM5LU0BmgW+cdRPHkiwM7sDa2VnV3VqvV7 QmoMKnHFzUB6Nn8uE+iakp5J81Pr68kDOq7kLW3UnGmg1PUqbsnCaTimJb3JAYWzOW/9CYcP lbAdIqi+wH7MOoeL+PA99A3kW/881rGmeOYFzzrsNVLtea+AJfXtp4LN5gOVIPIpovCNSVXX EKgl7a4vjUGzVBzrH7PzT+k4XUEQwNCACfGZxEExtny19bjvumZ0rv+AEAHvsWSKXHUVJzIN jqd9UioaEbKGAPlPABEBAAHCwXwEGAEKACYWIQTss2i4eQi/tpFNcmnvW6Tc1anzwAUCWnIH CwIbDAUJB4YfgAAKCRDvW6Tc1anzwM/8D/9IbDzMvsz4O+Gcz1oUx4IMxbQDw99qgJexR5cj W207GkRnKVJ0zqx7Xc+U3AytniuwqHEXeV4qIqP6h14pEuCqdRJ+fSm65rB4+ZdeM2Y5YYvU BByOM78Mbs6SZy2k5X0EL5FXjNVIMOv2ImblyeRWhWK6gCfc/l7kV1EYVx9LV3umsc7K+ceZ lfE1U8hWbie8r7tl3V9ggF2g1cyc9ru0qW3sg8D4vNTS1uwdqeccKRc3osrVw4WrW1nGxTmT TCqVYGHjF2sANF9o1JB93hoXz8lydmDdhJ/62/XHapeT1FB8m7gulinM33VeOCCjN+dUgLQk 5tAGg+iHQWhC4Q/o4m0OqfdcSYdhCJ7h2I4GwOoGaxzoXqEL47Guxz+zE4osAFP5JLxCTbi2 x5sduCvxx3WbO95kZJKp7D0BIKpbKcfkyWse53YBI9wSrkIil+InnqvSDzU9nMvIyKSjv4ui wvZi1HY7tPiir/P2naZaiQ1SAM0KLP3g123WcnhRKo++ZRHhay5/70SKGdxEmKf3nld8xNCs 9EIWOTpRaqc9+zOcD1zVTZwnwgBrnPqzfPW9+d7FwAP1MdJbrROuC2bfzNZyoR4uHAnDOyNW wGSmShv7hhdettO8dJblneTY8vhzxo36pWmojEdgghXNw9Ji7kyInAmWq9kwV5Vou3ZNFw== Message-ID: Date: Sun, 3 Jun 2018 19:19:47 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <201806010551.w515pfoB090926@repo.freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5OOJnSK4dcKaDFl5MFjvOoT7UHV879xib" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 17:20:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5OOJnSK4dcKaDFl5MFjvOoT7UHV879xib Content-Type: multipart/mixed; boundary="RKhASXiOaIqqvJvyxgaZGBxK0Jk3ykQmh"; protected-headers="v1" From: Florian Smeets To: Eitan Adler , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: Subject: Re: svn commit: r334474 - head/usr.bin/top References: <201806010551.w515pfoB090926@repo.freebsd.org> In-Reply-To: <201806010551.w515pfoB090926@repo.freebsd.org> --RKhASXiOaIqqvJvyxgaZGBxK0Jk3ykQmh Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 01.06.18 07:51, Eitan Adler wrote: > Author: eadler > Date: Fri Jun 1 05:51:40 2018 > New Revision: 334474 > URL: https://svnweb.freebsd.org/changeset/base/334474 >=20 > Log: > top(1): Display of TID when using 'H' flag > =20 > Some users prefer seeing the TID when viewing individual threads. Thi= s > makes sense as the PID will be the same for multiple entries. An atte= mpt > was made to include both, but there is insufficient room. As such, us= ing > the TID. > =20 > While here, rename the header variables to be more understandable. > =20 > Discussed with: mmacy > Reported on: 2009-10-07 >=20 Hi, I think this is a mistake. The 'H' flag should keep the PID, AFAIK you cannot use the TID anywhere in top in contrast to the PID. I usually start top with the 'S' and 'H' flags. Now I cannot use 'k' to kill a process in that view, as I don't see the PID. IMHO showing TIDs should be a separate flag, 'h' maybe, as this commit changes current/expected behavior (POLA?). Also, this is not documented in the man page. Florian --RKhASXiOaIqqvJvyxgaZGBxK0Jk3ykQmh-- --5OOJnSK4dcKaDFl5MFjvOoT7UHV879xib Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEE7LNouHkIv7aRTXJp71uk3NWp88AFAlsUI05fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEVD QjM2OEI4NzkwOEJGQjY5MTRENzI2OUVGNUJBNERDRDVBOUYzQzAACgkQ71uk3NWp 88DseQ/9FmSsirHQ4KDv9uvNpf1zXss8dzO0VRfr1BxTwEqz8ketK6vAi04olR4a TWdHZ+ril/ybAwzcuZkUY8PXdoWZQmmQyaB6L2fQkCO8GV6Br7/8zH0NI8Avxu/8 1Y0YKpKPA+YFo0Iv0aQsqY2aeL05FF9y/selp2KKoWn2jgNhz0AFDqEQtOhd1ZOt IuiY/M7qknIQs/Z3Qv8VKG1ArYS5Kd42+7uAg+C3wEDGgXxVHuz6IvBNIRSy9ItD BlP1Fwa7+PXxJNpASRDeTQMGuNnSRIagb8Z86xPJPYPxLfjgaRFfnIozQ5Dux2MD RHV/N/olZ5mIciPDcR7E0DCGgXzzPmjxcCiVUWjaUojEM+OYeJXogduKSt2F58nr JKmWlYXz4+QKb5+1rGnn/afPuZUFtPSEu4irvZ2XgE2vhiRpWj5RCuFq3sanD1mH qBMpkrhSI/3QCUWpK2KT2jSKtNJQUXpfluqnSgaDzdvR44mbO2F4z0Kt3dHkXEXT zRaZ3eboqeMiPQvBkzt15SwaQVyXpNdgS+JzkLf+IObyQmTeaO7hvlUXs68VqJD2 D3NfBiaL+lR5VE12KUcUxk6Q5Z78OoDfP3NtmrAc9aRV9PQOP11pRMZ505HhcPqy abwwAofgF9dXTDClelbvWnvYuU7xls/fgsEJLtYtXr3+pCMNCT4= =6hLe -----END PGP SIGNATURE----- --5OOJnSK4dcKaDFl5MFjvOoT7UHV879xib-- From owner-svn-src-head@freebsd.org Sun Jun 3 17:55:53 2018 Return-Path: Delivered-To: svn-src-head@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 876B9FE6086; Sun, 3 Jun 2018 17:55:53 +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 3AB7C71D93; Sun, 3 Jun 2018 17:55:53 +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 F1F7321EC6; Sun, 3 Jun 2018 17:55:52 +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 w53HtqYu026646; Sun, 3 Jun 2018 17:55:52 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53Htp6b026637; Sun, 3 Jun 2018 17:55:51 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031755.w53Htp6b026637@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 17:55:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334574 - 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: 334574 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 17:55:53 -0000 Author: pstef Date: Sun Jun 3 17:55:50 2018 New Revision: 334574 URL: https://svnweb.freebsd.org/changeset/base/334574 Log: indent(1): remove troff output support The troff output in indent was invented at Sun and the online documentation for some post-SunOS operating system includes this: The usual way to get a troffed listing is with the command indent -troff program.c | troff -mindent The indent manual page in FreeBSD 1.0 already lacks that information and troff -mindent complains about not being able to find the macro file. It seems that the file did exist on SunOS and was supposed to be imported into 4.3BSD together with the feature, but that has never happened. Removal of troff output support simplifies a lot of indent's code. vgrind(1) seems to be a promising replacement. Modified: head/usr.bin/indent/args.c head/usr.bin/indent/indent.1 head/usr.bin/indent/indent.c head/usr.bin/indent/indent.h head/usr.bin/indent/indent_globs.h head/usr.bin/indent/io.c head/usr.bin/indent/lexi.c head/usr.bin/indent/pr_comment.c Modified: head/usr.bin/indent/args.c ============================================================================== --- head/usr.bin/indent/args.c Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/args.c Sun Jun 3 17:55:50 2018 (r334574) @@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$"); #define PRO_SPECIAL 1 /* special case */ #define PRO_BOOL 2 /* boolean */ #define PRO_INT 3 /* integer */ -#define PRO_FONT 4 /* troff font */ /* profile specials for booleans */ #define ON 1 /* turn it on */ @@ -119,15 +118,9 @@ struct pro { {"d", PRO_INT, 0, 0, &ps.unindent_displace}, {"eei", PRO_BOOL, false, ON, &extra_expression_indent}, {"ei", PRO_BOOL, true, ON, &ps.else_if}, - {"fbc", PRO_FONT, 0, 0, (int *) &blkcomf}, {"fbs", PRO_BOOL, true, ON, &function_brace_split}, - {"fbx", PRO_FONT, 0, 0, (int *) &boxcomf}, - {"fb", PRO_FONT, 0, 0, (int *) &bodyf}, {"fc1", PRO_BOOL, true, ON, &format_col1_comments}, {"fcb", PRO_BOOL, true, ON, &format_block_comments}, - {"fc", PRO_FONT, 0, 0, (int *) &scomf}, - {"fk", PRO_FONT, 0, 0, (int *) &keywordf}, - {"fs", PRO_FONT, 0, 0, (int *) &stringf}, {"ip", PRO_BOOL, true, ON, &ps.indent_parameters}, {"i", PRO_INT, 8, 0, &ps.ind_size}, {"lc", PRO_INT, 0, 0, &block_comment_max_col}, @@ -167,7 +160,6 @@ struct pro { {"st", PRO_SPECIAL, 0, STDIN, 0}, {"ta", PRO_BOOL, false, ON, &auto_typedefs}, {"ts", PRO_INT, 8, 0, &tabsize}, - {"troff", PRO_BOOL, false, ON, &troff}, {"ut", PRO_BOOL, true, ON, &use_tabs}, {"v", PRO_BOOL, false, ON, &verbose}, /* whew! */ @@ -259,7 +251,7 @@ set_defaults(void) */ ps.case_indent = 0.0; /* -cli0.0 */ for (p = pro; p->p_name; p++) - if (p->p_type != PRO_SPECIAL && p->p_type != PRO_FONT) + if (p->p_type != PRO_SPECIAL) *p->p_obj = p->p_default; } @@ -326,10 +318,6 @@ found: errx(1, "%s: ``%s'' requires a parameter", option_source, p->p_name); } *p->p_obj = atoi(param_start); - break; - - case PRO_FONT: - parsefont((struct fstate *) p->p_obj, param_start); break; default: Modified: head/usr.bin/indent/indent.1 ============================================================================== --- head/usr.bin/indent/indent.1 Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/indent.1 Sun Jun 3 17:55:50 2018 (r334574) @@ -84,7 +84,6 @@ .Ek .Op Fl \&st .Op Fl \&ta -.Op Fl troff .Op Fl ts Ns Ar n .Op Fl U Ns Ar file .Op Fl ut | Fl nut @@ -453,16 +452,6 @@ language and cannot find all instances of .Ic typedef . -.It Fl troff -Causes -.Nm -to format the program for processing by -.Xr troff 1 . -It will produce a fancy -listing in much the same spirit as -.Xr vgrind 1 . -If the output file is not specified, the default is standard output, -rather than formatting in place. .It Fl ts Ns Ar n Assumed distance between tab stops. The default is 8. Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/indent.c Sun Jun 3 17:55:50 2018 (r334574) @@ -240,7 +240,7 @@ main(int argc, char **argv) if (input == NULL) input = stdin; if (output == NULL) { - if (troff || input == stdin) + if (input == stdin) output = stdout; else { out_name = in_name; @@ -260,26 +260,6 @@ main(int argc, char **argv) if (ps.com_ind <= 1) ps.com_ind = 2; /* dont put normal comments before column 2 */ - if (troff) { - if (bodyf.font[0] == 0) - parsefont(&bodyf, "R"); - if (scomf.font[0] == 0) - parsefont(&scomf, "I"); - if (blkcomf.font[0] == 0) - blkcomf = scomf, blkcomf.size += 2; - if (boxcomf.font[0] == 0) - boxcomf = blkcomf; - if (stringf.font[0] == 0) - parsefont(&stringf, "L"); - if (keywordf.font[0] == 0) - parsefont(&keywordf, "B"); - writefdef(&bodyf, 'B'); - writefdef(&scomf, 'C'); - writefdef(&blkcomf, 'L'); - writefdef(&boxcomf, 'X'); - writefdef(&stringf, 'S'); - writefdef(&keywordf, 'K'); - } if (block_comment_max_col <= 0) block_comment_max_col = max_col; if (ps.local_decl_indent < 0) /* if not specified by user, set this */ @@ -307,15 +287,7 @@ main(int argc, char **argv) if (col > ps.ind_size) ps.ind_level = ps.i_l_follow = col / ps.ind_size; } - if (troff) { - const char *p = in_name, - *beg = in_name; - while (*p) - if (*p++ == '/') - beg = p; - fprintf(output, ".Fn \"%s\"\n", beg); - } /* * START OF MAIN LOOP */ @@ -596,13 +568,7 @@ check_type: if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent && ps.procname[0] == '\0' && ps.paren_level == 0) { /* function pointer declarations */ - if (troff) { - sprintf(e_code, "\n.Du %dp+\200p \"%s\"\n", dec_ind * 7, token); - e_code += strlen(e_code); - } - else { - indent_declaration(dec_ind, tabs_to_var); - } + indent_declaration(dec_ind, tabs_to_var); ps.dumped_decl_indent = true; } else if (ps.want_blank && *token != '[' && @@ -614,8 +580,7 @@ check_type: ps.keyword + Bill_Shannon > 2)) *e_code++ = ' '; ps.want_blank = false; - if (!troff) - *e_code++ = token[0]; + *e_code++ = token[0]; ps.paren_indents[ps.p_l_follow - 1] = count_spaces_until(1, s_code, e_code) - 1; if (sp_sw && ps.p_l_follow == 1 && extra_expression_indent && ps.paren_indents[0] < 2 * ps.ind_size) @@ -673,33 +638,22 @@ check_type: if (!ps.dumped_decl_indent && ps.in_decl && !ps.block_init && ps.procname[0] == '\0' && ps.paren_level == 0) { /* pointer declarations */ - if (troff) { - if (ps.want_blank) - *e_code++ = ' '; - sprintf(e_code, "\n.Du %dp+\200p \"%s\"\n", dec_ind * 7, - token); - e_code += strlen(e_code); - } - else { - /* if this is a unary op in a declaration, we should - * indent this token */ - for (i = 0; token[i]; ++i) - /* find length of token */; - indent_declaration(dec_ind - i, tabs_to_var); - } + + /* + * if this is a unary op in a declaration, we should indent + * this token + */ + for (i = 0; token[i]; ++i) + /* find length of token */; + indent_declaration(dec_ind - i, tabs_to_var); ps.dumped_decl_indent = true; } else if (ps.want_blank) *e_code++ = ' '; - { - const char *res = token; - if (troff && token[0] == '-' && token[1] == '>') - res = "\\(->"; - for (t_ptr = res; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; - } + for (t_ptr = token; *t_ptr; ++t_ptr) { + CHECK_SIZE_CODE; + *e_code++ = *t_ptr; } ps.want_blank = false; break; @@ -707,34 +661,9 @@ check_type: case binary_op: /* any binary operation */ if (ps.want_blank) *e_code++ = ' '; - { - const char *res = token; - - if (troff) - switch (token[0]) { - case '<': - if (token[1] == '=') - res = "\\(<="; - break; - case '>': - if (token[1] == '=') - res = "\\(>="; - break; - case '!': - if (token[1] == '=') - res = "\\(!="; - break; - case '|': - if (token[1] == '|') - res = "\\(br\\(br"; - else if (token[1] == 0) - res = "\\(br"; - break; - } - for (t_ptr = res; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; /* move the operator */ - } + for (t_ptr = token; *t_ptr; ++t_ptr) { + CHECK_SIZE_CODE; + *e_code++ = *t_ptr; /* move the operator */ } ps.want_blank = true; break; @@ -1044,14 +973,7 @@ check_type: else if (!ps.block_init && !ps.dumped_decl_indent && ps.paren_level == 0) { /* if we are in a declaration, we * must indent identifier */ - - if (troff) { - if (ps.want_blank) - *e_code++ = ' '; - sprintf(e_code, "\n.De %dp+\200p\n", dec_ind * 7); - e_code += strlen(e_code); - } else - indent_declaration(dec_ind, tabs_to_var); + indent_declaration(dec_ind, tabs_to_var); ps.dumped_decl_indent = true; ps.want_blank = false; } @@ -1066,20 +988,10 @@ check_type: copy_id: if (ps.want_blank) *e_code++ = ' '; - if (troff && ps.keyword) { - e_code = chfont(&bodyf, &keywordf, e_code); - for (t_ptr = token; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = keywordf.allcaps && islower((unsigned char)*t_ptr) - ? toupper(*t_ptr) : *t_ptr; - } - e_code = chfont(&keywordf, &bodyf, e_code); + for (t_ptr = token; *t_ptr; ++t_ptr) { + CHECK_SIZE_CODE; + *e_code++ = *t_ptr; } - else - for (t_ptr = token; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; - } if (type_code != funcname) ps.want_blank = true; break; @@ -1145,8 +1057,6 @@ check_type: fill_buffer(); switch (*e_lab++) { case BACKSLASH: - if (troff) - *e_lab++ = BACKSLASH; if (!in_comment) { *e_lab++ = *buf_ptr++; if (buf_ptr >= buf_end) Modified: head/usr.bin/indent/indent.h ============================================================================== --- head/usr.bin/indent/indent.h Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/indent.h Sun Jun 3 17:55:50 2018 (r334574) @@ -43,9 +43,7 @@ void diag4(int, const char *, int, int); void dump_line(void); void fill_buffer(void); void parse(int); -void parsefont(struct fstate *, const char *); void pr_comment(void); void set_defaults(void); void set_option(char *); void set_profile(const char *); -void writefdef(struct fstate *f, int); Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/indent_globs.h Sun Jun 3 17:55:50 2018 (r334574) @@ -166,7 +166,6 @@ int cuddle_else; /* true if else should cuddle int star_comment_cont; /* true iff comment continuation lines should * have stars at the beginning of each line. */ int comment_delimiter_on_blankline; -int troff; /* true iff were generating troff input */ int procnames_start_line; /* if true, the names of procedures * being defined get placed in column * 1 (ie. a newline is placed between @@ -218,29 +217,10 @@ int auto_typedefs; /* set true to recognize ident int space_after_cast; /* "b = (int) a" vs "b = (int)a" */ int tabsize; /* the size of a tab */ -/* -troff font state information */ - -struct fstate { - char font[4]; - char size; - int allcaps:1; -} __aligned(sizeof(int)); -char *chfont(struct fstate *, struct fstate *, char *); - -struct fstate - keywordf, /* keyword font */ - stringf, /* string font */ - boxcomf, /* Box comment font */ - blkcomf, /* Block comment font */ - scomf, /* Same line comment font */ - bodyf; /* major body font */ - - #define STACKSIZE 256 struct parser_state { int last_token; - struct fstate cfont; /* Current font */ 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 */ Modified: head/usr.bin/indent/io.c ============================================================================== --- head/usr.bin/indent/io.c Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/io.c Sun Jun 3 17:55:50 2018 (r334574) @@ -68,13 +68,6 @@ dump_line(void) static int not_first_line; if (ps.procname[0]) { - if (troff) { - if (comment_open) { - comment_open = 0; - fprintf(output, ".*/\n"); - } - fprintf(output, ".Pr \"%s\"\n", ps.procname); - } ps.ind_level = 0; ps.procname[0] = 0; } @@ -163,99 +156,38 @@ dump_line(void) putc(*p, output); cur_col = count_spaces(cur_col, s_code); } - if (s_com != e_com) { - if (troff) { - int all_here = 0; - char *p; + if (s_com != e_com) { /* print comment, if any */ + int target = ps.com_col; + char *com_st = s_com; - if (e_com[-1] == '/' && e_com[-2] == '*') - e_com -= 2, all_here++; - while (e_com > s_com && e_com[-1] == ' ') - e_com--; - *e_com = 0; - p = s_com; - while (*p == ' ') - p++; - if (p[0] == '/' && p[1] == '*') - p += 2, all_here++; - else if (p[0] == '*') - p += p[1] == '/' ? 2 : 1; - while (*p == ' ') - p++; - if (*p == 0) - goto inhibit_newline; - if (comment_open < 2 && ps.box_com) { - comment_open = 0; - fprintf(output, ".*/\n"); - } - if (comment_open == 0) { - if ('a' <= *p && *p <= 'z') - *p = *p + 'A' - 'a'; - if (e_com - p < 50 && all_here == 2) { - char *follow = p; - fprintf(output, "\n.nr C! \\w\1"); - while (follow < e_com) { - switch (*follow) { - case '\n': - putc(' ', output); - case 1: - break; - case '\\': - putc('\\', output); - /* add a backslash to escape the '\' */ - default: - putc(*follow, output); - } - follow++; - } - putc(1, output); - } - fprintf(output, "\n./* %dp %d %dp\n", - ps.com_col * 7, - (s_code != e_code || s_lab != e_lab) - ps.box_com, - target_col * 7); - } - comment_open = 1 + ps.box_com; - while (*p) { - if (*p == BACKSLASH) - putc(BACKSLASH, output); - putc(*p++, output); - } + target += ps.comment_delta; + while (*com_st == '\t') /* consider original indentation in + * case this is a box comment */ + com_st++, target += tabsize; + while (target <= 0) + if (*com_st == ' ') + target++, com_st++; + else if (*com_st == '\t') + target = tabsize * (1 + (target - 1) / tabsize) + 1, com_st++; + else + target = 1; + if (cur_col > target) { /* if comment can't fit on this line, + * put it on next line */ + putc('\n', output); + cur_col = 1; + ++ps.out_lines; } - else { /* print comment, if any */ - int target = ps.com_col; - char *com_st = s_com; - - target += ps.comment_delta; - while (*com_st == '\t') /* consider original indentation in - * case this is a box comment */ - com_st++, target += tabsize; - while (target <= 0) - if (*com_st == ' ') - target++, com_st++; - else if (*com_st == '\t') - target = tabsize * (1 + (target - 1) / tabsize) + 1, com_st++; - else - target = 1; - if (cur_col > target) { /* if comment can't fit on this line, - * put it on next line */ - putc('\n', output); - cur_col = 1; - ++ps.out_lines; - } - while (e_com > com_st && isspace((unsigned char)e_com[-1])) - e_com--; - (void)pad_output(cur_col, target); - fwrite(com_st, e_com - com_st, 1, output); - ps.comment_delta = ps.n_comment_delta; - ++ps.com_lines; /* count lines with comments */ - } + while (e_com > com_st && isspace((unsigned char)e_com[-1])) + e_com--; + (void)pad_output(cur_col, target); + fwrite(com_st, e_com - com_st, 1, output); + ps.comment_delta = ps.n_comment_delta; + ++ps.com_lines; /* count lines with comments */ } if (ps.use_ff) putc('\014', output); else putc('\n', output); -inhibit_newline: ++ps.out_lines; if (ps.just_saw_decl == 1 && blanklines_after_declarations) { prefix_blankline_requested = 1; @@ -460,26 +392,22 @@ pad_output(int current, int target) /* current: the current column value */ /* target: position we want it at */ { + int curr; /* internal column pointer */ - if (troff) - fprintf(output, "\\h'|%dp'", (target - 1) * 7); - else { - int curr; /* internal column pointer */ + if (current >= target) + return (current); /* line is already long enough */ + curr = current; + if (use_tabs) { + int tcur; - if (current >= target) - return (current); /* line is already long enough */ - curr = current; - if (use_tabs) { - int tcur; - - while ((tcur = tabsize * (1 + (curr - 1) / tabsize) + 1) <= target) { - putc('\t', output); - curr = tcur; - } - } - while (curr++ < target) - putc(' ', output); /* pad with final blanks */ + while ((tcur = tabsize * (1 + (curr - 1) / tabsize) + 1) <= target) { + putc('\t', output); + curr = tcur; + } } + while (curr++ < target) + putc(' ', output); /* pad with final blanks */ + return (target); } @@ -593,77 +521,3 @@ diag2(int level, const char *msg) } } -void -writefdef(struct fstate *f, int nm) -{ - fprintf(output, ".ds f%c %s\n.nr s%c %d\n", - nm, f->font, nm, f->size); -} - -char * -chfont(struct fstate *of, struct fstate *nf, char *s) -{ - if (of->font[0] != nf->font[0] - || of->font[1] != nf->font[1]) { - *s++ = '\\'; - *s++ = 'f'; - if (nf->font[1]) { - *s++ = '('; - *s++ = nf->font[0]; - *s++ = nf->font[1]; - } - else - *s++ = nf->font[0]; - } - if (nf->size != of->size) { - *s++ = '\\'; - *s++ = 's'; - if (nf->size < of->size) { - *s++ = '-'; - *s++ = '0' + of->size - nf->size; - } - else { - *s++ = '+'; - *s++ = '0' + nf->size - of->size; - } - } - return s; -} - -void -parsefont(struct fstate *f, const char *s0) -{ - const char *s = s0; - int sizedelta = 0; - - memset(f, '\0', sizeof(*f)); - while (*s) { - if (isdigit((unsigned char)*s)) - f->size = f->size * 10 + *s - '0'; - else if (isupper((unsigned char)*s)) - if (f->font[0]) - f->font[1] = *s; - else - f->font[0] = *s; - else if (*s == 'c') - f->allcaps = 1; - else if (*s == '+') - sizedelta++; - else if (*s == '-') - sizedelta--; - else { - errx(1, "bad font specification: %s", s0); - } - s++; - } - if (f->font[0] == 0) - f->font[0] = 'R'; - if (bodyf.size == 0) - bodyf.size = 11; - if (f->size == 0) - f->size = bodyf.size + sizedelta; - else if (sizedelta > 0) - f->size += bodyf.size; - else - f->size = bodyf.size - f->size; -} Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/lexi.c Sun Jun 3 17:55:50 2018 (r334574) @@ -418,12 +418,6 @@ lexi(struct parser_state *state) case '\'': /* start of quoted character */ case '"': /* start of string */ qchar = *token; - if (troff) { - e_token[-1] = '`'; - if (qchar == '"') - *e_token++ = '`'; - e_token = chfont(&bodyf, &stringf, e_token); - } do { /* copy the string */ while (1) { /* move one character or [/] */ if (*buf_ptr == '\n') { @@ -439,11 +433,6 @@ lexi(struct parser_state *state) if (*e_token == BACKSLASH) { /* if escape, copy extra char */ if (*buf_ptr == '\n') /* check for escaped newline */ ++line_no; - if (troff) { - *++e_token = BACKSLASH; - if (*buf_ptr == BACKSLASH) - *++e_token = BACKSLASH; - } *++e_token = *buf_ptr++; ++e_token; /* we must increment this again because we * copied two chars */ @@ -454,11 +443,6 @@ lexi(struct parser_state *state) break; /* we copied one character */ } /* end of while (1) */ } while (*e_token++ != qchar); - if (troff) { - e_token = chfont(&stringf, &bodyf, e_token - 1); - if (qchar == '"') - *e_token++ = '\''; - } stop_lit: code = ident; break; Modified: head/usr.bin/indent/pr_comment.c ============================================================================== --- head/usr.bin/indent/pr_comment.c Sun Jun 3 17:49:45 2018 (r334573) +++ head/usr.bin/indent/pr_comment.c Sun Jun 3 17:55:50 2018 (r334574) @@ -201,9 +201,6 @@ pr_comment(void) *e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; } - if (troff) - adj_max_col = 80; - /* Start to copy the comment */ while (1) { /* this loop will go until the comment is From owner-svn-src-head@freebsd.org Sun Jun 3 18:19:43 2018 Return-Path: Delivered-To: svn-src-head@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 40D74FE8DEC; Sun, 3 Jun 2018 18:19:43 +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 E3F61738B8; Sun, 3 Jun 2018 18:19:42 +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 AABE322207; Sun, 3 Jun 2018 18:19:42 +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 w53IJgHN038358; Sun, 3 Jun 2018 18:19:42 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53IJfII038354; Sun, 3 Jun 2018 18:19:41 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031819.w53IJfII038354@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 18:19:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334576 - 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: 334576 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 18:19:43 -0000 Author: pstef Date: Sun Jun 3 18:19:41 2018 New Revision: 334576 URL: https://svnweb.freebsd.org/changeset/base/334576 Log: indent(1): improve CHECK_SIZE_ macros Rewrite the macros so that they take a parameter. Consumers use it to signal how much room in the buffer they need; this lets them do that once when required space is known instead of doing the check once every loop step. Also take the parameter value into consideration when resizing the buffer; the requested space may be larger than the constant 400 bytes that the previous version used - now it's the sum of those two values. On the consumer side, don't copy strings byte by byte - use memcpy(). Deduplicate code that copied base 2, base 8 and base 16 literals. Don't advance the e_token pointer once the token has been copied into s_token. This allows easy calculation of the token's length. Modified: head/usr.bin/indent/indent.c head/usr.bin/indent/indent_globs.h head/usr.bin/indent/lexi.c head/usr.bin/indent/pr_comment.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 18:17:07 2018 (r334575) +++ head/usr.bin/indent/indent.c Sun Jun 3 18:19:41 2018 (r334576) @@ -520,11 +520,12 @@ check_type: * '}' */ if (s_com != e_com) { /* the turkey has embedded a comment * in a line. fix it */ + int len = e_com - s_com; + + CHECK_SIZE_CODE(len + 3); *e_code++ = ' '; - for (t_ptr = s_com; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; - } + memcpy(e_code, s_com, len); + e_code += len; *e_code++ = ' '; *e_code = '\0'; /* null terminate code sect */ ps.want_blank = false; @@ -540,7 +541,10 @@ check_type: /*-----------------------------------------------------*\ | do switch on type of token scanned | \*-----------------------------------------------------*/ - CHECK_SIZE_CODE; + CHECK_SIZE_CODE(3); /* maximum number of increments of e_code + * before the next CHECK_SIZE_CODE or + * dump_line() is 2. After that there's the + * final increment for the null character. */ switch (type_code) { /* now, decide what to do with the token */ case form_feed: /* found a form feed in line */ @@ -651,19 +655,25 @@ check_type: else if (ps.want_blank) *e_code++ = ' '; - for (t_ptr = token; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; + { + int len = e_token - s_token; + + CHECK_SIZE_CODE(len); + memcpy(e_code, token, len); + e_code += len; } ps.want_blank = false; break; case binary_op: /* any binary operation */ - if (ps.want_blank) - *e_code++ = ' '; - for (t_ptr = token; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; /* move the operator */ + { + int len = e_token - s_token; + + CHECK_SIZE_CODE(len + 1); + if (ps.want_blank) + *e_code++ = ' '; + memcpy(e_code, token, len); + e_code += len; } ps.want_blank = true; break; @@ -704,13 +714,20 @@ check_type: } ps.in_stmt = false; /* seeing a label does not imply we are in a * stmt */ - for (t_ptr = s_code; *t_ptr; ++t_ptr) - *e_lab++ = *t_ptr; /* turn everything so far into a label */ - e_code = s_code; - *e_lab++ = ':'; - *e_lab++ = ' '; - *e_lab = '\0'; + /* + * turn everything so far into a label + */ + { + int len = e_code - s_code; + CHECK_SIZE_LAB(len + 3); + memcpy(e_lab, s_code, len); + e_lab += len; + *e_lab++ = ':'; + *e_lab++ = ' '; + *e_lab = '\0'; + e_code = s_code; + } force_nl = ps.pcase = scase; /* ps.pcase will be used by * dump_line to decide how to * indent the label. force_nl @@ -986,22 +1003,28 @@ check_type: parse(hd_type); } copy_id: - if (ps.want_blank) - *e_code++ = ' '; - for (t_ptr = token; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; + { + int len = e_token - s_token; + + CHECK_SIZE_CODE(len + 1); + if (ps.want_blank) + *e_code++ = ' '; + memcpy(e_code, s_token, len); + e_code += len; } if (type_code != funcname) ps.want_blank = true; break; case strpfx: - if (ps.want_blank) - *e_code++ = ' '; - for (t_ptr = token; *t_ptr; ++t_ptr) { - CHECK_SIZE_CODE; - *e_code++ = *t_ptr; + { + int len = e_token - s_token; + + CHECK_SIZE_CODE(len + 1); + if (ps.want_blank) + *e_code++ = ' '; + memcpy(e_code, token, len); + e_code += len; } ps.want_blank = false; break; @@ -1038,6 +1061,7 @@ check_type: (s_lab != e_lab) || (s_code != e_code)) dump_line(); + CHECK_SIZE_LAB(1); *e_lab++ = '#'; /* move whole line to 'label' buffer */ { int in_comment = 0; @@ -1051,7 +1075,7 @@ check_type: fill_buffer(); } while (*buf_ptr != '\n' || (in_comment && !had_eof)) { - CHECK_SIZE_LAB; + CHECK_SIZE_LAB(2); *e_lab = *buf_ptr++; if (buf_ptr >= buf_end) fill_buffer(); @@ -1119,6 +1143,7 @@ check_type: buf_end = sc_end; sc_end = NULL; } + CHECK_SIZE_LAB(1); *e_lab = '\0'; /* null terminate line */ ps.pcase = false; } @@ -1249,14 +1274,14 @@ indent_declaration(int cur_dec_ind, int tabs_to_var) if (tabs_to_var) { int tpos; + CHECK_SIZE_CODE(cur_dec_ind / tabsize); while ((tpos = tabsize * (1 + pos / tabsize)) <= cur_dec_ind) { - CHECK_SIZE_CODE; *e_code++ = '\t'; pos = tpos; } } + CHECK_SIZE_CODE(cur_dec_ind - pos + 1); while (pos < cur_dec_ind) { - CHECK_SIZE_CODE; *e_code++ = ' '; pos++; } Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jun 3 18:17:07 2018 (r334575) +++ head/usr.bin/indent/indent_globs.h Sun Jun 3 18:19:41 2018 (r334576) @@ -52,9 +52,9 @@ FILE *input; /* the fid for the input file */ FILE *output; /* the output file */ -#define CHECK_SIZE_CODE \ - if (e_code >= l_code) { \ - int nsize = l_code-s_code+400; \ +#define CHECK_SIZE_CODE(desired_size) \ + if (e_code + (desired_size) >= l_code) { \ + int nsize = l_code-s_code + 400 + desired_size; \ int code_len = e_code-s_code; \ codebuf = (char *) realloc(codebuf, nsize); \ if (codebuf == NULL) \ @@ -63,9 +63,9 @@ FILE *output; /* the output file */ l_code = codebuf + nsize - 5; \ s_code = codebuf + 1; \ } -#define CHECK_SIZE_COM \ - if (e_com >= l_com) { \ - int nsize = l_com-s_com+400; \ +#define CHECK_SIZE_COM(desired_size) \ + if (e_com + (desired_size) >= l_com) { \ + int nsize = l_com-s_com + 400 + desired_size; \ int com_len = e_com - s_com; \ int blank_pos; \ if (last_bl != NULL) \ @@ -81,9 +81,9 @@ FILE *output; /* the output file */ l_com = combuf + nsize - 5; \ s_com = combuf + 1; \ } -#define CHECK_SIZE_LAB \ - if (e_lab >= l_lab) { \ - int nsize = l_lab-s_lab+400; \ +#define CHECK_SIZE_LAB(desired_size) \ + if (e_lab + (desired_size) >= l_lab) { \ + int nsize = l_lab-s_lab + 400 + desired_size; \ int label_len = e_lab - s_lab; \ labbuf = (char *) realloc(labbuf, nsize); \ if (labbuf == NULL) \ @@ -92,9 +92,9 @@ FILE *output; /* the output file */ l_lab = labbuf + nsize - 5; \ s_lab = labbuf + 1; \ } -#define CHECK_SIZE_TOKEN \ - if (e_token >= l_token) { \ - int nsize = l_token-s_token+400; \ +#define CHECK_SIZE_TOKEN(desired_size) \ + if (e_token + (desired_size) >= l_token) { \ + int nsize = l_token-s_token + 400 + desired_size; \ int token_len = e_token - s_token; \ tokenbuf = (char *) realloc(tokenbuf, nsize); \ if (tokenbuf == NULL) \ Modified: head/usr.bin/indent/lexi.c ============================================================================== --- head/usr.bin/indent/lexi.c Sun Jun 3 18:17:07 2018 (r334575) +++ head/usr.bin/indent/lexi.c Sun Jun 3 18:19:41 2018 (r334576) @@ -182,47 +182,32 @@ lexi(struct parser_state *state) if (isdigit((unsigned char)*buf_ptr) || (buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) { - enum base { - BASE_2, BASE_8, BASE_10, BASE_16 - }; int seendot = 0, seenexp = 0, seensfx = 0; - enum base in_base = BASE_10; - if (*buf_ptr == '0') { + /* + * base 2, base 8, base 16: + */ + if (buf_ptr[0] == '0' && buf_ptr[1] != '.') { + int len; + if (buf_ptr[1] == 'b' || buf_ptr[1] == 'B') - in_base = BASE_2; + len = strspn(buf_ptr + 2, "01") + 2; else if (buf_ptr[1] == 'x' || buf_ptr[1] == 'X') - in_base = BASE_16; - else if (isdigit((unsigned char)buf_ptr[1])) - in_base = BASE_8; - } - switch (in_base) { - case BASE_2: - *e_token++ = *buf_ptr++; - *e_token++ = *buf_ptr++; - while (*buf_ptr == '0' || *buf_ptr == '1') { - CHECK_SIZE_TOKEN; - *e_token++ = *buf_ptr++; + len = strspn(buf_ptr + 2, "0123456789ABCDEFabcdef") + 2; + else + len = strspn(buf_ptr + 1, "012345678") + 1; + if (len > 0) { + CHECK_SIZE_TOKEN(len); + memcpy(e_token, buf_ptr, len); + e_token += len; + buf_ptr += len; } - break; - case BASE_8: - *e_token++ = *buf_ptr++; - while (*buf_ptr >= '0' && *buf_ptr <= '8') { - CHECK_SIZE_TOKEN; - *e_token++ = *buf_ptr++; - } - break; - case BASE_16: - *e_token++ = *buf_ptr++; - *e_token++ = *buf_ptr++; - while (isxdigit((unsigned char)*buf_ptr)) { - CHECK_SIZE_TOKEN; - *e_token++ = *buf_ptr++; - } - break; - case BASE_10: + else + diag2(1, "Unterminated literal"); + } + else /* base 10: */ while (1) { if (*buf_ptr == '.') { if (seendot) @@ -230,7 +215,7 @@ lexi(struct parser_state *state) else seendot++; } - CHECK_SIZE_TOKEN; + CHECK_SIZE_TOKEN(3); *e_token++ = *buf_ptr++; if (!isdigit((unsigned char)*buf_ptr) && *buf_ptr != '.') { if ((*buf_ptr != 'E' && *buf_ptr != 'e') || seenexp) @@ -238,24 +223,21 @@ lexi(struct parser_state *state) else { seenexp++; seendot++; - CHECK_SIZE_TOKEN; *e_token++ = *buf_ptr++; if (*buf_ptr == '+' || *buf_ptr == '-') *e_token++ = *buf_ptr++; } } } - break; - } + while (1) { + CHECK_SIZE_TOKEN(2); if (!(seensfx & 1) && (*buf_ptr == 'U' || *buf_ptr == 'u')) { - CHECK_SIZE_TOKEN; *e_token++ = *buf_ptr++; seensfx |= 1; continue; } if (!(seensfx & 2) && (strchr("fFlL", *buf_ptr) != NULL)) { - CHECK_SIZE_TOKEN; if (buf_ptr[1] == buf_ptr[0]) *e_token++ = *buf_ptr++; *e_token++ = *buf_ptr++; @@ -276,13 +258,13 @@ lexi(struct parser_state *state) } else break; } - CHECK_SIZE_TOKEN; + CHECK_SIZE_TOKEN(1); /* copy it over */ *e_token++ = *buf_ptr++; if (buf_ptr >= buf_end) fill_buffer(); } - *e_token++ = '\0'; + *e_token = '\0'; if (s_token[0] == 'L' && s_token[1] == '\0' && (*buf_ptr == '"' || *buf_ptr == '\'')) @@ -397,6 +379,7 @@ lexi(struct parser_state *state) /* Scan a non-alphanumeric token */ + CHECK_SIZE_TOKEN(3); /* things like "<<=" */ *e_token++ = *buf_ptr; /* if it is only a one-character token, it is * moved here */ *e_token = '\0'; @@ -424,9 +407,7 @@ lexi(struct parser_state *state) diag2(1, "Unterminated literal"); goto stop_lit; } - CHECK_SIZE_TOKEN; /* Only have to do this once in this loop, - * since CHECK_SIZE guarantees that there - * are at least 5 entries left */ + CHECK_SIZE_TOKEN(2); *e_token = *buf_ptr++; if (buf_ptr >= buf_end) fill_buffer(); @@ -585,8 +566,10 @@ stop_lit: break; } while (*buf_ptr == '*' || isspace((unsigned char)*buf_ptr)) { - if (*buf_ptr == '*') + if (*buf_ptr == '*') { + CHECK_SIZE_TOKEN(1); *e_token++ = *buf_ptr; + } if (++buf_ptr >= buf_end) fill_buffer(); } @@ -620,6 +603,7 @@ stop_lit: /* * handle ||, &&, etc, and also things as in int *****i */ + CHECK_SIZE_TOKEN(1); *e_token++ = *buf_ptr; if (++buf_ptr >= buf_end) fill_buffer(); @@ -632,6 +616,7 @@ stop_lit: if (buf_ptr >= buf_end) /* check for input buffer empty */ fill_buffer(); state->last_u_d = unary_delim; + CHECK_SIZE_TOKEN(1); *e_token = '\0'; /* null terminate the token */ return (code); } Modified: head/usr.bin/indent/pr_comment.c ============================================================================== --- head/usr.bin/indent/pr_comment.c Sun Jun 3 18:17:07 2018 (r334575) +++ head/usr.bin/indent/pr_comment.c Sun Jun 3 18:19:41 2018 (r334576) @@ -205,9 +205,9 @@ pr_comment(void) while (1) { /* this loop will go until the comment is * copied */ - CHECK_SIZE_COM; switch (*buf_ptr) { /* this checks for various spcl cases */ case 014: /* check for a form feed */ + CHECK_SIZE_COM(3); if (!ps.box_com) { /* in a text comment, break the line here */ ps.use_ff = true; /* fix so dump_line uses a form feed */ @@ -232,6 +232,7 @@ pr_comment(void) return; } last_bl = NULL; + CHECK_SIZE_COM(4); if (ps.box_com || ps.last_nl) { /* if this is a boxed comment, * we dont ignore the newline */ if (s_com == e_com) @@ -255,7 +256,6 @@ pr_comment(void) */ else { /* otherwise, insert one */ last_bl = e_com; - CHECK_SIZE_COM; *e_com++ = ' '; } } @@ -282,12 +282,11 @@ pr_comment(void) * of comment */ if (++buf_ptr >= buf_end) /* get to next char after * */ fill_buffer(); - + CHECK_SIZE_COM(4); if (*buf_ptr == '/') { /* it is the end!!! */ end_of_comment: if (++buf_ptr >= buf_end) fill_buffer(); - CHECK_SIZE_COM; if (break_delim) { if (e_com > s_com + 3) { dump_line(); @@ -308,6 +307,7 @@ pr_comment(void) default: /* we have a random char */ now_col = count_spaces_until(ps.com_col, s_com, e_com); do { + CHECK_SIZE_COM(1); *e_com = *buf_ptr++; if (buf_ptr >= buf_end) fill_buffer(); @@ -337,11 +337,16 @@ pr_comment(void) t_ptr++) ; last_bl = NULL; + /* + * t_ptr will be somewhere between e_com (dump_line() reset) + * and l_com. So it's safe to copy byte by byte from t_ptr + * to e_com without any CHECK_SIZE_COM(). + */ while (*t_ptr != '\0') { if (*t_ptr == ' ' || *t_ptr == '\t') last_bl = e_com; *e_com++ = *t_ptr++; - } + } } break; } From owner-svn-src-head@freebsd.org Sun Jun 3 18:29:21 2018 Return-Path: Delivered-To: svn-src-head@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 754D2FE9F94; Sun, 3 Jun 2018 18:29:21 +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 2919A740BB; Sun, 3 Jun 2018 18:29:21 +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 0B625223A2; Sun, 3 Jun 2018 18:29:21 +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 w53ITKGW043168; Sun, 3 Jun 2018 18:29:20 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53ITKaa043167; Sun, 3 Jun 2018 18:29:20 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031829.w53ITKaa043167@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 18:29:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334578 - 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: 334578 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 18:29:21 -0000 Author: pstef Date: Sun Jun 3 18:29:20 2018 New Revision: 334578 URL: https://svnweb.freebsd.org/changeset/base/334578 Log: indent(1): don't overflow di_stack[] Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 18:19:48 2018 (r334577) +++ head/usr.bin/indent/indent.c Sun Jun 3 18:29:20 2018 (r334578) @@ -831,7 +831,12 @@ check_type: * with '{' */ if (ps.in_decl && ps.in_or_st) { /* this is either a structure * declaration or an init */ - di_stack[ps.dec_nest++] = dec_ind; + di_stack[ps.dec_nest] = dec_ind; + if (++ps.dec_nest == nitems(di_stack)) { + diag3(0, "Reached internal limit of %d struct levels", + nitems(di_stack)); + ps.dec_nest--; + } /* ? dec_ind = 0; */ } else { From owner-svn-src-head@freebsd.org Sun Jun 3 18:32:12 2018 Return-Path: Delivered-To: svn-src-head@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 82F98FEA4C5; Sun, 3 Jun 2018 18:32:12 +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 34F3E7451D; Sun, 3 Jun 2018 18:32:12 +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 163322252E; Sun, 3 Jun 2018 18:32:12 +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 w53IWBTO047921; Sun, 3 Jun 2018 18:32:11 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53IWBI1047920; Sun, 3 Jun 2018 18:32:11 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031832.w53IWBI1047920@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 18:32:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334579 - 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: 334579 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 18:32:12 -0000 Author: pstef Date: Sun Jun 3 18:32:11 2018 New Revision: 334579 URL: https://svnweb.freebsd.org/changeset/base/334579 Log: indent(1): ignore null characters from input Modified: head/usr.bin/indent/io.c Modified: head/usr.bin/indent/io.c ============================================================================== --- head/usr.bin/indent/io.c Sun Jun 3 18:29:20 2018 (r334578) +++ head/usr.bin/indent/io.c Sun Jun 3 18:32:11 2018 (r334579) @@ -300,7 +300,8 @@ fill_buffer(void) had_eof = true; break; } - *p++ = i; + if (i != '\0') + *p++ = i; if (i == '\n') break; } From owner-svn-src-head@freebsd.org Sun Jun 3 18:34:37 2018 Return-Path: Delivered-To: svn-src-head@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 60ECCFEAA47; Sun, 3 Jun 2018 18:34:37 +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 0EC7574805; Sun, 3 Jun 2018 18:34:37 +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 E18E12254B; Sun, 3 Jun 2018 18:34:36 +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 w53IYa6i048069; Sun, 3 Jun 2018 18:34:36 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53IYatM048068; Sun, 3 Jun 2018 18:34:36 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031834.w53IYatM048068@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 18:34:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334580 - 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: 334580 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 18:34:37 -0000 Author: pstef Date: Sun Jun 3 18:34:36 2018 New Revision: 334580 URL: https://svnweb.freebsd.org/changeset/base/334580 Log: indent(1): don't add a space after a label It's not needed and it fools pr_comment(). Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 18:32:11 2018 (r334579) +++ head/usr.bin/indent/indent.c Sun Jun 3 18:34:36 2018 (r334580) @@ -724,7 +724,6 @@ check_type: memcpy(e_lab, s_code, len); e_lab += len; *e_lab++ = ':'; - *e_lab++ = ' '; *e_lab = '\0'; e_code = s_code; } From owner-svn-src-head@freebsd.org Sun Jun 3 18:38:04 2018 Return-Path: Delivered-To: svn-src-head@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 5BEF6FEB239; Sun, 3 Jun 2018 18:38:04 +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 0E9C074B8D; Sun, 3 Jun 2018 18:38:04 +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 E4A5722558; Sun, 3 Jun 2018 18:38:03 +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 w53Ic312048247; Sun, 3 Jun 2018 18:38:03 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53Ic3YJ048246; Sun, 3 Jun 2018 18:38:03 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806031838.w53Ic3YJ048246@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 18:38:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334581 - 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: 334581 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 18:38:04 -0000 Author: pstef Date: Sun Jun 3 18:38:03 2018 New Revision: 334581 URL: https://svnweb.freebsd.org/changeset/base/334581 Log: indent(1): if the token is a "[" then neither of the blocks is relevant Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 18:34:36 2018 (r334580) +++ head/usr.bin/indent/indent.c Sun Jun 3 18:38:03 2018 (r334581) @@ -569,13 +569,15 @@ check_type: nitems(ps.paren_indents)); ps.p_l_follow--; } - if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent && + if (*token == '[') + /* not a function pointer declaration or a function call */; + else if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent && ps.procname[0] == '\0' && ps.paren_level == 0) { /* function pointer declarations */ indent_declaration(dec_ind, tabs_to_var); ps.dumped_decl_indent = true; } - else if (ps.want_blank && *token != '[' && + else if (ps.want_blank && ((ps.last_token != ident && ps.last_token != funcname) || proc_calls_space || /* offsetof (1) is never allowed a space; sizeof (2) gets From owner-svn-src-head@freebsd.org Sun Jun 3 19:05:22 2018 Return-Path: Delivered-To: svn-src-head@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 91EA0FEE134; Sun, 3 Jun 2018 19:05:22 +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 42F4C75E4B; Sun, 3 Jun 2018 19:05:22 +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 2069A22A2E; Sun,