+2009-03-11 Borut Razem <borut.razem AT siol.net>
+
+ * as/asranlib/asranlib.c: retain the original file mode
+
2009-03-10 Borut Razem <borut.razem AT siol.net>
* src/mcs51/gen.c, src/z80/gen.c, src/hc08/gen.c, src/ds390/gen.c,
int nsym;
int symtab_size;
char tmpfile[] = "arXXXXXX";
+ struct stat stat_buf;
+ int can_stat;
+ /* TODO: create tmpfile in temporery directory (TMP, TMPDIR, /usr/tmp, /tmp) */
#ifdef _WIN32
if (NULL == _mktemp (tmpfile) || NULL == (outfp = fopen (tmpfile, "wb")))
{
fwrite (buf, 1, sizeof (buf), outfp);
}
-
for (symp = symlist; symp; symp = symp->next)
{
fputs (symp->name, outfp);
putc (pad, outfp);
fclose (outfp);
+
+ if (0 != fstat(fileno(infp), &stat_buf))
+ {
+ fprintf (stderr, "asranlib: can't stat %s: ", infp);
+ perror (NULL);
+ fclose (infp);
+ can_stat = 0;
+ }
+ else
+ can_stat = 1;
+
fclose (infp);
if (0 != remove (archive))
fprintf (stderr, "asranlib: can't rename %s to %s: ", tmpfile, archive);
perror (NULL);
}
+ else if (!can_stat || 0 != chmod (archive, stat_buf.st_mode))
+ {
+ fprintf (stderr, "asranlib: can't chmod %s: ", archive);
+ perror (NULL);
+ }
}
else
fclose (infp);