Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: :mtime=error throw error on stat(2) failure
details: https://anonhg.NetBSD.org/src/rev/b806cb4334f3
branches: trunk
changeset: 374674:b806cb4334f3
user: sjg <sjg%NetBSD.org@localhost>
date: Tue May 09 20:53:23 2023 +0000
description:
make: :mtime=error throw error on stat(2) failure
Sometimes we want fatal error if stat fails on the
presumed pathname.
diffstat:
usr.bin/make/make.1 | 9 ++++++++-
usr.bin/make/var.c | 16 ++++++++++++----
2 files changed, 20 insertions(+), 5 deletions(-)
diffs (72 lines):
diff -r 23fafd19c2c6 -r b806cb4334f3 usr.bin/make/make.1
--- a/usr.bin/make/make.1 Tue May 09 20:51:14 2023 +0000
+++ b/usr.bin/make/make.1 Tue May 09 20:53:23 2023 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.364 2023/05/09 20:14:27 sjg Exp $
+.\" $NetBSD: make.1,v 1.365 2023/05/09 20:53:23 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -1522,6 +1522,13 @@ If
fails; use
.Ar timestamp
or current time.
+If
+.Ar timestamp
+is set to
+.Ql error ,
+then
+.Xr stat 2
+failure will cause an error.
.It Cm \&:tA
Attempts to convert the value to an absolute path using
.Xr realpath 3 .
diff -r 23fafd19c2c6 -r b806cb4334f3 usr.bin/make/var.c
--- a/usr.bin/make/var.c Tue May 09 20:51:14 2023 +0000
+++ b/usr.bin/make/var.c Tue May 09 20:53:23 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1051 2023/05/09 20:14:27 sjg Exp $ */
+/* $NetBSD: var.c,v 1.1052 2023/05/09 20:53:23 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1051 2023/05/09 20:14:27 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1052 2023/05/09 20:53:23 sjg Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -2841,6 +2841,7 @@ ApplyModifier_Mtime(const char **pp, Mod
Expr *expr = ch->expr;
const char *args, *mod = *pp;
struct stat st;
+ bool error = false;
int i = -1;
if (!ModMatchEq(mod, "mtime", ch))
@@ -2849,13 +2850,20 @@ ApplyModifier_Mtime(const char **pp, Mod
args = *pp;
if (args[0] == '=') {
args++;
- if (!TryParseIntBase0(&args, &i))
- return AMR_BAD;
+ if (!TryParseIntBase0(&args, &i)) {
+ if (strncmp(args, "error", 5) == 0) {
+ error = true;
+ args += 5;
+ } else
+ return AMR_BAD;
+ }
*pp = args;
}
if (!ModChain_ShouldEval(ch))
return AMR_OK;
if (stat(Expr_Str(expr), &st) < 0) {
+ if (error)
+ return AMR_BAD;
if (i < 0)
time(&st.st_mtime);
else
Home |
Main Index |
Thread Index |
Old Index