Skip to content

Commit

Permalink
Put parentheses around assignments in if() and while()
Browse files Browse the repository at this point in the history
  • Loading branch information
mjfitzpatrick authored and olebole committed Jan 29, 2024
1 parent d34aa4d commit 91191af
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
22 changes: 12 additions & 10 deletions pkg/cl/lexicon.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ lexicon (void)
* mode metacharacters (they will be automatically turned on when
* compute mode is entered in an expression).
*/
while (ch = input())
while ((ch = input()))
if (ch == ' ' || ch == '\t') {
space: if (lexcol > 0)
lhs = 0;
Expand Down Expand Up @@ -199,7 +199,7 @@ space: if (lexcol > 0)
* integer constants, more complex tokens as operand structures in
* yylval.
*/
while (ch = input()) {
while ((ch = input())) {
lexcol++;

switch (ch) {
Expand All @@ -212,7 +212,7 @@ space: if (lexcol > 0)
unput (ch);
goto tokout_;
} else {
while (ch = input()) {
while ((ch = input())) {
if (ch == ' ' || ch == '\t')
continue;
else {
Expand Down Expand Up @@ -300,7 +300,7 @@ etok_: if (!newtoken) {
/* ?, ?? menu commands, recognized only at beginning of stmt */
if (lexcol > 1) {
goto deposit_;
} else if (ch = input()) {
} else if ((ch = input())) {
if (ch == '?')
return (crackident ("??"));
else {
Expand Down Expand Up @@ -355,7 +355,7 @@ etok_: if (!newtoken) {
}
}

} else if (cch = input()) {
} else if ((cch = input())) {
clswitch = (isspace (cch) || cch == ';');
if (cch == '=') {
unput(cch);
Expand Down Expand Up @@ -387,7 +387,7 @@ etok_: if (!newtoken) {
}

case '\\':
if (ch = input()) {
if ((ch = input())) {
if (ch == '\n')
continue;
else if (strchr ("&;=+-\"'\\#><()|", ch) != NULL)
Expand All @@ -408,14 +408,16 @@ etok_: if (!newtoken) {
* command, but all other escapes are passed on unmodified.
*/
while ((ch = input()) && ch != '\n') {
if (ch == '\\')
if (ch = input()) {
if (ch == '\\') {
if ((ch = input())) {
if (ch == '\n')
continue;
else
yytext[yyleng++] = '\\';
} else
} else {
break;
}
}
yytext[yyleng++] = ch;
}
if (ch)
Expand Down Expand Up @@ -511,7 +513,7 @@ etok_: if (!newtoken) {
if (!newtoken) {
unput (ch);
goto tokout_;
} else if (ch = input()) {
} else if ((ch = input())) {
if (ch == '&')
return (Y_ALLPIPE);
else {
Expand Down
22 changes: 12 additions & 10 deletions pkg/ecl/lexicon.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ lexicon (void)
* mode metacharacters (they will be automatically turned on when
* compute mode is entered in an expression).
*/
while (ch = input())
while ((ch = input()))
if (ch == ' ' || ch == '\t') {
space: if (lexcol > 0)
lhs = 0;
Expand Down Expand Up @@ -199,7 +199,7 @@ space: if (lexcol > 0)
* integer constants, more complex tokens as operand structures in
* yylval.
*/
while (ch = input()) {
while ((ch = input())) {
lexcol++;

switch (ch) {
Expand All @@ -212,7 +212,7 @@ space: if (lexcol > 0)
unput (ch);
goto tokout_;
} else {
while (ch = input()) {
while ((ch = input())) {
if (ch == ' ' || ch == '\t')
continue;
else {
Expand Down Expand Up @@ -300,7 +300,7 @@ etok_: if (!newtoken) {
/* ?, ?? menu commands, recognized only at beginning of stmt */
if (lexcol > 1) {
goto deposit_;
} else if (ch = input()) {
} else if ((ch = input())) {
if (ch == '?')
return (crackident ("??"));
else {
Expand Down Expand Up @@ -355,7 +355,7 @@ etok_: if (!newtoken) {
}
}

} else if (cch = input()) {
} else if ((cch = input())) {
clswitch = (isspace (cch) || cch == ';');
if (cch == '=') {
unput(cch);
Expand Down Expand Up @@ -387,7 +387,7 @@ etok_: if (!newtoken) {
}

case '\\':
if (ch = input()) {
if ((ch = input())) {
if (ch == '\n')
continue;
else if (strchr ("&;=+-\"'\\#><()|", ch) != NULL)
Expand All @@ -408,14 +408,16 @@ etok_: if (!newtoken) {
* command, but all other escapes are passed on unmodified.
*/
while ((ch = input()) && ch != '\n') {
if (ch == '\\')
if (ch = input()) {
if (ch == '\\') {
if ((ch = input())) {
if (ch == '\n')
continue;
else
yytext[yyleng++] = '\\';
} else
} else {
break;
}
}
yytext[yyleng++] = ch;
}
if (ch)
Expand Down Expand Up @@ -511,7 +513,7 @@ etok_: if (!newtoken) {
if (!newtoken) {
unput (ch);
goto tokout_;
} else if (ch = input()) {
} else if ((ch = input())) {
if (ch == '&')
return (Y_ALLPIPE);
else {
Expand Down

0 comments on commit 91191af

Please sign in to comment.