projects
/
ctsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r284: rename if-1 to if1
[ctsim.git]
/
libctsupport
/
syserror.cpp
diff --git
a/libctsupport/syserror.cpp
b/libctsupport/syserror.cpp
index dc3851cbbffb8507884ca8129ed7508d962ae683..f60628840d675189d59d6ccf37ee9ef22d29580c 100644
(file)
--- a/
libctsupport/syserror.cpp
+++ b/
libctsupport/syserror.cpp
@@
-2,7
+2,7
@@
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: syserror.cpp,v 1.
1 2000/06/19 02:58:0
8 kevin Exp $
+** $Id: syserror.cpp,v 1.
8 2000/12/17 23:30:4
8 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
@@
-19,10
+19,11
@@
******************************************************************************/
#include <iostream>
******************************************************************************/
#include <iostream>
+#include <exception>
+#include <stdexcept>
#include <stdarg.h>
#include <ctype.h>
#include <stdarg.h>
#include <ctype.h>
-#include "kstddef.h"
-#include "cio.h"
+#include "ctsupport.h"
/* NAME
/* NAME
@@
-57,45
+58,53
@@
const static int MAX_ERROR_COUNT = 20;
void sys_verror (int severity, const char *msg, va_list arg)
{
if (severity < errorlevel)
void sys_verror (int severity, const char *msg, va_list arg)
{
if (severity < errorlevel)
- return;
/* ignore error if less than max level */
+ return;
// ignore error if less than max level
nErrorCount++;
if (severity != ERR_FATAL) {
if (nErrorCount > MAX_ERROR_COUNT)
return;
else if (nErrorCount == MAX_ERROR_COUNT) {
nErrorCount++;
if (severity != ERR_FATAL) {
if (nErrorCount > MAX_ERROR_COUNT)
return;
else if (nErrorCount == MAX_ERROR_COUNT) {
-
cout << "*****************************************************************" << endl
;
-
cout << "*** M A X I M U M E R R O R C O U N T R E A C H E D ***" << endl
;
-
cout << "*** ***" << endl
;
-
cout << "*** No further errors will be reported ***" << endl
;
-
cout << "*****************************************************************" << endl
;
+
std::cout << "*****************************************************************\n"
;
+
std::cout << "*** M A X I M U M E R R O R C O U N T R E A C H E D ***\n"
;
+
std::cout << "*** ***\n"
;
+
std::cout << "*** No further errors will be reported ***\n"
;
+
std::cout << "*****************************************************************\n"
;
return;
}
}
switch (severity) {
case ERR_FATAL:
return;
}
}
switch (severity) {
case ERR_FATAL:
- cout << "FATAL ERROR: ";
+
std::
cout << "FATAL ERROR: ";
break;
case ERR_SEVERE:
break;
case ERR_SEVERE:
- cout << "SEVERE ERROR: ";
+
std::
cout << "SEVERE ERROR: ";
break;
case ERR_WARNING:
break;
case ERR_WARNING:
- cout << "WARNING ERROR: ";
+
std::
cout << "WARNING ERROR: ";
break;
default:
break;
default:
-
sys_error (ERR_FATAL, "illegal error code #%d [sys_error]", severity)
;
+
std::cout << "Illegal error code #" << severity << ": "
;
}
}
- vfprintf (stdout, msg, arg);
+ char errStr[512];
\r
+
+#if HAVE_VSNPRINTF
+ vsnprintf (errStr, sizeof(errStr), msg, arg);
+#elif HAVE_VSPRINTF
+ vsprintf (errStr, msg, arg);
\r
+#else
\r
+ strncpy (errStr, sizeof(errStr), "Error message not available on this platform.");
+#endif
-
cout << "\n"
;
+
std::cout << errStr << std::endl
;
if (severity == ERR_FATAL)
if (severity == ERR_FATAL)
-
exit(1
);
+
throw std::runtime_error (errStr
);
#if INTERACTIVE_ERROR_DISPLAY
#if INTERACTIVE_ERROR_DISPLAY
- cout << "A - Abort C - Continue W - Turn off warnings? ";
+
std::
cout << "A - Abort C - Continue W - Turn off warnings? ";
// fflush(stderr);
do
{
// fflush(stderr);
do
{