* cygwin.din (error): Export.

(error_at_line): Export.
(error_message_count): Export.
(error_one_per_line): Export.
(error_print_progname): Export.
* errno.cc (error_message_count): Define.
(error_one_per_line): Define.
(error_print_progname): Define.
(_verror): New static function.
(error): New function.
(error_at_line): New function.
* posix.sgml (std-gnu): Add error, error_at_line.
* include/error.h: New header.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
This commit is contained in:
Yaakov Selkowitz 2011-05-18 01:25:41 +00:00
parent 7dd9fa7ffb
commit d470b53c98
6 changed files with 128 additions and 1 deletions

View File

@ -1,3 +1,20 @@
2011-05-17 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* cygwin.din (error): Export.
(error_at_line): Export.
(error_message_count): Export.
(error_one_per_line): Export.
(error_print_progname): Export.
* errno.cc (error_message_count): Define.
(error_one_per_line): Define.
(error_print_progname): Define.
(_verror): New static function.
(error): New function.
(error_at_line): New function.
* posix.sgml (std-gnu): Add error, error_at_line.
* include/error.h: New header.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-17 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* cygwin.din (clock_getcpuclockid): Export.

View File

@ -10,6 +10,9 @@ __ctype_ptr__ DATA
__cygwin_environ DATA
__cygwin_user_data DATA
_daylight DATA
error_message_count DATA
error_one_per_line DATA
error_print_progname DATA
h_errno DATA
_impure_ptr DATA
in6addr_any DATA
@ -389,6 +392,8 @@ erff NOSIGFE
_erff = erff NOSIGFE
err SIGFE
__errno NOSIGFE
error SIGFE
error_at_line SIGFE
errx SIGFE
euidaccess SIGFE
execl SIGFE

View File

@ -13,6 +13,13 @@ details. */
#define sys_nerr FOOsys_nerr
#define _sys_errlist FOO_sys_errlist
#define strerror_r FOO_strerror_r
#define __INSIDE_CYGWIN__
#include <errno.h>
#include <error.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "winsup.h"
#include "cygtls.h"
#include "ntdll.h"
@ -417,3 +424,67 @@ __xpg_strerror_r (int errnum, char *buf, size_t n)
strcpy (buf, error);
return result;
}
unsigned int error_message_count = 0;
int error_one_per_line = 0;
void (*error_print_progname) (void) = NULL;
static void
_verror (int status, int errnum, const char *filename, unsigned int lineno, const char *fmt, va_list ap)
{
error_message_count++;
fflush (stdout);
if (error_print_progname)
(*error_print_progname) ();
else
fprintf (stderr, "%s:%s", program_invocation_name, filename ? "" : " ");
if (filename)
fprintf (stderr, "%s:%d: ", filename, lineno);
vfprintf (stderr, fmt, ap);
if (errnum != 0)
fprintf (stderr, ": %s", strerror (errnum));
fprintf (stderr, "\n");
if (status != 0)
exit (status);
}
extern "C" void
error (int status, int errnum, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
_verror (status, errnum, NULL, 0, fmt, ap);
va_end (ap);
}
extern "C" void
error_at_line (int status, int errnum, const char *filename, unsigned int lineno, const char *fmt, ...)
{
va_list ap;
if (error_one_per_line != 0)
{
static const char *last_filename;
static unsigned int last_lineno;
/* strcmp(3) will SEGV if filename or last_filename are NULL */
if (lineno == last_lineno
&& ((!filename && !last_filename)
|| (filename && last_filename && strcmp (filename, last_filename) == 0)))
return;
last_filename = filename;
last_lineno = lineno;
}
va_start (ap, fmt);
_verror (status, errnum, filename, lineno, fmt, ap);
va_end (ap);
}

View File

@ -414,12 +414,14 @@ details. */
pthread_attr_setstack, pthread_attr_setstackaddr.
246: Add CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID.
Export clock_getcpuclockid, pthread_getcpuclockid.
247: Export error, error_at_line, error_message_count, error_one_per_line,
error_print_progname.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 246
#define CYGWIN_VERSION_API_MINOR 247
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible

View File

@ -0,0 +1,30 @@
/* error.h: GNU error reporting functions
Copyright 2011 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _ERROR_H
#define _ERROR_H
#ifdef __cplusplus
extern "C"
{
#endif
void error (int, int, const char *, ...);
void error_at_line (int, int, const char *, unsigned int, const char *, ...);
extern unsigned int error_message_count;
extern int error_one_per_line;
extern void (*error_print_progname) (void);
#ifdef __cplusplus
}
#endif
#endif /* _ERROR_H */

View File

@ -1089,6 +1089,8 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
envz_merge
envz_remove
envz_strip
error
error_at_line
euidaccess
execvpe
exp10