Module Name: src Committed By: rillig Date: Mon Dec 27 17:18:57 UTC 2021
Modified Files: src/usr.bin/make: compat.c job.c main.c nonints.h Log Message: make: rename eunlink to unlink_file The name eunlink suggested a relation with the similarly named functions emalloc or esnprintf, but that was misleading. Instead, unlink_file works like unlink, except that it refuses to remove an empty directory. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/usr.bin/make/compat.c cvs rdiff -u -r1.443 -r1.444 src/usr.bin/make/job.c cvs rdiff -u -r1.547 -r1.548 src/usr.bin/make/main.c cvs rdiff -u -r1.221 -r1.222 src/usr.bin/make/nonints.h 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/make/compat.c diff -u src/usr.bin/make/compat.c:1.233 src/usr.bin/make/compat.c:1.234 --- src/usr.bin/make/compat.c:1.233 Wed Dec 15 13:03:33 2021 +++ src/usr.bin/make/compat.c Mon Dec 27 17:18:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.233 2021/12/15 13:03:33 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.234 2021/12/27 17:18:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -96,7 +96,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.233 2021/12/15 13:03:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.234 2021/12/27 17:18:57 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -112,7 +112,7 @@ CompatDeleteTarget(GNode *gn) if (gn != NULL && !Targ_Precious(gn)) { const char *file = GNode_VarTarget(gn); - if (!opts.noExecute && eunlink(file) != -1) { + if (!opts.noExecute && unlink_file(file)) { Error("*** %s removed", file); } } Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.443 src/usr.bin/make/job.c:1.444 --- src/usr.bin/make/job.c:1.443 Wed Dec 15 12:58:01 2021 +++ src/usr.bin/make/job.c Mon Dec 27 17:18:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.443 2021/12/15 12:58:01 rillig Exp $ */ +/* $NetBSD: job.c,v 1.444 2021/12/27 17:18:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -142,7 +142,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.443 2021/12/15 12:58:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.444 2021/12/27 17:18:57 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -512,7 +512,7 @@ JobDeleteTarget(GNode *gn) return; file = GNode_Path(gn); - if (eunlink(file) != -1) + if (unlink_file(file)) Error("*** %s removed", file); } Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.547 src/usr.bin/make/main.c:1.548 --- src/usr.bin/make/main.c:1.547 Wed Dec 15 12:58:01 2021 +++ src/usr.bin/make/main.c Mon Dec 27 17:18:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.547 2021/12/15 12:58:01 rillig Exp $ */ +/* $NetBSD: main.c,v 1.548 2021/12/27 17:18:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.547 2021/12/15 12:58:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.548 2021/12/27 17:18:57 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1983,23 +1983,19 @@ Finish(int errs) Fatal("%d error%s", errs, errs == 1 ? "" : "s"); } -/* - * eunlink -- - * Remove a file carefully, avoiding directories. - */ -int -eunlink(const char *file) +bool +unlink_file(const char *file) { struct stat st; if (lstat(file, &st) == -1) - return -1; + return false; if (S_ISDIR(st.st_mode)) { errno = EISDIR; - return -1; + return false; } - return unlink(file); + return unlink(file) == 0; } static void Index: src/usr.bin/make/nonints.h diff -u src/usr.bin/make/nonints.h:1.221 src/usr.bin/make/nonints.h:1.222 --- src/usr.bin/make/nonints.h:1.221 Wed Dec 15 12:58:01 2021 +++ src/usr.bin/make/nonints.h Mon Dec 27 17:18:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.221 2021/12/15 12:58:01 rillig Exp $ */ +/* $NetBSD: nonints.h,v 1.222 2021/12/27 17:18:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ void Fatal(const char *, ...) MAKE_ATTR_ void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; void DieHorribly(void) MAKE_ATTR_DEAD; void Finish(int) MAKE_ATTR_DEAD; -int eunlink(const char *) MAKE_ATTR_USE; +bool unlink_file(const char *) MAKE_ATTR_USE; void execDie(const char *, const char *); char *getTmpdir(void) MAKE_ATTR_USE; bool ParseBoolean(const char *, bool) MAKE_ATTR_USE;