X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsupport%2Fsyserror.cpp;h=f60628840d675189d59d6ccf37ee9ef22d29580c;hp=e59449f0161c5695a4efa4b471f5af34acadbc12;hb=855f0990a75750c61badd376ff35ffb39fab1c36;hpb=1e88cf0f7fa4f690ea9f110e8ed3f2b5338d0a10 diff --git a/libctsupport/syserror.cpp b/libctsupport/syserror.cpp index e59449f..f606288 100644 --- 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 ** -** $Id: syserror.cpp,v 1.4 2000/08/25 15:59:13 kevin Exp $ +** $Id: syserror.cpp,v 1.8 2000/12/17 23:30:48 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 @@ -65,38 +65,46 @@ void sys_verror (int severity, const char *msg, va_list arg) 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: - cout << "FATAL ERROR: "; + std::cout << "FATAL ERROR: "; break; case ERR_SEVERE: - cout << "SEVERE ERROR: "; + std::cout << "SEVERE ERROR: "; break; case ERR_WARNING: - cout << "WARNING ERROR: "; + std::cout << "WARNING ERROR: "; break; default: - sys_error (ERR_FATAL, "illegal error code #%d [sys_error]", severity); + std::cout << "Illegal error code #" << severity << ": "; } - char errStr[512]; + char errStr[512]; + +#if HAVE_VSNPRINTF vsnprintf (errStr, sizeof(errStr), msg, arg); - cout << errStr << endl; +#elif HAVE_VSPRINTF + vsprintf (errStr, msg, arg); +#else + strncpy (errStr, sizeof(errStr), "Error message not available on this platform."); +#endif + + std::cout << errStr << std::endl; if (severity == ERR_FATAL) - throw runtime_error (errStr); + throw std::runtime_error (errStr); #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 {