1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
From f549b757394fdb4ac27e4a4bc42e865e98434361 Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Wed, 22 Jan 2020 11:36:30 -0800
Subject: [PATCH 3/4] parse: Check that rules have $rspfile iff they have
$rspfile_content
---
parse.c | 8 +++++++-
util.c | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/parse.c b/parse.c
index 6d07816..413e5d7 100644
--- a/parse.c
+++ b/parse.c
@@ -35,7 +35,7 @@ parserule(struct scanner *s, struct environment *env)
struct rule *r;
char *var;
struct evalstring *val;
- bool hascommand = false;
+ bool hascommand = false, hasrspfile = false, hasrspcontent = false;
r = mkrule(scanname(s));
scannewline(s);
@@ -45,9 +45,15 @@ parserule(struct scanner *s, struct environment *env)
ruleaddvar(r, var, val);
if (strcmp(var, "command") == 0)
hascommand = true;
+ else if (strcmp(var, "rspfile") == 0)
+ hasrspfile = true;
+ else if (strcmp(var, "rspfile_content") == 0)
+ hasrspcontent = true;
}
if (!hascommand)
fatal("rule '%s' has no command", r->name);
+ if (hasrspfile != hasrspcontent)
+ fatal("rule '%s' has rspfile and no rspfile_content or vice versa", r->name);
envaddrule(env, r);
}
diff --git a/util.c b/util.c
index 8eccf92..39bab18 100644
--- a/util.c
+++ b/util.c
@@ -257,7 +257,7 @@ writefile(const char *name, struct string *s)
return -1;
}
ret = 0;
- if (s && (fwrite(s->s, 1, s->n, f) != s->n || fflush(f) != 0)) {
+ if (fwrite(s->s, 1, s->n, f) != s->n || fflush(f) != 0) {
warn("write %s:", name);
ret = -1;
}
--
2.24.0
|