2007-10-07 Jim Meyering <meyering@redhat.com>
+ Don't let a helper function modify errno.
+ * src/remove.c (full_filename_): Save and restore errno.
+ Spotted by Bruno Haible.
+
Reflect 2->3 GPL copyright version update in gnulib.
* gl/lib/tempname.h: Update copyright from gnulib.
* gl/lib/tempname.c: Likewise.
/* Using the global directory name obstack, create the full name FILENAME.
Return it in sometimes-realloc'd space that should not be freed by the
caller. Realloc as necessary. If realloc fails, use a static buffer
- and put as long a suffix in that buffer as possible. */
+ and put as long a suffix in that buffer as possible. Be careful not
+ to change errno. */
#define full_filename(Filename) full_filename_ (ds, Filename)
static char *
{
static char *buf = NULL;
static size_t n_allocated = 0;
+ int saved_errno = errno;
size_t dir_len = obstack_object_size (&ds->dir_stack);
char *dir_name = obstack_base (&ds->dir_stack);
memcpy (static_buf, ELLIPSES_PREFIX,
sizeof (ELLIPSES_PREFIX) - 1);
}
+ errno = saved_errno;
return p;
}
assert (strlen (buf) + 1 == n_bytes_needed);
}
+ errno = saved_errno;
return buf;
}