🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.d
Article #4941

Re: v18i049: Indent

#4941
From: Rob Bernardo
Date: Tue, 25 Apr 1989 23:55
141 lines
4895 bytes
About a month ago Jef Poskanzer <jef@helios.ee.lbl.gov> posted a patch to
indent(1), which added some command line flags (-brr, -ccin, and -prs).

I ran into some problems with the -brr flag. The -brr flag was an
alternative to the -bl and -br (the default) flags, which all set
curly braces around blocks of code in different styles. There
were two bugs. 

	1. The way command line flags were compared against each
	possible flag, only first strlen(possible_flag) characters
	were compared, causing "-brr" to be interpreted as "-br".

	2. Some default values cause the curly brace style of "-brr"
	not only to be the default, but to not be overridable when
	the "-br" (the alleged default) was explicit on the command line.

Additionally, it trying to get two curly braces to line up in the same
column in an example on the man page, one curly brace was preceded with
a tab, the other with spaces, thereby not guaranteeing that they would
align in the same column when troff'ed.

The following patch corrects these difficulties. Because of #1 above,
it was necessary to rename the flag "-brr"; I chose "-bib" ("brace
indent both").

*** args.c~	Tue Apr 25 16:04:24 1989
--- args.c	Tue Apr 25 16:48:21 1989
***************
*** 71,79 ****
      "bap", PRO_BOOL, false, ON, &blanklines_after_procs,
      "bbb", PRO_BOOL, false, ON, &blanklines_before_blockcomments,
      "bc", PRO_BOOL, true, OFF, &ps.leave_comma,
      "bl", PRO_BOOL, true, OFF, &btype_2,
      "br", PRO_BOOL, true, ON, &btype_2,
-     "brr", PRO_BOOL, true, ON, &btype_3,
      "bs", PRO_BOOL, false, ON, &Bill_Shannon,
      "cdb", PRO_BOOL, true, ON, &comment_delimiter_on_blankline,
      "cd", PRO_INT, 0, 0, &ps.decl_com_ind,
--- 71,79 ----
      "bap", PRO_BOOL, false, ON, &blanklines_after_procs,
      "bbb", PRO_BOOL, false, ON, &blanklines_before_blockcomments,
      "bc", PRO_BOOL, true, OFF, &ps.leave_comma,
+     "bib", PRO_BOOL, false, ON, &btype_3,
      "bl", PRO_BOOL, true, OFF, &btype_2,
      "br", PRO_BOOL, true, ON, &btype_2,
      "bs", PRO_BOOL, false, ON, &Bill_Shannon,
      "cdb", PRO_BOOL, true, ON, &comment_delimiter_on_blankline,
      "cd", PRO_INT, 0, 0, &ps.decl_com_ind,
*** indent.1~	Tue Apr 25 16:04:55 1989
--- indent.1	Tue Apr 25 16:49:52 1989
***************
*** 29,37 ****
  [\ \fB\-bap\fR\ |\ \fB\-nbap\fR\ ]
  [\ \fB\-bbb\fR\ |\ \fB\-nbbb\fR\ ]
  [\ \fB\-bc\fR\ |\ \fB\-nbc\fR\ ]
  [\ \fB\-bl\fR\ ]
  [\ \fB\-br\fR\ ]
- [\ \fB\-brr\fR\ ]
  [\ \fB\-c\fIn\fR\ ]
  [\ \fB\-cd\fIn\fR\ ]
  [\ \fB\-cdb\fR\ |\ \fB\-ncdb\fR\ ]
--- 29,37 ----
  [\ \fB\-bap\fR\ |\ \fB\-nbap\fR\ ]
  [\ \fB\-bbb\fR\ |\ \fB\-nbbb\fR\ ]
  [\ \fB\-bc\fR\ |\ \fB\-nbc\fR\ ]
+ [\ \fB\-bib\fR\ ]
  [\ \fB\-bl\fR\ ]
  [\ \fB\-br\fR\ ]
  [\ \fB\-c\fIn\fR\ ]
  [\ \fB\-cd\fIn\fR\ ]
  [\ \fB\-cdb\fR\ |\ \fB\-ncdb\fR\ ]
***************
*** 111,117 ****
  turns off this option.  The default is
  .BR \-bc .
  .TP 15
! .BR \-br , \-bl , \-brr
  Specifying
  .B \-bl
  lines up compound statements like this:
--- 111,117 ----
  turns off this option.  The default is
  .BR \-bc .
  .TP 15
! .BR \-br , \-bl , \-bib
  Specifying
  .B \-bl
  lines up compound statements like this:
***************
*** 136,148 ****
  .ft R
  .fi
  And specifying
! .B \-brr
  makes them look like this:
  .ne 3
  .nf
  .ft L
      if (...)
! 	{
          code
          }
  .ft R
--- 136,148 ----
  .ft R
  .fi
  And specifying
! .B \-bib
  makes them look like this:
  .ne 3
  .nf
  .ft L
      if (...)
!         {
          code
          }
  .ft R
*** indent.c~	Tue Apr 25 16:09:05 1989
--- indent.c	Tue Apr 25 16:49:00 1989
***************
*** 130,136 ****
  				 * by an arg, we will set this equal to
  				 * ps.com_ind */
      btype_2 = 1;		/* -br */
!     btype_3 = 0;		/* not -brr */
      cuddle_else = 1;		/* -ce */
      ps.unindent_displace = 0;	/* -d0 */
      ps.case_indent = 0;		/* -cli0 */
--- 130,136 ----
  				 * by an arg, we will set this equal to
  				 * ps.com_ind */
      btype_2 = 1;		/* -br */
!     btype_3 = 0;		/* not -bib */
      cuddle_else = 1;		/* -ce */
      ps.unindent_displace = 0;	/* -d0 */
      ps.case_indent = 0;		/* -cli0 */
-- 
Rob Bernardo, Pacific Bell UNIX/C Reusable Code Library
Email:     ...![backbone]!pacbell!pbhyf!rob   OR  rob@pbhyf.PacBell.COM
Office:    (415) 823-2417  Room 4E850O San Ramon Valley Administrative Center
Residence: (415) 827-4301  R Bar JB, Concord, California
Technical Details
Message-ID: <5128@pbhyf.PacBell.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!bionet!ames!amdahl!pacbell!pbhyf!rob

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!bionet!ames!amdahl!pacbell!pbhyf!rob
From: rob@PacBell.COM (Rob Bernardo)
Newsgroups: comp.sources.d
Subject: Re: v18i049:  Indent
Message-ID: <5128@pbhyf.PacBell.COM>
Date: 25 Apr 89 23:55:49 GMT
Organization: Pacific * Bell, San Ramon, CA
Lines: 141