mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-22 01:06:03 +00:00
Work over a bug in gnulib error()
The error() function from glibc correctly prefixes each message it prints with program_name as set by set_program_name. However, its replacement from gnulib, which is linked in on systems where this function is not available, prints the name returned by getprogname() instead. Due to this messages output by tar subprocess (which sets its program name to 'tar (child)') become indiscernible from those printed by the main process. In particular, this breaks the remfiles01.at and remfiles02.at test cases. * configure.ac: Define ENABLE_ERROR_PRINT_PROGNAME if using gnulib error(). * src/tar.c [ENABLE_ERROR_PRINT_PROGNAME] (tar_print_progname): New function. (main) [ENABLE_ERROR_PRINT_PROGNAME]: Set error_print_progname.
This commit is contained in:
@@ -2666,7 +2666,28 @@ decode_options (int argc, char **argv)
|
||||
|
||||
report_textual_dates (&args);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_ERROR_PRINT_PROGNAME
|
||||
/* The error() function from glibc correctly prefixes each message it
|
||||
prints with program_name as set by set_program_name. However, its
|
||||
replacement from gnulib, which is linked in on systems where this
|
||||
function is not available, prints the name returned by getprogname()
|
||||
instead. Due to this messages output by tar subprocess (which sets its
|
||||
program name to 'tar (child)') become indiscernible from those printed
|
||||
by the main process. In particular, this breaks the remfiles01.at and
|
||||
remfiles02.at test cases.
|
||||
|
||||
To avoid this, on such systems the following helper function is used
|
||||
to print proper program name. Its address is assigned to the
|
||||
error_print_progname variable, which error() then uses instead of
|
||||
printing getprogname() result.
|
||||
*/
|
||||
static void
|
||||
tar_print_progname (void)
|
||||
{
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Tar proper. */
|
||||
|
||||
@@ -2676,7 +2697,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
set_start_time ();
|
||||
set_program_name (argv[0]);
|
||||
|
||||
#ifdef ENABLE_ERROR_PRINT_PROGNAME
|
||||
error_print_progname = tar_print_progname;
|
||||
#endif
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
Reference in New Issue
Block a user