This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: ar -M temporary file bug
- To: binutils at sources dot redhat dot com
- Subject: PATCH: ar -M temporary file bug
- From: Earl Chew <earl_chew at agilent dot com>
- Date: Fri, 19 Oct 2001 12:37:04 -0700
- Organization: Agilent Technologies
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;
}