Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint2 lint: move fgetln peculiarities out of r...
details: https://anonhg.NetBSD.org/src/rev/8de23aa80abb
branches: trunk
changeset: 1026537:8de23aa80abb
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 28 08:21:49 2021 +0000
description:
lint: move fgetln peculiarities out of read_ln_line
This allows the function parameter to be a pointer to const.
No functional change.
diffstat:
usr.bin/xlint/lint2/read.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diffs (52 lines):
diff -r cc9db21219a6 -r 8de23aa80abb usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c Sun Nov 28 02:54:26 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c Sun Nov 28 08:21:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.69 2021/11/16 22:12:44 rillig Exp $ */
+/* $NetBSD: read.c,v 1.70 2021/11/28 08:21:49 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: read.c,v 1.69 2021/11/16 22:12:44 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.70 2021/11/28 08:21:49 rillig Exp $");
#endif
#include <ctype.h>
@@ -139,7 +139,7 @@
}
static void
-read_ln_line(char *line, size_t len)
+read_ln_line(const char *line, size_t len)
{
const char *cp;
int cline, isrc, iline;
@@ -148,9 +148,6 @@
flines[srcfile]++;
- if (len == 0 || line[len - 1] != '\n')
- inperr("%s", &line[len - 1]);
- line[len - 1] = '\0';
cp = line;
/* line number in csrcfile */
@@ -230,8 +227,13 @@
if ((inp = fopen(name, "r")) == NULL)
err(1, "cannot open %s", name);
- while ((line = fgetln(inp, &len)) != NULL)
+ while ((line = fgetln(inp, &len)) != NULL) {
+ if (len == 0 || line[len - 1] != '\n')
+ inperr("%s", &line[len - 1]);
+ line[len - 1] = '\0';
+
read_ln_line(line, len);
+ }
_destroyhash(renametab);
Home |
Main Index |
Thread Index |
Old Index