Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: fix build on Cygwin
details: https://anonhg.NetBSD.org/src/rev/bb15cef0552b
branches: trunk
changeset: 950284:bb15cef0552b
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 24 09:44:35 2021 +0000
description:
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type
size_t.
Instead, Cygwin defines it as type int. This leads to compile errors
because comparing signed with unsigned expressions is surprising in C.
diffstat:
usr.bin/xlint/lint1/lex.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diffs (54 lines):
diff -r 5ac01429957e -r bb15cef0552b usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Jan 24 09:25:16 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Jan 24 09:44:35 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.6 2021/01/24 09:25:16 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.7 2021/01/24 09:44:35 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.6 2021/01/24 09:25:16 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.7 2021/01/24 09:44:35 rillig Exp $");
#endif
#include <ctype.h>
@@ -845,13 +845,15 @@
lex_wide_character_constant(void)
{
static char buf[MB_LEN_MAX + 1];
- size_t i;
+ size_t i, imax;
int c;
wchar_t wc;
+ imax = MB_CUR_MAX;
+
i = 0;
while ((c = get_escaped_char('\'')) >= 0) {
- if (i < MB_CUR_MAX)
+ if (i < imax)
buf[i] = (char)c;
i++;
}
@@ -865,14 +867,14 @@
/* empty character constant */
error(73);
} else {
- if (i > MB_CUR_MAX) {
- i = MB_CUR_MAX;
+ 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, MB_CUR_MAX) < 0)
+ if (mbtowc(&wc, buf, imax) < 0)
/* invalid multibyte character */
error(291);
}
Home |
Main Index |
Thread Index |
Old Index