[GRASS-SVN] r60590 - in grass/trunk: include/defs lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 29 15:23:24 PDT 2014


Author: glynn
Date: 2014-05-29 15:23:24 -0700 (Thu, 29 May 2014)
New Revision: 60590

Modified:
   grass/trunk/include/defs/gis.h
   grass/trunk/lib/gis/error.c
Log:
Add G_fatal_longjmp()


Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h	2014-05-29 21:02:00 UTC (rev 60589)
+++ grass/trunk/include/defs/gis.h	2014-05-29 22:23:24 UTC (rev 60590)
@@ -60,6 +60,7 @@
 
 #include <stdarg.h>
 #include <stdio.h>
+#include <setjmp.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -217,6 +218,7 @@
 void G_switch_env(void);
 
 /* error.c */
+jmp_buf *G_fatal_longjmp(int);
 int G_info_format(void);
 void G_message(const char *, ...) __attribute__ ((format(printf, 1, 2)));
 void G_verbose_message(const char *, ...)

Modified: grass/trunk/lib/gis/error.c
===================================================================
--- grass/trunk/lib/gis/error.c	2014-05-29 21:02:00 UTC (rev 60589)
+++ grass/trunk/lib/gis/error.c	2014-05-29 22:23:24 UTC (rev 60590)
@@ -14,6 +14,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <setjmp.h>
 #include <unistd.h>
 #include <time.h>
 #include <stdarg.h>
@@ -57,6 +58,15 @@
 static int write_error(const char *, int, time_t, const char *);
 static void log_error(const char *, int);
 
+static int fatal_longjmp;
+static jmp_buf fatal_jmp_buf;
+
+jmp_buf *G_fatal_longjmp(int enable)
+{
+    fatal_longjmp = enable;
+    return &fatal_jmp_buf;
+}
+
 static void vfprint_error(int type, const char *template, va_list ap)
 {
     char buffer[2000];		/* G_asprintf does not work */
@@ -158,6 +168,11 @@
         va_end(ap);
     }
 
+    if (fatal_longjmp) {
+	busy = 0;
+	longjmp(fatal_jmp_buf, 1);
+    }
+
     G__call_error_handlers();
 
     /* Raise SIGABRT, useful for debugging only.



More information about the grass-commit mailing list