2023-04-24 23:44:30 +00:00
|
|
|
/* $NetBSD: arch.c,v 1.213 2023/02/14 21:08:00 rillig Exp $ */
|
2012-06-08 21:57:36 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988, 1989, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1996-10-06 15:57:15 +00:00
|
|
|
* Copyright (c) 1989 by Berkeley Softworks
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Manipulate libraries, archives and their members.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* The first time an archive is referenced, all of its members' headers are
|
|
|
|
* read and cached and the archive closed again. All cached archives are kept
|
|
|
|
* on a list which is searched each time an archive member is referenced.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
|
|
|
* The interface to this module is:
|
2020-11-20 03:54:37 +00:00
|
|
|
*
|
|
|
|
* Arch_Init Initialize this module.
|
|
|
|
*
|
|
|
|
* Arch_End Clean up this module.
|
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Arch_ParseArchive
|
2020-11-20 03:54:37 +00:00
|
|
|
* Parse an archive specification such as
|
|
|
|
* "archive.a(member1 member2)".
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Arch_Touch Alter the modification time of the archive
|
|
|
|
* member described by the given node to be
|
2020-11-20 03:54:37 +00:00
|
|
|
* the time when make was started.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Arch_TouchLib Update the modification time of the library
|
|
|
|
* described by the given node. This is special
|
|
|
|
* because it also updates the modification time
|
|
|
|
* of the library's table of contents.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* Arch_UpdateMTime
|
|
|
|
* Find the modification time of a member of
|
|
|
|
* an archive *in the archive* and place it in the
|
|
|
|
* member's GNode.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* Arch_UpdateMemberMTime
|
|
|
|
* Find the modification time of a member of
|
2020-11-07 19:39:21 +00:00
|
|
|
* an archive. Called when the member doesn't
|
|
|
|
* already exist. Looks in the archive for the
|
|
|
|
* modification time. Returns the modification
|
|
|
|
* time.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Arch_FindLib Search for a library along a path. The
|
|
|
|
* library name in the GNode should be in
|
|
|
|
* -l<name> format.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* Arch_LibOODate Decide if a library node is out-of-date.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2020-11-07 19:39:21 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/param.h>
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef HAVE_AR_H
|
2020-11-07 19:39:21 +00:00
|
|
|
#include <ar.h>
|
2012-06-08 21:57:36 +00:00
|
|
|
#else
|
|
|
|
struct ar_hdr {
|
|
|
|
char ar_name[16]; /* name */
|
|
|
|
char ar_date[12]; /* modification time */
|
|
|
|
char ar_uid[6]; /* user id */
|
|
|
|
char ar_gid[6]; /* group id */
|
|
|
|
char ar_mode[8]; /* octal file permissions */
|
|
|
|
char ar_size[10]; /* size in bytes */
|
|
|
|
#ifndef ARFMAG
|
|
|
|
#define ARFMAG "`\n"
|
|
|
|
#endif
|
|
|
|
char ar_fmag[2]; /* consistency check */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_RANLIB_H) && !(defined(__ELF__) || defined(NO_RANLIB))
|
2020-11-07 19:39:21 +00:00
|
|
|
#include <ranlib.h>
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UTIME_H
|
2020-11-07 19:39:21 +00:00
|
|
|
#include <utime.h>
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
#include "make.h"
|
|
|
|
#include "dir.h"
|
|
|
|
|
|
|
|
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
|
2023-04-24 23:44:30 +00:00
|
|
|
MAKE_RCSID("$NetBSD: arch.c,v 1.213 2023/02/14 21:08:00 rillig Exp $");
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
typedef struct List ArchList;
|
|
|
|
typedef struct ListNode ArchListNode;
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
static ArchList archives; /* The archives we've already examined */
|
1996-10-06 15:57:15 +00:00
|
|
|
|
|
|
|
typedef struct Arch {
|
2021-01-14 01:24:34 +00:00
|
|
|
char *name; /* Name of archive */
|
|
|
|
HashTable members; /* All the members of the archive described
|
2020-11-07 19:39:21 +00:00
|
|
|
* by <name, struct ar_hdr *> key/value pairs */
|
2021-01-14 01:24:34 +00:00
|
|
|
char *fnametab; /* Extended name table strings */
|
|
|
|
size_t fnamesize; /* Size of the string table */
|
1996-10-06 15:57:15 +00:00
|
|
|
} Arch;
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
static FILE *ArchFindMember(const char *, const char *,
|
|
|
|
struct ar_hdr *, const char *);
|
2012-06-08 21:57:36 +00:00
|
|
|
#if defined(__svr4__) || defined(__SVR4) || defined(__ELF__)
|
|
|
|
#define SVR4ARCHIVES
|
|
|
|
static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
|
|
|
|
#endif
|
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
#if defined(_AIX)
|
|
|
|
# define AR_NAME _ar_name.ar_name
|
|
|
|
# define AR_FMAG _ar_name.ar_fmag
|
|
|
|
# define SARMAG SAIAMAG
|
|
|
|
# define ARMAG AIAMAG
|
|
|
|
# define ARFMAG AIAFMAG
|
|
|
|
#endif
|
|
|
|
#ifndef AR_NAME
|
|
|
|
# define AR_NAME ar_name
|
|
|
|
#endif
|
|
|
|
#ifndef AR_DATE
|
|
|
|
# define AR_DATE ar_date
|
|
|
|
#endif
|
|
|
|
#ifndef AR_SIZE
|
|
|
|
# define AR_SIZE ar_size
|
|
|
|
#endif
|
|
|
|
#ifndef AR_FMAG
|
|
|
|
# define AR_FMAG ar_fmag
|
|
|
|
#endif
|
|
|
|
#ifndef ARMAG
|
|
|
|
# define ARMAG "!<arch>\n"
|
|
|
|
#endif
|
|
|
|
#ifndef SARMAG
|
|
|
|
# define SARMAG 8
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CLEANUP
|
1996-10-06 15:57:15 +00:00
|
|
|
static void
|
2012-06-08 21:57:36 +00:00
|
|
|
ArchFree(void *ap)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
Arch *a = ap;
|
|
|
|
HashIter hi;
|
|
|
|
|
|
|
|
/* Free memory from hash entries */
|
|
|
|
HashIter_Init(&hi, &a->members);
|
|
|
|
while (HashIter_Next(&hi) != NULL)
|
|
|
|
free(hi.entry->value);
|
|
|
|
|
|
|
|
free(a->name);
|
|
|
|
free(a->fnametab);
|
|
|
|
HashTable_Done(&a->members);
|
|
|
|
free(a);
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
/* Return "archive(member)". */
|
|
|
|
static char *
|
|
|
|
FullName(const char *archive, const char *member)
|
|
|
|
{
|
|
|
|
size_t len1 = strlen(archive);
|
|
|
|
size_t len3 = strlen(member);
|
|
|
|
char *result = bmake_malloc(len1 + 1 + len3 + 1 + 1);
|
|
|
|
memcpy(result, archive, len1);
|
|
|
|
memcpy(result + len1, "(", 1);
|
|
|
|
memcpy(result + len1 + 1, member, len3);
|
|
|
|
memcpy(result + len1 + 1 + len3, ")", 1 + 1);
|
|
|
|
return result;
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/*
|
|
|
|
* Parse an archive specification such as "archive.a(member1 member2.${EXT})",
|
2021-01-14 01:24:34 +00:00
|
|
|
* adding nodes for the expanded members to gns. Nodes are created as
|
2020-11-20 03:54:37 +00:00
|
|
|
* necessary.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2012-06-08 21:57:36 +00:00
|
|
|
* Input:
|
2020-11-20 03:54:37 +00:00
|
|
|
* pp The start of the specification.
|
2021-01-14 01:24:34 +00:00
|
|
|
* gns The list on which to place the nodes.
|
2021-02-11 01:51:11 +00:00
|
|
|
* scope The scope in which to expand variables.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* Output:
|
2021-06-25 18:16:24 +00:00
|
|
|
* return True if it was a valid specification.
|
2020-11-20 03:54:37 +00:00
|
|
|
* *pp Points to the first non-space after the archive spec.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-06-25 18:16:24 +00:00
|
|
|
bool
|
2021-02-11 01:51:11 +00:00
|
|
|
Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2022-02-05 20:03:50 +00:00
|
|
|
char *spec; /* For modifying some bytes of *pp */
|
|
|
|
const char *cp; /* Pointer into line */
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode *gn; /* New node */
|
2022-02-05 20:03:50 +00:00
|
|
|
FStr lib; /* Library-part of specification */
|
2021-12-18 07:27:22 +00:00
|
|
|
FStr mem; /* Member-part of specification */
|
2021-01-14 01:24:34 +00:00
|
|
|
char saveChar; /* Ending delimiter of member-name */
|
2022-02-05 20:03:50 +00:00
|
|
|
bool expandLib; /* Whether the parsed lib contains variable
|
|
|
|
* expressions that need to be expanded */
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
spec = *pp;
|
|
|
|
lib = FStr_InitRefer(spec);
|
|
|
|
expandLib = false;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
for (cp = lib.str; *cp != '(' && *cp != '\0';) {
|
2021-01-14 01:24:34 +00:00
|
|
|
if (*cp == '$') {
|
|
|
|
/* Expand nested variable expressions. */
|
|
|
|
/* XXX: This code can probably be shortened. */
|
|
|
|
const char *nested_p = cp;
|
|
|
|
FStr result;
|
2021-06-25 18:16:24 +00:00
|
|
|
bool isError;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
/* XXX: is expanded twice: once here and once below */
|
2023-04-24 23:44:30 +00:00
|
|
|
result = Var_Parse(&nested_p, scope, VARE_UNDEFERR);
|
2021-01-14 01:24:34 +00:00
|
|
|
/* TODO: handle errors */
|
|
|
|
isError = result.str == var_Error;
|
|
|
|
FStr_Done(&result);
|
|
|
|
if (isError)
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
expandLib = true;
|
2021-01-14 01:24:34 +00:00
|
|
|
cp += nested_p - cp;
|
|
|
|
} else
|
|
|
|
cp++;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
spec[cp++ - spec] = '\0';
|
|
|
|
if (expandLib)
|
|
|
|
Var_Expand(&lib, scope, VARE_UNDEFERR);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (;;) {
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* First skip to the start of the member's name, mark that
|
|
|
|
* place and skip to the end of it (either white-space or
|
|
|
|
* a close paren).
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-06-25 18:16:24 +00:00
|
|
|
bool doSubst = false;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
cpp_skip_whitespace(&cp);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
mem = FStr_InitRefer(cp);
|
2021-01-14 01:24:34 +00:00
|
|
|
while (*cp != '\0' && *cp != ')' && !ch_isspace(*cp)) {
|
|
|
|
if (*cp == '$') {
|
|
|
|
/* Expand nested variable expressions. */
|
2022-02-05 20:03:50 +00:00
|
|
|
/*
|
|
|
|
* XXX: This code can probably be shortened.
|
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
FStr result;
|
2021-06-25 18:16:24 +00:00
|
|
|
bool isError;
|
2021-01-14 01:24:34 +00:00
|
|
|
const char *nested_p = cp;
|
|
|
|
|
2023-04-24 23:44:30 +00:00
|
|
|
result = Var_Parse(&nested_p, scope,
|
|
|
|
VARE_UNDEFERR);
|
2021-01-14 01:24:34 +00:00
|
|
|
/* TODO: handle errors */
|
|
|
|
isError = result.str == var_Error;
|
|
|
|
FStr_Done(&result);
|
|
|
|
|
|
|
|
if (isError)
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
doSubst = true;
|
2021-01-14 01:24:34 +00:00
|
|
|
cp += nested_p - cp;
|
|
|
|
} else {
|
|
|
|
cp++;
|
|
|
|
}
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* If the specification ends without a closing parenthesis,
|
|
|
|
* chances are there's something wrong (like a missing
|
|
|
|
* backslash), so it's better to return failure than allow
|
|
|
|
* such things to happen
|
|
|
|
*/
|
|
|
|
if (*cp == '\0') {
|
|
|
|
Parse_Error(PARSE_FATAL,
|
2022-02-05 20:03:50 +00:00
|
|
|
"No closing parenthesis "
|
|
|
|
"in archive specification");
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* If we didn't move anywhere, we must be done
|
|
|
|
*/
|
2021-12-18 07:27:22 +00:00
|
|
|
if (cp == mem.str)
|
2021-01-14 01:24:34 +00:00
|
|
|
break;
|
2020-09-05 16:11:04 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
saveChar = *cp;
|
2022-02-05 20:03:50 +00:00
|
|
|
spec[cp - spec] = '\0';
|
2020-09-05 16:11:04 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* XXX: This should be taken care of intelligently by
|
|
|
|
* SuffExpandChildren, both for the archive and the member
|
|
|
|
* portions.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* If member contains variables, try and substitute for them.
|
2023-01-28 00:23:54 +00:00
|
|
|
* This slows down archive specs with dynamic sources, since
|
|
|
|
* they are (non-)substituted three times, but we need to do
|
|
|
|
* this since SuffExpandChildren calls us, otherwise we could
|
|
|
|
* assume the substitutions would be taken care of later.
|
2021-01-14 01:24:34 +00:00
|
|
|
*/
|
|
|
|
if (doSubst) {
|
|
|
|
char *fullName;
|
2022-02-05 20:03:50 +00:00
|
|
|
char *p;
|
2021-12-18 07:27:22 +00:00
|
|
|
const char *unexpandedMem = mem.str;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
Var_Expand(&mem, scope, VARE_UNDEFERR);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now form an archive spec and recurse to deal with
|
|
|
|
* nested variables and multi-word variable values.
|
|
|
|
*/
|
2022-02-05 20:03:50 +00:00
|
|
|
fullName = FullName(lib.str, mem.str);
|
2021-01-14 01:24:34 +00:00
|
|
|
p = fullName;
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
if (strcmp(mem.str, unexpandedMem) == 0) {
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Must contain dynamic sources, so we can't
|
|
|
|
* deal with it now. Just create an ARCHV node
|
|
|
|
* for the thing and let SuffExpandChildren
|
|
|
|
* handle it.
|
|
|
|
*/
|
|
|
|
gn = Targ_GetNode(fullName);
|
|
|
|
gn->type |= OP_ARCHV;
|
|
|
|
Lst_Append(gns, gn);
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
} else if (!Arch_ParseArchive(&p, gns, scope)) {
|
2021-01-14 01:24:34 +00:00
|
|
|
/* Error in nested call. */
|
|
|
|
free(fullName);
|
|
|
|
/* XXX: does unexpandedMemName leak? */
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
free(fullName);
|
|
|
|
/* XXX: does unexpandedMemName leak? */
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
} else if (Dir_HasWildcards(mem.str)) {
|
2021-01-14 01:24:34 +00:00
|
|
|
StringList members = LST_INIT;
|
2021-12-18 07:27:22 +00:00
|
|
|
SearchPath_Expand(&dirSearchPath, mem.str, &members);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
while (!Lst_IsEmpty(&members)) {
|
|
|
|
char *member = Lst_Dequeue(&members);
|
2022-02-05 20:03:50 +00:00
|
|
|
char *fullname = FullName(lib.str, member);
|
2021-01-14 01:24:34 +00:00
|
|
|
free(member);
|
|
|
|
|
|
|
|
gn = Targ_GetNode(fullname);
|
|
|
|
free(fullname);
|
|
|
|
|
|
|
|
gn->type |= OP_ARCHV;
|
|
|
|
Lst_Append(gns, gn);
|
|
|
|
}
|
|
|
|
Lst_Done(&members);
|
|
|
|
|
|
|
|
} else {
|
2022-02-05 20:03:50 +00:00
|
|
|
char *fullname = FullName(lib.str, mem.str);
|
2021-01-14 01:24:34 +00:00
|
|
|
gn = Targ_GetNode(fullname);
|
|
|
|
free(fullname);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We've found the node, but have to make sure the
|
|
|
|
* rest of the world knows it's an archive member,
|
|
|
|
* without having to constantly check for parentheses,
|
|
|
|
* so we type the thing with the OP_ARCHV bit before
|
|
|
|
* we place it on the end of the provided list.
|
|
|
|
*/
|
|
|
|
gn->type |= OP_ARCHV;
|
|
|
|
Lst_Append(gns, gn);
|
|
|
|
}
|
2021-12-18 07:27:22 +00:00
|
|
|
FStr_Done(&mem);
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
spec[cp - spec] = saveChar;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
FStr_Done(&lib);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
cp++; /* skip the ')' */
|
|
|
|
/* We promised that pp would be set up at the next non-space. */
|
2022-02-05 20:03:50 +00:00
|
|
|
cpp_skip_whitespace(&cp);
|
|
|
|
*pp += cp - *pp;
|
2021-06-25 18:16:24 +00:00
|
|
|
return true;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Locate a member of an archive, given the path of the archive and the path
|
2020-11-07 19:39:21 +00:00
|
|
|
* of the desired member.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2012-06-08 21:57:36 +00:00
|
|
|
* Input:
|
|
|
|
* archive Path to the archive
|
2020-11-07 19:39:21 +00:00
|
|
|
* member Name of member; only its basename is used.
|
2021-06-25 18:16:24 +00:00
|
|
|
* addToCache True if archive should be cached if not already so.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
1996-10-06 15:57:15 +00:00
|
|
|
* Results:
|
2020-11-20 03:54:37 +00:00
|
|
|
* The ar_hdr for the member, or NULL.
|
|
|
|
*
|
|
|
|
* See ArchFindMember for an almost identical copy of this code.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
|
|
|
static struct ar_hdr *
|
2021-06-25 18:16:24 +00:00
|
|
|
ArchStatMember(const char *archive, const char *member, bool addToCache)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
#define AR_MAX_NAME_LEN (sizeof arh.ar_name - 1)
|
|
|
|
FILE *arch;
|
|
|
|
size_t size; /* Size of archive member */
|
|
|
|
char magic[SARMAG];
|
|
|
|
ArchListNode *ln;
|
|
|
|
Arch *ar; /* Archive descriptor */
|
|
|
|
struct ar_hdr arh; /* archive-member header for reading archive */
|
|
|
|
char memName[MAXPATHLEN + 1];
|
|
|
|
/* Current member name while hashing. */
|
1996-10-06 15:57:15 +00:00
|
|
|
|
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* Because of space constraints and similar things, files are archived
|
|
|
|
* using their basename, not the entire path.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
member = str_basename(member);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (ln = archives.first; ln != NULL; ln = ln->next) {
|
|
|
|
const Arch *a = ln->datum;
|
|
|
|
if (strcmp(a->name, archive) == 0)
|
|
|
|
break;
|
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (ln != NULL) {
|
|
|
|
struct ar_hdr *hdr;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
ar = ln->datum;
|
|
|
|
hdr = HashTable_FindValue(&ar->members, member);
|
|
|
|
if (hdr != NULL)
|
|
|
|
return hdr;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
{
|
|
|
|
/* Try truncated name */
|
|
|
|
char copy[AR_MAX_NAME_LEN + 1];
|
|
|
|
size_t len = strlen(member);
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (len > AR_MAX_NAME_LEN) {
|
|
|
|
snprintf(copy, sizeof copy, "%s", member);
|
|
|
|
hdr = HashTable_FindValue(&ar->members, copy);
|
|
|
|
}
|
|
|
|
return hdr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!addToCache) {
|
|
|
|
/*
|
|
|
|
* Caller doesn't want the thing cached, just use
|
|
|
|
* ArchFindMember to read the header for the member out and
|
|
|
|
* close down the stream again. Since the archive is not to be
|
|
|
|
* cached, we assume there's no need to allocate extra room
|
|
|
|
* for the header we're returning, so just declare it static.
|
|
|
|
*/
|
|
|
|
static struct ar_hdr sarh;
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
arch = ArchFindMember(archive, member, &sarh, "r");
|
|
|
|
if (arch == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
fclose(arch);
|
|
|
|
return &sarh;
|
|
|
|
}
|
2020-09-05 16:11:04 +00:00
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* We don't have this archive on the list yet, so we want to find out
|
|
|
|
* everything that's in it and cache it so we can get at it quickly.
|
2020-11-20 03:54:37 +00:00
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
arch = fopen(archive, "r");
|
|
|
|
if (arch == NULL)
|
|
|
|
return NULL;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* We use the ARMAG string to make sure this is an archive we
|
|
|
|
* can handle...
|
2020-11-20 03:54:37 +00:00
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
if (fread(magic, SARMAG, 1, arch) != 1 ||
|
|
|
|
strncmp(magic, ARMAG, SARMAG) != 0) {
|
|
|
|
(void)fclose(arch);
|
|
|
|
return NULL;
|
2020-11-20 03:54:37 +00:00
|
|
|
}
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
ar = bmake_malloc(sizeof *ar);
|
|
|
|
ar->name = bmake_strdup(archive);
|
|
|
|
ar->fnametab = NULL;
|
|
|
|
ar->fnamesize = 0;
|
|
|
|
HashTable_Init(&ar->members);
|
|
|
|
memName[AR_MAX_NAME_LEN] = '\0';
|
|
|
|
|
|
|
|
while (fread(&arh, sizeof arh, 1, arch) == 1) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 > memName && *nameend == ' ')
|
|
|
|
nameend--;
|
|
|
|
nameend[1] = '\0';
|
|
|
|
|
|
|
|
#ifdef SVR4ARCHIVES
|
|
|
|
/*
|
|
|
|
* svr4 names are slash-terminated.
|
|
|
|
* Also svr4 extended the AR format.
|
|
|
|
*/
|
|
|
|
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';
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
#ifdef AR_EFMT1
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* 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])) {
|
|
|
|
|
2023-01-28 00:23:54 +00:00
|
|
|
size_t elen = (size_t)atoi(
|
|
|
|
memName + sizeof AR_EFMT1 - 1);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
if (elen > MAXPATHLEN)
|
2021-01-14 01:24:34 +00:00
|
|
|
goto badarch;
|
2021-12-18 07:27:22 +00:00
|
|
|
if (fread(memName, elen, 1, arch) != 1)
|
2021-01-14 01:24:34 +00:00
|
|
|
goto badarch;
|
|
|
|
memName[elen] = '\0';
|
2021-12-18 07:27:22 +00:00
|
|
|
if (fseek(arch, -(long)elen, SEEK_CUR) != 0)
|
2021-01-14 01:24:34 +00:00
|
|
|
goto badarch;
|
|
|
|
if (DEBUG(ARCH) || DEBUG(MAKE))
|
|
|
|
debug_printf(
|
|
|
|
"ArchStatMember: "
|
|
|
|
"Extended format entry for %s\n",
|
|
|
|
memName);
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
#endif
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
{
|
|
|
|
struct ar_hdr *cached_hdr = bmake_malloc(
|
|
|
|
sizeof *cached_hdr);
|
|
|
|
memcpy(cached_hdr, &arh, sizeof arh);
|
|
|
|
HashTable_Set(&ar->members, memName, cached_hdr);
|
|
|
|
}
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0)
|
|
|
|
goto badarch;
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
Lst_Append(&archives, ar);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Now that the archive has been read and cached, we can look into
|
|
|
|
* the addToCache table to find the desired member's header.
|
|
|
|
*/
|
|
|
|
return HashTable_FindValue(&ar->members, member);
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
badarch:
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
|
|
|
HashTable_Done(&ar->members);
|
|
|
|
free(ar->fnametab);
|
|
|
|
free(ar);
|
|
|
|
return NULL;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SVR4ARCHIVES
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Parse an SVR4 style entry that begins with a slash.
|
|
|
|
* If it is "//", then load the table of filenames.
|
|
|
|
* If it is "/<offset>", then try to substitute the long file name
|
|
|
|
* from offset of a table previously read.
|
|
|
|
* If a table is read, the file pointer is moved to the next archive member.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* -1: Bad data in archive
|
|
|
|
* 0: A table was loaded from the file
|
|
|
|
* 1: Name was successfully substituted from table
|
|
|
|
* 2: Name was not successfully substituted from table
|
|
|
|
*/
|
|
|
|
static int
|
2020-11-20 03:54:37 +00:00
|
|
|
ArchSVR4Entry(Arch *ar, char *inout_name, size_t size, FILE *arch)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
|
|
|
#define ARLONGNAMES1 "//"
|
|
|
|
#define ARLONGNAMES2 "/ARFILENAMES"
|
2021-01-14 01:24:34 +00:00
|
|
|
size_t entry;
|
|
|
|
char *ptr, *eptr;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (strncmp(inout_name, ARLONGNAMES1, sizeof ARLONGNAMES1 - 1) == 0 ||
|
|
|
|
strncmp(inout_name, ARLONGNAMES2, sizeof ARLONGNAMES2 - 1) == 0) {
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (ar->fnametab != NULL) {
|
|
|
|
DEBUG0(ARCH,
|
2022-02-05 20:03:50 +00:00
|
|
|
"Attempted to redefine an SVR4 name table\n");
|
2021-01-14 01:24:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a table of archive names, so we build one for
|
|
|
|
* ourselves
|
|
|
|
*/
|
|
|
|
ar->fnametab = bmake_malloc(size);
|
|
|
|
ar->fnamesize = size;
|
|
|
|
|
|
|
|
if (fread(ar->fnametab, size, 1, arch) != 1) {
|
|
|
|
DEBUG0(ARCH, "Reading an SVR4 name table failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
eptr = ar->fnametab + size;
|
|
|
|
for (entry = 0, ptr = ar->fnametab; ptr < eptr; ptr++)
|
|
|
|
if (*ptr == '/') {
|
|
|
|
entry++;
|
|
|
|
*ptr = '\0';
|
|
|
|
}
|
2022-02-05 20:03:50 +00:00
|
|
|
DEBUG1(ARCH,
|
|
|
|
"Found svr4 archive name table with %lu entries\n",
|
|
|
|
(unsigned long)entry);
|
2021-01-14 01:24:34 +00:00
|
|
|
return 0;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (inout_name[1] == ' ' || inout_name[1] == '\0')
|
|
|
|
return 2;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
entry = (size_t)strtol(&inout_name[1], &eptr, 0);
|
|
|
|
if ((*eptr != ' ' && *eptr != '\0') || eptr == &inout_name[1]) {
|
|
|
|
DEBUG1(ARCH, "Could not parse SVR4 name %s\n", inout_name);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if (entry >= ar->fnamesize) {
|
|
|
|
DEBUG2(ARCH, "SVR4 entry offset %s is greater than %lu\n",
|
2022-02-05 20:03:50 +00:00
|
|
|
inout_name, (unsigned long)ar->fnamesize);
|
2021-01-14 01:24:34 +00:00
|
|
|
return 2;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
DEBUG2(ARCH, "Replaced %s with %s\n", inout_name, &ar->fnametab[entry]);
|
|
|
|
|
|
|
|
snprintf(inout_name, MAXPATHLEN + 1, "%s", &ar->fnametab[entry]);
|
|
|
|
return 1;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
static bool
|
2020-11-20 03:54:37 +00:00
|
|
|
ArchiveMember_HasName(const struct ar_hdr *hdr,
|
|
|
|
const char *name, size_t namelen)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
const size_t ar_name_len = sizeof hdr->AR_NAME;
|
|
|
|
const char *ar_name = hdr->AR_NAME;
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (strncmp(ar_name, name, namelen) != 0)
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (namelen >= ar_name_len)
|
|
|
|
return namelen == ar_name_len;
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/* hdr->AR_NAME is space-padded to the right. */
|
|
|
|
if (ar_name[namelen] == ' ')
|
2021-06-25 18:16:24 +00:00
|
|
|
return true;
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
/*
|
|
|
|
* In archives created by GNU binutils 2.27, the member names end
|
|
|
|
* with a slash.
|
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
if (ar_name[namelen] == '/' &&
|
|
|
|
(namelen == ar_name_len || ar_name[namelen + 1] == ' '))
|
2021-06-25 18:16:24 +00:00
|
|
|
return true;
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2020-11-20 03:54:37 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Locate a member of an archive, given the path of the archive and the path
|
2020-11-20 03:54:37 +00:00
|
|
|
* of the desired member.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2012-06-08 21:57:36 +00:00
|
|
|
* Input:
|
|
|
|
* archive Path to the archive
|
|
|
|
* member Name of member. If it is a path, only the last
|
|
|
|
* component is used.
|
2020-11-20 03:54:37 +00:00
|
|
|
* out_arh Archive header to be filled in
|
|
|
|
* mode "r" for read-only access, "r+" for read-write access
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* Output:
|
|
|
|
* return The archive file, positioned at the start of the
|
|
|
|
* member's struct ar_hdr, or NULL if the member doesn't
|
|
|
|
* exist.
|
|
|
|
* *out_arh The current struct ar_hdr for member.
|
|
|
|
*
|
|
|
|
* See ArchStatMember for an almost identical copy of this code.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
|
|
|
static FILE *
|
2020-11-20 03:54:37 +00:00
|
|
|
ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh,
|
2020-11-07 19:39:21 +00:00
|
|
|
const char *mode)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
FILE *arch; /* Stream to archive */
|
|
|
|
int size; /* Size of archive member */
|
|
|
|
char magic[SARMAG];
|
|
|
|
size_t len;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
arch = fopen(archive, mode);
|
|
|
|
if (arch == NULL)
|
|
|
|
return NULL;
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* We use the ARMAG string to make sure this is an archive we
|
|
|
|
* can handle...
|
|
|
|
*/
|
|
|
|
if (fread(magic, SARMAG, 1, arch) != 1 ||
|
|
|
|
strncmp(magic, ARMAG, SARMAG) != 0) {
|
2020-11-07 19:39:21 +00:00
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* Because of space constraints and similar things, files are archived
|
|
|
|
* using their basename, not the entire path.
|
2020-11-07 19:39:21 +00:00
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
member = str_basename(member);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
len = strlen(member);
|
|
|
|
|
|
|
|
while (fread(out_arh, sizeof *out_arh, 1, arch) == 1) {
|
|
|
|
|
|
|
|
if (strncmp(out_arh->AR_FMAG, ARFMAG,
|
|
|
|
sizeof out_arh->AR_FMAG) != 0) {
|
|
|
|
/*
|
|
|
|
* The header is bogus, so the archive is bad
|
|
|
|
* and there's no way we can recover...
|
|
|
|
*/
|
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG5(ARCH, "Reading archive %s member %.*s mtime %.*s\n",
|
2022-02-05 20:03:50 +00:00
|
|
|
archive,
|
|
|
|
(int)sizeof out_arh->AR_NAME, out_arh->AR_NAME,
|
|
|
|
(int)sizeof out_arh->ar_date, out_arh->ar_date);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
if (ArchiveMember_HasName(out_arh, member, len)) {
|
|
|
|
/*
|
|
|
|
* To make life easier for callers that want to update
|
|
|
|
* the archive, we reposition the file at the start of
|
|
|
|
* the header we just read before we return the
|
|
|
|
* stream. In a more general situation, it might be
|
|
|
|
* better to leave the file at the actual member,
|
|
|
|
* rather than its header, but not here.
|
|
|
|
*/
|
|
|
|
if (fseek(arch, -(long)sizeof *out_arh, SEEK_CUR) !=
|
|
|
|
0) {
|
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return arch;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef AR_EFMT1
|
|
|
|
/*
|
|
|
|
* BSD 4.4 extended AR format: #1/<namelen>, with name as the
|
|
|
|
* first <namelen> bytes of the file
|
|
|
|
*/
|
|
|
|
if (strncmp(out_arh->AR_NAME, AR_EFMT1, sizeof AR_EFMT1 - 1) ==
|
|
|
|
0 &&
|
|
|
|
(ch_isdigit(out_arh->AR_NAME[sizeof AR_EFMT1 - 1]))) {
|
2023-01-28 00:23:54 +00:00
|
|
|
size_t elen = (size_t)atoi(
|
2021-12-18 07:27:22 +00:00
|
|
|
&out_arh->AR_NAME[sizeof AR_EFMT1 - 1]);
|
2021-01-14 01:24:34 +00:00
|
|
|
char ename[MAXPATHLEN + 1];
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
if (elen > MAXPATHLEN) {
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-12-18 07:27:22 +00:00
|
|
|
if (fread(ename, elen, 1, arch) != 1) {
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ename[elen] = '\0';
|
|
|
|
if (DEBUG(ARCH) || DEBUG(MAKE))
|
|
|
|
debug_printf(
|
|
|
|
"ArchFindMember: "
|
|
|
|
"Extended format entry for %s\n",
|
|
|
|
ename);
|
|
|
|
if (strncmp(ename, member, len) == 0) {
|
|
|
|
/* Found as extended name */
|
|
|
|
if (fseek(arch,
|
2021-12-18 07:27:22 +00:00
|
|
|
-(long)(sizeof(struct ar_hdr) - elen),
|
|
|
|
SEEK_CUR) != 0) {
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return arch;
|
|
|
|
}
|
2021-12-18 07:27:22 +00:00
|
|
|
if (fseek(arch, -(long)elen, SEEK_CUR) != 0) {
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-04-20 23:12:37 +00:00
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
#endif
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* This isn't the member we're after, so 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.
|
|
|
|
*/
|
|
|
|
out_arh->AR_SIZE[sizeof out_arh->AR_SIZE - 1] = '\0';
|
|
|
|
size = (int)strtol(out_arh->AR_SIZE, NULL, 10);
|
2021-12-18 07:27:22 +00:00
|
|
|
if (fseek(arch, (size + 1) & ~1L, SEEK_CUR) != 0) {
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
fclose(arch);
|
|
|
|
return NULL;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Touch a member of an archive, on disk.
|
2020-11-20 03:54:37 +00:00
|
|
|
* The GNode's modification time is left as-is.
|
|
|
|
*
|
|
|
|
* The st_mtime of the entire archive is also changed.
|
|
|
|
* For a library, it may be required to run ranlib after this.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2012-06-08 21:57:36 +00:00
|
|
|
* Input:
|
|
|
|
* gn Node of member to touch
|
|
|
|
*
|
1996-10-06 15:57:15 +00:00
|
|
|
* Results:
|
|
|
|
* The 'time' field of the member's header is updated.
|
|
|
|
*/
|
|
|
|
void
|
2012-06-08 21:57:36 +00:00
|
|
|
Arch_Touch(GNode *gn)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
FILE *f;
|
|
|
|
struct ar_hdr arh;
|
2016-03-11 00:37:02 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
f = ArchFindMember(GNode_VarArchive(gn), GNode_VarMember(gn), &arh,
|
2022-02-05 20:03:50 +00:00
|
|
|
"r+");
|
2021-01-14 01:24:34 +00:00
|
|
|
if (f == NULL)
|
|
|
|
return;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now);
|
|
|
|
(void)fwrite(&arh, sizeof arh, 1, f);
|
|
|
|
fclose(f); /* TODO: handle errors */
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Given a node which represents a library, touch the thing, making sure that
|
2020-11-20 03:54:37 +00:00
|
|
|
* the table of contents is also touched.
|
2020-09-05 16:11:04 +00:00
|
|
|
*
|
|
|
|
* Both the modification time of the library and of the RANLIBMAG member are
|
2021-01-14 01:24:34 +00:00
|
|
|
* set to 'now'.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1996-10-06 15:57:15 +00:00
|
|
|
void
|
2020-11-20 03:54:37 +00:00
|
|
|
Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef RANLIBMAG
|
2021-01-14 01:24:34 +00:00
|
|
|
FILE *f;
|
|
|
|
struct ar_hdr arh; /* Header describing table of contents */
|
|
|
|
struct utimbuf times;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
f = ArchFindMember(gn->path, RANLIBMAG, &arh, "r+");
|
|
|
|
if (f == NULL)
|
|
|
|
return;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now);
|
|
|
|
(void)fwrite(&arh, sizeof arh, 1, f);
|
|
|
|
fclose(f); /* TODO: handle errors */
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
times.actime = times.modtime = now;
|
|
|
|
utime(gn->path, ×); /* TODO: handle errors */
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Update the mtime of the GNode with the mtime from the archive member on
|
|
|
|
* disk (or in the cache).
|
|
|
|
*/
|
2020-11-20 03:54:37 +00:00
|
|
|
void
|
|
|
|
Arch_UpdateMTime(GNode *gn)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
struct ar_hdr *arh;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
arh = ArchStatMember(GNode_VarArchive(gn), GNode_VarMember(gn), true);
|
2021-01-14 01:24:34 +00:00
|
|
|
if (arh != NULL)
|
|
|
|
gn->mtime = (time_t)strtol(arh->ar_date, NULL, 10);
|
|
|
|
else
|
|
|
|
gn->mtime = 0;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Given a nonexistent archive member's node, update gn->mtime from its
|
|
|
|
* archived form, if it exists.
|
|
|
|
*/
|
2020-11-20 03:54:37 +00:00
|
|
|
void
|
|
|
|
Arch_UpdateMemberMTime(GNode *gn)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNodeListNode *ln;
|
|
|
|
|
|
|
|
for (ln = gn->parents.first; ln != NULL; ln = ln->next) {
|
|
|
|
GNode *pgn = ln->datum;
|
|
|
|
|
|
|
|
if (pgn->type & OP_ARCHV) {
|
|
|
|
/*
|
|
|
|
* If the parent is an archive specification and is
|
|
|
|
* being made and its member's name matches the name
|
|
|
|
* of the node we were given, record the modification
|
|
|
|
* time of the parent in the child. We keep searching
|
|
|
|
* its parents in case some other parent requires this
|
|
|
|
* child to exist.
|
|
|
|
*/
|
|
|
|
const char *nameStart = strchr(pgn->name, '(') + 1;
|
|
|
|
const char *nameEnd = strchr(nameStart, ')');
|
|
|
|
size_t nameLen = (size_t)(nameEnd - nameStart);
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
if (pgn->flags.remake &&
|
2021-01-14 01:24:34 +00:00
|
|
|
strncmp(nameStart, gn->name, nameLen) == 0) {
|
|
|
|
Arch_UpdateMTime(pgn);
|
|
|
|
gn->mtime = pgn->mtime;
|
|
|
|
}
|
2021-12-18 07:27:22 +00:00
|
|
|
} else if (pgn->flags.remake) {
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Something which isn't a library depends on the
|
|
|
|
* existence of this target, so it needs to exist.
|
|
|
|
*/
|
|
|
|
gn->mtime = 0;
|
|
|
|
break;
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Search for a library along the given search path.
|
2020-09-05 16:11:04 +00:00
|
|
|
*
|
|
|
|
* The node's 'path' field is set to the found path (including the
|
|
|
|
* actual file name, not -l...). If the system can handle the -L
|
|
|
|
* flag when linking (or we cannot find the library), we assume that
|
|
|
|
* the user has placed the .LIBS variable in the final linking
|
|
|
|
* command (or the linker will know where to find it) and set the
|
|
|
|
* TARGET variable for this node to be the node's name. Otherwise,
|
|
|
|
* we set the TARGET variable to be the full path of the library,
|
|
|
|
* as returned by Dir_FindFile.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
|
|
|
* Input:
|
|
|
|
* gn Node of library to find
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
|
|
|
void
|
2020-11-07 19:39:21 +00:00
|
|
|
Arch_FindLib(GNode *gn, SearchPath *path)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
char *libName = str_concat3("lib", gn->name + 2, ".a");
|
|
|
|
gn->path = Dir_FindFile(libName, path);
|
|
|
|
free(libName);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
|
|
|
#ifdef LIBRARIES
|
2021-02-11 01:51:11 +00:00
|
|
|
Var_Set(gn, TARGET, gn->name);
|
1996-10-06 15:57:15 +00:00
|
|
|
#else
|
2021-02-11 01:51:11 +00:00
|
|
|
Var_Set(gn, TARGET, GNode_Path(gn));
|
2020-11-07 19:39:21 +00:00
|
|
|
#endif
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Decide if a node with the OP_LIB attribute is out-of-date. Called from
|
2020-11-20 03:54:37 +00:00
|
|
|
* GNode_IsOODate to make its life easier.
|
|
|
|
* The library is cached if it hasn't been already.
|
2020-09-05 16:11:04 +00:00
|
|
|
*
|
|
|
|
* There are several ways for a library to be out-of-date that are
|
|
|
|
* not available to ordinary files. In addition, there are ways
|
|
|
|
* that are open to regular files that are not available to
|
2020-11-20 03:54:37 +00:00
|
|
|
* libraries.
|
|
|
|
*
|
|
|
|
* A library that is only used as a source is never
|
2020-09-05 16:11:04 +00:00
|
|
|
* considered out-of-date by itself. This does not preclude the
|
|
|
|
* library's modification time from making its parent be out-of-date.
|
|
|
|
* A library will be considered out-of-date for any of these reasons,
|
|
|
|
* given that it is a target on a dependency line somewhere:
|
|
|
|
*
|
|
|
|
* Its modification time is less than that of one of its sources
|
2020-11-07 19:39:21 +00:00
|
|
|
* (gn->mtime < gn->youngestChild->mtime).
|
2020-09-05 16:11:04 +00:00
|
|
|
*
|
|
|
|
* Its modification time is greater than the time at which the make
|
|
|
|
* began (i.e. it's been modified in the course of the make, probably
|
|
|
|
* by archiving).
|
|
|
|
*
|
|
|
|
* The modification time of one of its sources is greater than the one
|
|
|
|
* of its RANLIBMAG member (i.e. its table of contents is out-of-date).
|
2020-11-20 03:54:37 +00:00
|
|
|
* We don't compare the archive time vs. TOC time because they can be
|
2020-09-05 16:11:04 +00:00
|
|
|
* too close. In my opinion we should not bother with the TOC at all
|
|
|
|
* since this is used by 'ar' rules that affect the data contents of the
|
|
|
|
* archive, not by ranlib rules, which affect the TOC.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-06-25 18:16:24 +00:00
|
|
|
bool
|
2012-06-08 21:57:36 +00:00
|
|
|
Arch_LibOODate(GNode *gn)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
if (gn->type & OP_PHONY) {
|
2021-12-18 07:27:22 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
} else if (!GNode_IsTarget(gn) && Lst_IsEmpty(&gn->children)) {
|
2021-12-18 07:27:22 +00:00
|
|
|
return false;
|
2021-01-14 01:24:34 +00:00
|
|
|
} else if ((!Lst_IsEmpty(&gn->children) && gn->youngestChild == NULL) ||
|
|
|
|
(gn->mtime > now) ||
|
|
|
|
(gn->youngestChild != NULL &&
|
|
|
|
gn->mtime < gn->youngestChild->mtime)) {
|
2021-12-18 07:27:22 +00:00
|
|
|
return true;
|
1996-10-06 15:57:15 +00:00
|
|
|
} else {
|
2021-12-18 07:27:22 +00:00
|
|
|
return RanlibOODate(gn);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/* Initialize the archives module. */
|
1996-10-06 15:57:15 +00:00
|
|
|
void
|
2012-06-08 21:57:36 +00:00
|
|
|
Arch_Init(void)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
Lst_Init(&archives);
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/* Clean up the archives module. */
|
1996-10-06 15:57:15 +00:00
|
|
|
void
|
2012-06-08 21:57:36 +00:00
|
|
|
Arch_End(void)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef CLEANUP
|
2021-01-14 01:24:34 +00:00
|
|
|
Lst_DoneCall(&archives, ArchFree);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
bool
|
2012-06-08 21:57:36 +00:00
|
|
|
Arch_IsLib(GNode *gn)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
static const char armag[] = "!<arch>\n";
|
|
|
|
char buf[sizeof armag - 1];
|
|
|
|
int fd;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if ((fd = open(gn->path, O_RDONLY)) == -1)
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (read(fd, buf, sizeof buf) != sizeof buf) {
|
|
|
|
(void)close(fd);
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
(void)close(fd);
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
return memcmp(buf, armag, sizeof buf) == 0;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|