Deleted Added
sdiff udiff text old ( 103503 ) new ( 103508 )
full compact
1/*
2 * Copyright (c) 1988, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1989 by Berkeley Softworks
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.

--- 25 unchanged lines hidden (view full) ---

34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)arch.c 8.2 (Berkeley) 1/2/94
39 */
40
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: head/usr.bin/make/arch.c 103508 2002-09-17 22:31:26Z jmallett $");
43
44/*-
45 * arch.c --
46 * Functions to manipulate libraries, archives and their members.
47 *
48 * Once again, cacheing/hashing comes into play in the manipulation
49 * of archives. The first time an archive is referenced, all of its members'
50 * headers are read and hashed and the archive closed again. All hashed

--- 565 unchanged lines hidden (view full) ---

616 unsigned int elen = atoi(&memName[sizeof(AR_EFMT1)-1]);
617
618 if (elen > MAXPATHLEN)
619 goto badarch;
620 if (fread (memName, elen, 1, arch) != 1)
621 goto badarch;
622 memName[elen] = '\0';
623 fseek (arch, -elen, SEEK_CUR);
624 /* XXX Multiple levels may be asked for, make this conditional
625 * on one, and use DEBUGF.
626 */
627 if (DEBUG(ARCH) || DEBUG(MAKE)) {
628 fprintf(stderr, "ArchStat: Extended format entry for %s\n", memName);
629 }
630 }
631#endif
632
633 he = Hash_CreateEntry (&ar->members, memName, NULL);
634 Hash_SetValue (he, (void *)emalloc (sizeof (struct ar_hdr)));
635 memcpy (Hash_GetValue (he), &arh,
636 sizeof (struct ar_hdr));

--- 57 unchanged lines hidden (view full) ---

694#define ARLONGNAMES2 "/ARFILENAMES"
695 size_t entry;
696 char *ptr, *eptr;
697
698 if (strncmp(name, ARLONGNAMES1, sizeof(ARLONGNAMES1) - 1) == 0 ||
699 strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) {
700
701 if (ar->fnametab != NULL) {
702 DEBUGF(ARCH, "Attempted to redefine an SVR4 name table\n");
703 return -1;
704 }
705
706 /*
707 * This is a table of archive names, so we build one for
708 * ourselves
709 */
710 ar->fnametab = emalloc(size);
711 ar->fnamesize = size;
712
713 if (fread(ar->fnametab, size, 1, arch) != 1) {
714 DEBUGF(ARCH, "Reading an SVR4 name table failed\n");
715 return -1;
716 }
717 eptr = ar->fnametab + size;
718 for (entry = 0, ptr = ar->fnametab; ptr < eptr; ptr++)
719 switch (*ptr) {
720 case '/':
721 entry++;
722 *ptr = '\0';
723 break;
724
725 case '\n':
726 break;
727
728 default:
729 break;
730 }
731 DEBUGF(ARCH, "Found svr4 archive name table with %zu entries\n", entry);
732 return 0;
733 }
734
735 if (name[1] == ' ' || name[1] == '\0')
736 return 2;
737
738 entry = (size_t) strtol(&name[1], &eptr, 0);
739 if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
740 DEBUGF(ARCH, "Could not parse SVR4 name %s\n", name);
741 return 2;
742 }
743 if (entry >= ar->fnamesize) {
744 DEBUGF(ARCH, "SVR4 entry offset %s is greater than %zu\n",
745 name, ar->fnamesize);
746 return 2;
747 }
748
749 DEBUGF(ARCH, "Replaced %s with %s\n", name, &ar->fnametab[entry]);
750
751 (void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
752 name[MAXPATHLEN] = '\0';
753 return 1;
754}
755#endif
756
757

--- 104 unchanged lines hidden (view full) ---

862 fclose (arch);
863 return NULL;
864 }
865 if (fread (ename, elen, 1, arch) != 1) {
866 fclose (arch);
867 return NULL;
868 }
869 ename[elen] = '\0';
870 /*
871 * XXX choose one.
872 */
873 if (DEBUG(ARCH) || DEBUG(MAKE)) {
874 printf("ArchFind: Extended format entry for %s\n", ename);
875 }
876 if (strncmp(ename, member, len) == 0) {
877 /* Found as extended name */
878 fseek (arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
879 return (arch);
880 }

--- 289 unchanged lines hidden (view full) ---

1170 struct ar_hdr *arhPtr; /* Header for __.SYMDEF */
1171 int modTimeTOC; /* The table-of-contents's mod time */
1172
1173 arhPtr = ArchStatMember (gn->path, RANLIBMAG, FALSE);
1174
1175 if (arhPtr != NULL) {
1176 modTimeTOC = (int) strtol(arhPtr->ar_date, NULL, 10);
1177
1178 /* XXX choose one. */
1179 if (DEBUG(ARCH) || DEBUG(MAKE)) {
1180 printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
1181 }
1182 oodate = (gn->cmtime > modTimeTOC);
1183 } else {
1184 /*
1185 * A library w/o a table of contents is out-of-date
1186 */

--- 51 unchanged lines hidden ---