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: extract RanlibOODate into separate function



details:   https://anonhg.NetBSD.org/src/rev/04ea25c447b1
branches:  trunk
changeset: 1022910:04ea25c447b1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 14 13:26:07 2021 +0000

description:
make: extract RanlibOODate into separate function

No functional change.

diffstat:

 usr.bin/make/arch.c |  67 ++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 33 deletions(-)

diffs (104 lines):

diff -r 32b3aca16345 -r 04ea25c447b1 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sat Aug 14 13:11:33 2021 +0000
+++ b/usr.bin/make/arch.c       Sat Aug 14 13:26:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -988,6 +988,34 @@
 #endif
 }
 
+static bool
+RanlibOODate(const GNode *gn MAKE_ATTR_UNUSED)
+{
+#ifdef RANLIBMAG
+       struct ar_hdr *arh;     /* Header for __.SYMDEF */
+       int tocModTime;         /* The table-of-contents' mod time */
+
+       arh = ArchStatMember(gn->path, RANLIBMAG, false);
+
+       if (arh == NULL) {
+               /* A library without a table of contents is out-of-date. */
+               if (DEBUG(ARCH) || DEBUG(MAKE))
+                       debug_printf("no toc...");
+               return true;
+       }
+
+       tocModTime = (int)strtol(arh->ar_date, NULL, 10);
+
+       if (DEBUG(ARCH) || DEBUG(MAKE))
+               debug_printf("%s modified %s...",
+                   RANLIBMAG, Targ_FmtTime(tocModTime));
+       return gn->youngestChild == NULL ||
+              gn->youngestChild->mtime > tocModTime;
+#else
+       return false;
+#endif
+}
+
 /*
  * Decide if a node with the OP_LIB attribute is out-of-date. Called from
  * GNode_IsOODate to make its life easier.
@@ -1021,46 +1049,19 @@
 bool
 Arch_LibOODate(GNode *gn)
 {
-       bool oodate;
 
        if (gn->type & OP_PHONY) {
-               oodate = true;
+               return true;
        } else if (!GNode_IsTarget(gn) && Lst_IsEmpty(&gn->children)) {
-               oodate = false;
+               return false;
        } else if ((!Lst_IsEmpty(&gn->children) && gn->youngestChild == NULL) ||
                   (gn->mtime > now) ||
                   (gn->youngestChild != NULL &&
                    gn->mtime < gn->youngestChild->mtime)) {
-               oodate = true;
+               return true;
        } else {
-#ifdef RANLIBMAG
-               struct ar_hdr *arh;     /* Header for __.SYMDEF */
-               int modTimeTOC;         /* The table-of-contents' mod time */
-
-               arh = ArchStatMember(gn->path, RANLIBMAG, false);
-
-               if (arh != NULL) {
-                       modTimeTOC = (int)strtol(arh->ar_date, NULL, 10);
-
-                       if (DEBUG(ARCH) || DEBUG(MAKE))
-                               debug_printf("%s modified %s...",
-                                            RANLIBMAG,
-                                            Targ_FmtTime(modTimeTOC));
-                       oodate = gn->youngestChild == NULL ||
-                                gn->youngestChild->mtime > modTimeTOC;
-               } else {
-                       /*
-                        * A library without a table of contents is out-of-date.
-                        */
-                       if (DEBUG(ARCH) || DEBUG(MAKE))
-                               debug_printf("no toc...");
-                       oodate = true;
-               }
-#else
-               oodate = false;
-#endif
+               return RanlibOODate(gn);
        }
-       return oodate;
 }
 
 /* Initialize the archives module. */



Home | Main Index | Thread Index | Old Index