summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-03-28 15:22:20 +0000
committerManolo Gouy <Manolo>2016-03-28 15:22:20 +0000
commit28d1a2d6848d5abe555fd0ddae8b57cec6f900ca (patch)
treebb17efad1d942a3fee09b0ef9e858677060e2230 /src
parent244a1a5bc439c0a3427e78f1dac9623b85f161bb (diff)
Rewrite Fl_abort.cxx under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11452 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_System_Driver.cxx42
-rw-r--r--src/Fl_abort.cxx76
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.H4
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx20
4 files changed, 70 insertions, 72 deletions
diff --git a/src/Fl_System_Driver.cxx b/src/Fl_System_Driver.cxx
index 711d9abaa..9a372885d 100644
--- a/src/Fl_System_Driver.cxx
+++ b/src/Fl_System_Driver.cxx
@@ -19,6 +19,8 @@
#include <FL/Fl_System_Driver.H>
#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
const int Fl_System_Driver::flNoValue = 0x0000;
const int Fl_System_Driver::flWidthValue = 0x0004;
@@ -38,6 +40,46 @@ Fl_System_Driver::~Fl_System_Driver()
{
}
+void Fl_System_Driver::warning(const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ driver()->warning(format, args);
+ va_end(args);
+}
+
+void Fl_System_Driver::warning(const char* format, va_list args) {
+ vfprintf(stderr, format, args);
+ fputc('\n', stderr);
+ fflush(stderr);
+}
+
+void Fl_System_Driver::error(const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ driver()->error(format, args);
+ va_end(args);
+}
+
+void Fl_System_Driver::error(const char *format, va_list args) {
+ vfprintf(stderr, format, args);
+ fputc('\n', stderr);
+ fflush(stderr);
+}
+
+void Fl_System_Driver::fatal(const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ driver()->fatal(format, args);
+ va_end(args);
+}
+
+void Fl_System_Driver::fatal(const char *format, va_list args) {
+ vfprintf(stderr, format, args);
+ fputc('\n', stderr);
+ fflush(stderr);
+ exit(1);
+}
+
/* the following function was stolen from the X sources as indicated. */
/* Copyright Massachusetts Institute of Technology 1985, 1986, 1987 */
diff --git a/src/Fl_abort.cxx b/src/Fl_abort.cxx
index a54004155..f0125e905 100644
--- a/src/Fl_abort.cxx
+++ b/src/Fl_abort.cxx
@@ -16,83 +16,15 @@
// http://www.fltk.org/str.php
//
-// This method is in its own source file so that stdlib and stdio
-// do not need to be included in Fl.cxx:
// You can also override this by redefining all of these.
#include <FL/Fl.H>
-#include <stdio.h>
-#include <stdlib.h>
+#include <FL/Fl_System_Driver.H>
#include <stdarg.h>
-#include "flstring.h"
-#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - native message box
-#elif defined(FL_PORTING)
-# pragma message "FL_PORTING: use native message box below if one is available"
-#else
-#endif
-
-#ifdef WIN32
-# include <windows.h>
-
-static void warning(const char *, ...) {
- // Show nothing for warnings under WIN32...
-}
-
-static void error(const char *format, ...) {
- va_list args;
- char buf[1024];
- va_start(args, format);
- vsnprintf(buf, 1024, format, args);
- va_end(args);
- MessageBox(0,buf,"Error",MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
-}
-
-static void fatal(const char *format, ...) {
- va_list args;
- char buf[1024];
- va_start(args, format);
- vsnprintf(buf, 1024, format, args);
- va_end(args);
- MessageBox(0,buf,"Error",MB_ICONSTOP|MB_SYSTEMMODAL);
- ::exit(1);
-}
-
-#else
-
-static void warning(const char *format, ...) {
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fputc('\n', stderr);
- fflush(stderr);
-}
-
-static void error(const char *format, ...) {
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fputc('\n', stderr);
- fflush(stderr);
-}
-
-static void fatal(const char *format, ...) {
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fputc('\n', stderr);
- fflush(stderr);
- ::exit(1);
-}
-
-#endif
-
-void (*Fl::warning)(const char* format, ...) = ::warning;
-void (*Fl::error)(const char* format, ...) = ::error;
-void (*Fl::fatal)(const char* format, ...) = ::fatal;
+void (*Fl::warning)(const char* format, ...) = Fl_System_Driver::warning;
+void (*Fl::error)(const char* format, ...) = Fl_System_Driver::error;
+void (*Fl::fatal)(const char* format, ...) = Fl_System_Driver::fatal;
//
// End of "$Id$".
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
index d213fd4af..c937c97da 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
@@ -26,6 +26,7 @@
#define FL_WINAPI_SYSTEM_DRIVER_H
#include <FL/Fl_System_Driver.H>
+#include <stdarg.h>
/*
Move everything here that manages the system interface.
@@ -41,6 +42,9 @@
class Fl_WinAPI_System_Driver : public Fl_System_Driver
{
public:
+ virtual void warning(const char *format, va_list args);
+ virtual void error(const char *format, va_list args);
+ virtual void fatal(const char *format, va_list args);
};
#endif // FL_WINAPI_SYSTEM_DRIVER_H
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
index b3678c097..8ea6113a0 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
@@ -19,6 +19,8 @@
#include "../../config_lib.h"
#include "Fl_WinAPI_System_Driver.H"
+#include <stdio.h>
+#include <windows.h>
#if !defined(FL_DOXYGEN)
const char* fl_local_alt = "Alt";
@@ -32,6 +34,24 @@ Fl_System_Driver *Fl_System_Driver::driver() {
return d;
}
+void Fl_WinAPI_System_Driver::warning(const char *format, va_list args) {
+ // Show nothing for warnings under WIN32...
+}
+
+void Fl_WinAPI_System_Driver::error(const char *format, va_list args) {
+ char buf[1024];
+ vsnprintf(buf, 1024, format, args);
+ MessageBox(0,buf,"Error",MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
+}
+
+void Fl_WinAPI_System_Driver::fatal(const char *format, va_list args) {
+ char buf[1024];
+ vsnprintf(buf, 1024, format, args);
+ MessageBox(0,buf,"Error",MB_ICONSTOP|MB_SYSTEMMODAL);
+ ::exit(1);
+}
+
+
//
// End of "$Id$".
//