Module Name: src
Committed By: rillig
Date: Sun Jun 20 18:41:27 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: lex.c
Log Message:
lint: reduce indentation in lexer for character constants
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xlint/lint1/lex.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.42 src/usr.bin/xlint/lint1/lex.c:1.43
--- src/usr.bin/xlint/lint1/lex.c:1.42 Sun Jun 20 18:38:12 2021
+++ src/usr.bin/xlint/lint1/lex.c Sun Jun 20 18:41:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.42 2021/06/20 18:38:12 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.43 2021/06/20 18:41:27 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.42 2021/06/20 18:38:12 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.43 2021/06/20 18:41:27 rillig Exp $");
#endif
#include <ctype.h>
@@ -831,18 +831,17 @@ lex_character_constant(void)
if (c == -2) {
/* unterminated character constant */
error(253);
- } else {
+ } else if (n > sizeof(int) || (n > 1 && (pflag || hflag))) {
/* XXX: should rather be sizeof(TARG_INT) */
- if (n > sizeof(int) || (n > 1 && (pflag || hflag))) {
- /* too many characters in character constant */
- error(71);
- } else if (n > 1) {
- /* multi-character character constant */
- warning(294);
- } else if (n == 0) {
- /* empty character constant */
- error(73);
- }
+
+ /* too many characters in character constant */
+ error(71);
+ } else if (n > 1) {
+ /* multi-character character constant */
+ warning(294);
+ } else if (n == 0) {
+ /* empty character constant */
+ error(73);
}
if (n == 1) {
cv = (char)val;
@@ -884,18 +883,16 @@ lex_wide_character_constant(void)
} else if (i == 0) {
/* empty character constant */
error(73);
+ } else if (i > imax) {
+ i = imax;
+ /* too many characters in character constant */
+ error(71);
} else {
- if (i > imax) {
- i = imax;
- /* too many characters in character constant */
- error(71);
- } else {
- buf[i] = '\0';
- (void)mbtowc(NULL, NULL, 0);
- if (mbtowc(&wc, buf, imax) < 0)
- /* invalid multibyte character */
- error(291);
- }
+ buf[i] = '\0';
+ (void)mbtowc(NULL, NULL, 0);
+ if (mbtowc(&wc, buf, imax) < 0)
+ /* invalid multibyte character */
+ error(291);
}
yylval.y_val = xcalloc(1, sizeof(*yylval.y_val));