This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: ar -M temporary file bug


This patch fixes a problem using ar -M. The command CREATE x/y.a fails
in recent versions of ar. Previous versions would create a temporary
file named x/y.a-tmp.

This would fail on DOS file systems, so a later patch was made to
instead use a tmp- prefix, instead of a -tmp suffix. This works
for CREATE z.a. A temporary file named tmp-z.a being the result.

This strategy fails for CREATE x/y.a since it attempts to create
a temporary file named tmp-x/y.a.

This patch applies the tmp- prefix to the basename, rather than
the entire pathname. Thus CREATE x/y.a results in the temporary
file named x/tmp-y.a.

The patch accommodates / and \ path separators, and a corresponding
change to the definition of FILENAME is necessary to allow
DOS \ path separators to be parsed.

Earl
------------------------------------------------------------------------
For binutils/ChangeLog:

        * arsup.h (ar_open): Create temporary filename by prepending
        tmp- to the basename, rather than the entire pathname.
        * arlex.l: Extend FILENAME definition to allow for DOS
        path separators.

--- arsup.c.orig	Sun May 28 03:57:50 2000
+++ arsup.c	Fri Oct 19 11:27:33 2001
@@ -160,10 +160,13 @@
 
 {
   char *tname = (char *) xmalloc (strlen (name) + 10);
+  char *basename = strchr (name, '\0');
   real_name = name;
-  /* Prepend tmp- to the beginning, to avoid file-name clashes after
+  /* Prepend tmp- to the beginning of the file name, to avoid clashes
after
      truncation on filesystems with limited namespaces (DOS).  */
-  sprintf(tname, "tmp-%s", name);
+  while (basename != name && ! IS_DIR_SEPARATOR(basename[-1]))
+    basename--;
+  sprintf(tname, "%.*stmp-%s", basename-name, name, basename);
   obfd = bfd_openw(tname, NULL);
 
   if (!obfd) {

--- arlex.l.orig	Tue May 23 00:57:58 2000
+++ arlex.l	Fri Oct 19 11:20:53 2001
@@ -71,7 +71,7 @@
 "("             { return '('; }
 ")"             { return ')'; }
 ","             { return ','; }
-[A-Za-z0-9/$:.\-\_]+  { 	
+[A-Za-z0-9/\\$:.\-\_]+  { 	
 		yylval.name =  xstrdup (yytext);
 		return FILENAME;
 		}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]