projects
/
debian
/
gzip
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Import Debian changes 1.9-2.2
[debian/gzip]
/
lib
/
error.c
diff --git
a/lib/error.c
b/lib/error.c
index dc8c65fa7f9899551519d08615ec373a34a8cbe2..81788c7b96e7e35b3b8815721b80867c2526156d 100644
(file)
--- a/
lib/error.c
+++ b/
lib/error.c
@@
-1,5
+1,5
@@
/* Error handler for noninteractive utilities
/* Error handler for noninteractive utilities
- Copyright (C) 1990-1998, 2000-2007, 2009-201
2
Free Software Foundation, Inc.
+ Copyright (C) 1990-1998, 2000-2007, 2009-201
8
Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@
-13,7
+13,7
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <http
s
://www.gnu.org/licenses/>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
@@
-39,6
+39,11
@@
# include <stdint.h>
# include <wchar.h>
# define mbsrtowcs __mbsrtowcs
# include <stdint.h>
# include <wchar.h>
# define mbsrtowcs __mbsrtowcs
+# define USE_UNLOCKED_IO 0
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b)
+# define _GL_ARG_NONNULL(a)
+#else
+# include "getprogname.h"
#endif
#if USE_UNLOCKED_IO
#endif
#if USE_UNLOCKED_IO
@@
-72,14
+77,14
@@
extern void __error (int status, int errnum, const char *message, ...)
extern void __error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message,
...)
extern void __error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message,
...)
- __attribute__ ((__format__ (__printf__, 5, 6)));
;
+ __attribute__ ((__format__ (__printf__, 5, 6)));
# define error __error
# define error_at_line __error_at_line
# include <libio/iolibio.h>
# define error __error
# define error_at_line __error_at_line
# include <libio/iolibio.h>
-# define fflush(s)
INTUSE(_IO_fflush)
(s)
+# define fflush(s)
_IO_fflush
(s)
# undef putc
# undef putc
-# define putc(c, fp)
INTUSE(_IO_putc)
(c, fp)
+# define putc(c, fp)
_IO_putc
(c, fp)
# include <bits/libc-lock.h>
# include <bits/libc-lock.h>
@@
-93,35
+98,37
@@
extern void __error_at_line (int status, int errnum, const char *file_name,
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# endif
/* The gnulib override of fcntl is not needed in this file. */
# undef fcntl
# endif
/* The gnulib override of fcntl is not needed in this file. */
# undef fcntl
-# if !
HAVE_DECL_STRERROR_R
+# if !
(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
# ifndef HAVE_DECL_STRERROR_R
"this configure-time declaration test was not run"
# endif
# if STRERROR_R_CHAR_P
# ifndef HAVE_DECL_STRERROR_R
"this configure-time declaration test was not run"
# endif
# if STRERROR_R_CHAR_P
-char *strerror_r ();
+char *strerror_r (
int errnum, char *buf, size_t buflen
);
# else
# else
-int strerror_r ();
+int strerror_r (
int errnum, char *buf, size_t buflen
);
# endif
# endif
# endif
# endif
-/* The calling program should define program_name and set it to the
- name of the executing program. */
-extern char *program_name;
+#define program_name getprogname ()
-# if HAVE_STRERROR_R || defined strerror_r
+# if
GNULIB_STRERROR_R_POSIX ||
HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
# define __strerror_r strerror_r
-# endif /* HAVE_STRERROR_R || defined strerror_r */
+# endif /*
GNULIB_STRERROR_R_POSIX ||
HAVE_STRERROR_R || defined strerror_r */
#endif /* not _LIBC */
#if !_LIBC
/* Return non-zero if FD is open. */
#endif /* not _LIBC */
#if !_LIBC
/* Return non-zero if FD is open. */
-static in
line in
t
+static int
is_open (int fd)
{
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
is_open (int fd)
{
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
@@
-139,7
+146,7
@@
is_open (int fd)
}
#endif
}
#endif
-static
inline
void
+static void
flush_stdout (void)
{
#if !_LIBC
flush_stdout (void)
{
#if !_LIBC
@@
-169,9
+176,9
@@
print_errno_message (int errnum)
{
char const *s;
{
char const *s;
-#if
defined HAVE_STRERROR_R || _LIBC
+#if
_LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
char errbuf[1024];
char errbuf[1024];
-# if
STRERROR_R_CHAR_P || _LIBC
+# if
_LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
s = __strerror_r (errnum, errbuf, sizeof errbuf);
# else
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
s = __strerror_r (errnum, errbuf, sizeof errbuf);
# else
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
@@
-195,13
+202,12
@@
print_errno_message (int errnum)
#endif
}
#endif
}
-static void
+static void
_GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))
error_tail (int status, int errnum, const char *message, va_list args)
{
#if _LIBC
if (_IO_fwide (stderr, 0) > 0)
{
error_tail (int status, int errnum, const char *message, va_list args)
{
#if _LIBC
if (_IO_fwide (stderr, 0) > 0)
{
-# define ALLOCA_LIMIT 2000
size_t len = strlen (message) + 1;
wchar_t *wmessage = NULL;
mbstate_t st;
size_t len = strlen (message) + 1;
wchar_t *wmessage = NULL;
mbstate_t st;
@@
-237,7
+243,7
@@
error_tail (int status, int errnum, const char *message, va_list args)
if (res != len)
break;
if (res != len)
break;
- if (__builtin_expect (len >= SIZE_MAX / 2, 0))
+ if (__builtin_expect (len >= SIZE_MAX /
sizeof (wchar_t) /
2, 0))
{
/* This really should not happen if everything is fine. */
res = (size_t) -1;
{
/* This really should not happen if everything is fine. */
res = (size_t) -1;
@@
-266,7
+272,6
@@
error_tail (int status, int errnum, const char *message, va_list args)
else
#endif
vfprintf (stderr, message, args);
else
#endif
vfprintf (stderr, message, args);
- va_end (args);
++error_message_count;
if (errnum)
++error_message_count;
if (errnum)
@@
-316,6
+321,7
@@
error (int status, int errnum, const char *message, ...)
va_start (args, message);
error_tail (status, errnum, message, args);
va_start (args, message);
error_tail (status, errnum, message, args);
+ va_end (args);
#ifdef _LIBC
_IO_funlockfile (stderr);
#ifdef _LIBC
_IO_funlockfile (stderr);
@@
-342,7
+348,10
@@
error_at_line (int status, int errnum, const char *file_name,
if (old_line_number == line_number
&& (file_name == old_file_name
if (old_line_number == line_number
&& (file_name == old_file_name
- || strcmp (old_file_name, file_name) == 0))
+ || (old_file_name != NULL
+ && file_name != NULL
+ && strcmp (old_file_name, file_name) == 0)))
+
/* Simply return and print nothing. */
return;
/* Simply return and print nothing. */
return;
@@
-374,15
+383,16
@@
error_at_line (int status, int errnum, const char *file_name,
}
#if _LIBC
}
#if _LIBC
- __fxprintf (NULL, file_name != NULL ? "%s:%
d
: " : " ",
+ __fxprintf (NULL, file_name != NULL ? "%s:%
u
: " : " ",
file_name, line_number);
#else
file_name, line_number);
#else
- fprintf (stderr, file_name != NULL ? "%s:%
d
: " : " ",
+ fprintf (stderr, file_name != NULL ? "%s:%
u
: " : " ",
file_name, line_number);
#endif
va_start (args, message);
error_tail (status, errnum, message, args);
file_name, line_number);
#endif
va_start (args, message);
error_tail (status, errnum, message, args);
+ va_end (args);
#ifdef _LIBC
_IO_funlockfile (stderr);
#ifdef _LIBC
_IO_funlockfile (stderr);