indent munges code
Lars Henrik Mathiesen
thorinn at skinfaxe.diku.dk
Thu Dec 14 04:42:02 AEST 1989
Description:
Indent(1) will _silently_ convert ``old style'' assignment
operators like =- and =* to the newer forms -= and *=. This
is a problem with C compilers like GNU gcc and SunOS4 cc which
do not support the ``old style'' and _silently_ parses it as
two operators. Additionally, if a `=' token is followed by a
character with bit 0200 set, a wild memory reference is made.
Fix:
A new option -osa/-nosa (old style assignment), default off,
to determine if these constructs are interpreted in the old or
the new style. Under -osa a warning message is always printed
for each conversion; after all, the semantics are changed for
_some_ compilers even if it isn't for yours.
RCS file: RCS/indent.1,v
retrieving revision 1.1
diff -c -r1.1 indent.1
*** /tmp/,RCSt1003087 Wed Dec 13 17:49:41 1989
--- indent.1 Wed Dec 13 17:03:25 1989
***************
*** 33,38 ****
--- 33,39 ----
[\ \fB\-l\fIn\fR\ ]
[\ \fB\-lc\fIn\fR\ ]
[\ \fB\-lp\fR\ |\ \fB\-nlp\fR\ ]
+ [\ \fB\-osa\fR\ |\ \fB\-nosa\fR\ ]
[\ \fB\-npro\fR\ ]
[\ \fB\-pcs\fR\ |\ \fB\-npcs\fR\ ]
[\ \fB\-ps\fR\ |\ \fB\-nps\fR\ ]
***************
*** 265,270 ****
--- 266,277 ----
p5));
.ft R
.fi
+ .TP 15
+ .BR \-osa , \-nosa
+ If true (\fB\-osa\fR) old style assignment operators (`=-', `=*', and so on)
+ are considered to be tokens, and are converted to the newer form (`-=', `*=').
+ The default is
+ .BR \-nosa .
.TP 15
.B \-npro
Causes the profile files, `./.indent.pro' and `~/.indent.pro', to be ignored.
===================================================================
RCS file: RCS/indent_globs.h,v
retrieving revision 1.1
diff -c -r1.1 indent_globs.h
*** /tmp/,RCSt1003087 Wed Dec 13 17:49:45 1989
--- indent_globs.h Wed Dec 13 16:12:11 1989
***************
*** 121,126 ****
--- 121,128 ----
int lineup_to_parens; /* if true, continued code within parens will
be lined up to the open paren */
int block_comment_max_col;
+ int convert_old_assignment; /* if true, old style assignment operators (=+)
+ are accepted and converted to new style */
struct parser_state {
===================================================================
RCS file: RCS/args.c,v
retrieving revision 1.1
diff -c -r1.1 args.c
*** /tmp/,RCSt1003087 Wed Dec 13 17:49:49 1989
--- args.c Wed Dec 13 16:27:10 1989
***************
*** 97,102 ****
--- 97,104 ----
"nbbb", PRO_BOOL, false, OFF, &blanklines_before_blockcomments,
"ps", PRO_BOOL, false, ON, &pointer_as_binop,
"nps", PRO_BOOL, false, OFF, &pointer_as_binop,
+ "osa", PRO_BOOL, false, ON, &convert_old_assignment,
+ "nosa", PRO_BOOL, false, OFF, &convert_old_assignment,
"troff", PRO_BOOL, false, ON, &troff,
"T", PRO_SPECIAL, 0, KEY, 0,
/* whew! */
===================================================================
RCS file: RCS/lexi.c,v
retrieving revision 1.1
diff -c -r1.1 lexi.c
*** /tmp/,RCSt1003087 Wed Dec 13 17:49:53 1989
--- lexi.c Wed Dec 13 17:49:20 1989
***************
*** 461,468 ****
case '=':
if (ps.in_or_st)
ps.block_init = 1;
! if (chartype[*buf_ptr] == opchar) { /* we have two char
* assignment */
tok[-1] = *buf_ptr++;
if ((tok[-1] == '<' || tok[-1] == '>') && tok[-1] == *buf_ptr)
*tok++ = *buf_ptr++;
--- 461,470 ----
case '=':
if (ps.in_or_st)
ps.block_init = 1;
! if (convert_old_assignment &&
! chartype[*buf_ptr & 0177] == opchar) { /* we have two char
* assignment */
+ printf("%d: Old style assignment converted\n", line_no);
tok[-1] = *buf_ptr++;
if ((tok[-1] == '<' || tok[-1] == '>') && tok[-1] == *buf_ptr)
*tok++ = *buf_ptr++;
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list