+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().
#include "../bfd/libbfd.h"
#include "arsup.h"
#include <stdio.h>
-#ifdef USG
+#ifdef POSIX_UTIME
+#include <utime.h>
+#else /* ! POSIX_UTIME */
+#ifdef USE_UTIME
#include <time.h>
-#else
+#else /* ! USE_UTIME */
#include <sys/time.h>
-#endif
+#endif /* ! USE_UTIME */
+#endif /* ! POSIX_UTIME */
#include <errno.h>
#ifndef errno
extern int errno;
/** Globals and flags */
-extern *program_version;
char *program_name = NULL;
bfd *inarch; /* The input arch we're manipulating */
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);
}
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.
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];
}
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();
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 */
}
}
{
print_arelt_descr(stdout,abfd, verbose);
}
-
-
-