bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ar 2.10.91 and command scripts


From: Eli Zaretskii
Subject: Re: ar 2.10.91 and command scripts
Date: Thu, 12 Jul 2001 21:54:15 +0300

> From: "Zagorodnev, Grigory" <address@hidden>
> Date: Thu, 12 Jul 2001 20:46:02 +0400
>
>       address@hidden tmp]$ ar -M < script 
>       /usr/bin/ar: Can't open output archive tmp-./foo.a
> 
> As I can see, reason of problem is in approach for temporary name creation.
> Previous versions of ar use template "%s-tmp" for name generation but now it
> is the "tmp-%s".
> According to note in ar source code it was done to support DOS-like file
> systems with 8.3 name format.
> 
> Anyway, I want to ask couple questions:
>       - Is this problem already known?
>       - Is it already fixed in the latest versions? 

No and no, at least this bug is stil in Binutils 2.11.

>       - If not, are you going to fix it?

Please try the change below:


2001-07-12  Eli Zaretskii  <address@hidden>

        * arsup.c (ar_open): Prepend "tmp-" only to the file's basename.

--- binutils/arsup.c~0  Sun May 28 06:57:50 2000
+++ binutils/arsup.c    Thu Jul 12 21:51:12 2001
@@ -160,10 +160,20 @@ DEFUN(ar_open,(name, t),
 
 {
   char *tname = (char *) xmalloc (strlen (name) + 10);
+  char *s = name;
   real_name = name;
-  /* Prepend tmp- to the beginning, to avoid file-name clashes after
-     truncation on filesystems with limited namespaces (DOS).  */
-  sprintf(tname, "tmp-%s", name);
+  /* Prepend tmp- to the beginning of the file's basename, to avoid
+     file-name clashes after truncation on filesystems with limited
+     namespaces (DOS).  */
+  while (*s && !IS_DIR_SEPARATOR (*s))
+    s++;
+  if (*s)
+    {
+      strncpy(tname, name, s - name);
+      sprintf(tname + (s - name), "%ctmp-%s", *s, s + 1);
+    }
+  else
+    sprintf(tname, "tmp-%s", name);
   obfd = bfd_openw(tname, NULL);
 
   if (!obfd) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]