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: rename eunlink to unlink_file



details:   https://anonhg.NetBSD.org/src/rev/cb671014428d
branches:  trunk
changeset: 1029207:cb671014428d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 27 17:18:57 2021 +0000

description:
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.

diffstat:

 usr.bin/make/compat.c  |   6 +++---
 usr.bin/make/job.c     |   6 +++---
 usr.bin/make/main.c    |  18 +++++++-----------
 usr.bin/make/nonints.h |   4 ++--
 4 files changed, 15 insertions(+), 19 deletions(-)

diffs (119 lines):

diff -r 9ce5136575d1 -r cb671014428d usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Mon Dec 27 14:57:30 2021 +0000
+++ b/usr.bin/make/compat.c     Mon Dec 27 17:18:57 2021 +0000
@@ -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 @@
        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);
                }
        }
diff -r 9ce5136575d1 -r cb671014428d usr.bin/make/job.c
--- a/usr.bin/make/job.c        Mon Dec 27 14:57:30 2021 +0000
+++ b/usr.bin/make/job.c        Mon Dec 27 17:18:57 2021 +0000
@@ -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 @@
                return;
 
        file = GNode_Path(gn);
-       if (eunlink(file) != -1)
+       if (unlink_file(file))
                Error("*** %s removed", file);
 }
 
diff -r 9ce5136575d1 -r cb671014428d usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Dec 27 14:57:30 2021 +0000
+++ b/usr.bin/make/main.c       Mon Dec 27 17:18:57 2021 +0000
@@ -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 @@
        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
diff -r 9ce5136575d1 -r cb671014428d usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Mon Dec 27 14:57:30 2021 +0000
+++ b/usr.bin/make/nonints.h    Mon Dec 27 17:18:57 2021 +0000
@@ -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 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;



Home | Main Index | Thread Index | Old Index