Module Name: src Committed By: kre Date: Thu Mar 14 19:38:56 UTC 2024
Modified Files: src/usr.bin/stat: stat.c Log Message: While the change in 1.51 certainly retained binary compat with what was in 1.50 (while silencing LINT) - it was clearly not the correct change to make. The code used !FLAG_POUND where it clearly meant ~FLAG_POUND ... the former is 0, so &= 0 could be replaced by =0 changing nothing. But that's not what it should have been doing, other flags should not have been removed here, just FLAG_POUND. This problem seems to have existed since support for %#s was first added in 2011, which kind of suggests how rarely that format, particularly with other flags (like %#-s) has ever been used (with no other flags, the bug would not be noticed). To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/usr.bin/stat/stat.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/stat/stat.c diff -u src/usr.bin/stat/stat.c:1.51 src/usr.bin/stat/stat.c:1.52 --- src/usr.bin/stat/stat.c:1.51 Thu Mar 14 00:07:20 2024 +++ src/usr.bin/stat/stat.c Thu Mar 14 19:38:56 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: stat.c,v 1.51 2024/03/14 00:07:20 rillig Exp $ */ +/* $NetBSD: stat.c,v 1.52 2024/03/14 19:38:56 kre Exp $ */ /* * Copyright (c) 2002-2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if !defined(lint) -__RCSID("$NetBSD: stat.c,v 1.51 2024/03/14 00:07:20 rillig Exp $"); +__RCSID("$NetBSD: stat.c,v 1.52 2024/03/14 19:38:56 kre Exp $"); #endif #if ! HAVE_NBTOOL_CONFIG_H @@ -1077,7 +1077,7 @@ format1(const struct stat *st, * First prefixlen chars are not encoded. */ if ((flags & FLAG_POUND) != 0 && ofmt == FMTF_STRING) { - flags = 0; + flags &= ~FLAG_POUND; strncpy(visbuf, sdata, prefixlen); /* Avoid GCC warnings. */ visbuf[prefixlen] = 0;