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(1): reduce indentation in ArchStatMember
details: https://anonhg.NetBSD.org/src/rev/5b7f65eb977d
branches: trunk
changeset: 945777:5b7f65eb977d
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Nov 07 13:29:38 2020 +0000
description:
make(1): reduce indentation in ArchStatMember
diffstat:
usr.bin/make/arch.c | 125 +++++++++++++++++++++++++--------------------------
1 files changed, 61 insertions(+), 64 deletions(-)
diffs (170 lines):
diff -r ada5636da05f -r 5b7f65eb977d usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sat Nov 07 13:24:06 2020 +0000
+++ b/usr.bin/make/arch.c Sat Nov 07 13:29:38 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.166 2020/11/07 13:24:06 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.167 2020/11/07 13:29:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
#include "config.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: arch.c,v 1.166 2020/11/07 13:24:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.167 2020/11/07 13:29:38 rillig Exp $");
typedef struct List ArchList;
typedef struct ListNode ArchListNode;
@@ -476,7 +476,7 @@
*/
if (fread(magic, SARMAG, 1, arch) != 1 ||
strncmp(magic, ARMAG, SARMAG) != 0) {
- fclose(arch);
+ (void)fclose(arch);
return NULL;
}
@@ -488,84 +488,81 @@
memName[AR_MAX_NAME_LEN] = '\0';
while (fread(&arh, sizeof arh, 1, arch) == 1) {
- if (strncmp(arh.ar_fmag, ARFMAG, sizeof arh.ar_fmag) != 0) {
- /*
- * The header is bogus, so the archive is bad
- * and there's no way we can recover...
- */
+ char *nameend;
+
+ /* If the header is bogus, there's no way we can recover. */
+ if (strncmp(arh.ar_fmag, ARFMAG, sizeof arh.ar_fmag) != 0)
goto badarch;
- } else {
- char *nameend;
- /*
- * We need to advance the stream's pointer to the start of the
- * next header. Files are padded with newlines to an even-byte
- * boundary, so we need to extract the size of the file from the
- * 'size' field of the header and round it up during the seek.
- */
- arh.ar_size[sizeof arh.ar_size - 1] = '\0';
- size = (size_t)strtol(arh.ar_size, NULL, 10);
+ /*
+ * We need to advance the stream's pointer to the start of the
+ * next header. Files are padded with newlines to an even-byte
+ * boundary, so we need to extract the size of the file from the
+ * 'size' field of the header and round it up during the seek.
+ */
+ arh.ar_size[sizeof arh.ar_size - 1] = '\0';
+ size = (size_t)strtol(arh.ar_size, NULL, 10);
- memcpy(memName, arh.ar_name, sizeof arh.ar_name);
- nameend = memName + AR_MAX_NAME_LEN;
- while (*nameend == ' ') {
- nameend--;
- }
- nameend[1] = '\0';
+ memcpy(memName, arh.ar_name, sizeof arh.ar_name);
+ nameend = memName + AR_MAX_NAME_LEN;
+ while (*nameend == ' ') {
+ nameend--;
+ }
+ nameend[1] = '\0';
#ifdef SVR4ARCHIVES
+ /*
+ * svr4 names are slash terminated. Also svr4 extended AR format.
+ */
+ if (memName[0] == '/') {
/*
- * svr4 names are slash terminated. Also svr4 extended AR format.
+ * svr4 magic mode; handle it
*/
- if (memName[0] == '/') {
- /*
- * svr4 magic mode; handle it
- */
- switch (ArchSVR4Entry(ar, memName, size, arch)) {
- case -1: /* Invalid data */
- goto badarch;
- case 0: /* List of files entry */
- continue;
- default: /* Got the entry */
- break;
- }
- } else {
- if (nameend[0] == '/')
- nameend[0] = '\0';
+ switch (ArchSVR4Entry(ar, memName, size, arch)) {
+ case -1: /* Invalid data */
+ goto badarch;
+ case 0: /* List of files entry */
+ continue;
+ default: /* Got the entry */
+ break;
}
+ } else {
+ if (nameend[0] == '/')
+ nameend[0] = '\0';
+ }
#endif
#ifdef AR_EFMT1
- /*
- * BSD 4.4 extended AR format: #1/<namelen>, with name as the
- * first <namelen> bytes of the file
- */
- if (strncmp(memName, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 &&
- ch_isdigit(memName[sizeof AR_EFMT1 - 1])) {
+ /*
+ * BSD 4.4 extended AR format: #1/<namelen>, with name as the
+ * first <namelen> bytes of the file
+ */
+ if (strncmp(memName, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 &&
+ ch_isdigit(memName[sizeof AR_EFMT1 - 1])) {
- int elen = atoi(memName + sizeof AR_EFMT1 - 1);
+ int elen = atoi(memName + sizeof AR_EFMT1 - 1);
- if ((unsigned int)elen > MAXPATHLEN)
- goto badarch;
- if (fread(memName, (size_t)elen, 1, arch) != 1)
- goto badarch;
- memName[elen] = '\0';
- if (fseek(arch, -elen, SEEK_CUR) != 0)
- goto badarch;
- if (DEBUG(ARCH) || DEBUG(MAKE)) {
- debug_printf("ArchStat: Extended format entry for %s\n",
- memName);
- }
+ if ((unsigned int)elen > MAXPATHLEN)
+ goto badarch;
+ if (fread(memName, (size_t)elen, 1, arch) != 1)
+ goto badarch;
+ memName[elen] = '\0';
+ if (fseek(arch, -elen, SEEK_CUR) != 0)
+ goto badarch;
+ if (DEBUG(ARCH) || DEBUG(MAKE)) {
+ debug_printf("ArchStat: Extended format entry for %s\n",
+ memName);
}
+ }
#endif
- {
- HashEntry *he;
- he = HashTable_CreateEntry(&ar->members, memName, NULL);
- HashEntry_Set(he, bmake_malloc(sizeof arh));
- memcpy(HashEntry_Get(he), &arh, sizeof arh);
- }
+ {
+ HashEntry *he;
+ he = HashTable_CreateEntry(&ar->members, memName, NULL);
+ HashEntry_Set(he, bmake_malloc(sizeof arh));
+ memcpy(HashEntry_Get(he), &arh, sizeof arh);
}
+
if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0)
goto badarch;
}
Home |
Main Index |
Thread Index |
Old Index