From 42b600fa4610bdf55fd9641984e0029cfad96c94 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 2 Nov 1992 20:43:55 +0000 Subject: [PATCH] Mon Nov 2 12:36:14 1992 Ian Lance Taylor (ian@cygnus.com) * config/delta88.mh, config/hp300.mh, config/hppahpux.mh, config/i386v.mh: removed -DUSG from HDEFINES. hosts/delta88.h, hosts/hp300.h, hosts/hppahpux.h, hosts/i386v.h: defined USE_UTIME. hosts/i386v.h: don't define POSIX_UTIME. --- binutils/ChangeLog | 10 +++++++ binutils/ar.c | 73 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 65 insertions(+), 18 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 3380475482..463d46f549 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,13 @@ +Mon Nov 2 12:42:11 1992 Ian Lance Taylor (ian@cygnus.com) + + * ar.c (extract_file): instead of checking USG: if POSIX_UTIME, + use utime and utimbuf structure, otherwise if USE_UTIME use utime + and array of two longs, otherwise use utimes. + +Thu Oct 15 13:57:35 1992 Per Bothner (bothner@cygnus.com) + + * binutils.tex: Document yesterday's changes to strip and copy. + Wed Oct 14 13:22:14 1992 Per Bothner (bothner@cygnus.com) * copy.c: Re-do command-line parsing to use getopt_long(). diff --git a/binutils/ar.c b/binutils/ar.c index 4a033a0f1e..2dec01458d 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -31,11 +31,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "../bfd/libbfd.h" #include "arsup.h" #include -#ifdef USG +#ifdef POSIX_UTIME +#include +#else /* ! POSIX_UTIME */ +#ifdef USE_UTIME #include -#else +#else /* ! USE_UTIME */ #include -#endif +#endif /* ! USE_UTIME */ +#endif /* ! POSIX_UTIME */ #include #ifndef errno extern int errno; @@ -56,7 +60,6 @@ PROTO(void, ranlib_only, (char *archname)); /** Globals and flags */ -extern *program_version; char *program_name = NULL; bfd *inarch; /* The input arch we're manipulating */ @@ -155,11 +158,20 @@ DEFUN(map_over_members,(function, files, count), for (; count > 0; files++, count--) { boolean found = false; for (head = inarch->next; head; head = head->next) - if ((head->filename != NULL) && - (!strcmp(*files, head->filename))) { - found = true; - function(head); - } + { + if (head->filename == NULL) + { + /* Some archive formats don't get the filenames filled in + 'till the elements are opened */ + struct stat buf; + bfd_stat_arch_elt(head, &buf); + } + if ((head->filename != NULL) && + (!strcmp(*files, head->filename))) { + found = true; + function(head); + } + } if (!found) fprintf(stderr, "No entry %s in archive.\n", *files); } @@ -168,6 +180,13 @@ DEFUN(map_over_members,(function, files, count), boolean operation_alters_arch = false; +void +do_show_version () +{ + extern char *program_version; + printf ("%s version %s\n", program_name, program_version); +} + /* The option parsing should be in its own function. It will be when I have getopt working. @@ -206,14 +225,22 @@ main(argc, argv) if (is_ranlib > 0 || (is_ranlib < 0 && strcmp(temp, "ranlib") == 0)) { if (argc < 2) fatal("Too few command arguments."); - ranlib_only(argv[1]); + arg_ptr = argv[1]; + if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "-v") == 0) { + do_show_version(); + if (argc == 2) + exit(0); + arg_ptr = argv[2]; + } + ranlib_only(arg_ptr); } if (argc == 2 && strcmp(argv[1],"-M") == 0) { mri_emul(); exit(0); } - if (argc < 3) + + if (argc < 2) fatal("Too few command arguments."); arg_ptr = argv[1]; @@ -298,7 +325,13 @@ main(argc, argv) } if (show_version) - printf ("%s version %s\n", program_name, program_version); + do_show_version(); + + if (argc < 3) + if (show_version) + exit(0); + else + fatal("Too few command arguments."); if (mri_mode) { mri_emul(); @@ -549,19 +582,26 @@ extract_file(abfd) chmod(abfd->filename, buf.st_mode); if (preserve_dates) { -#ifdef USG +#ifdef POSIX_UTIME + struct utimbuf tb; + tb.actime = buf.st_mtime; + tb.modtime = buf.st_mtime; + utime(abfd->filename, tb); /* FIXME check result */ +#else /* ! POSIX_UTIME */ +#ifdef USE_UTIME long tb[2]; tb[0] = buf.st_mtime; tb[1] = buf.st_mtime; utime(abfd->filename, tb); /* FIXME check result */ -#else +#else /* ! USE_UTIME */ struct timeval tv[2]; tv[0].tv_sec = buf.st_mtime; tv[0].tv_usec = 0; tv[1].tv_sec = buf.st_mtime; tv[1].tv_usec = 0; utimes(abfd->filename, tv); /* FIXME check result */ -#endif +#endif /* ! USE_UTIME */ +#endif /* ! POSIX_UTIME */ } } @@ -948,6 +988,3 @@ print_descr(abfd) { print_arelt_descr(stdout,abfd, verbose); } - - - -- 2.34.1