[uim-commit] r2525 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Sun Dec 11 12:37:51 PST 2005
Author: yamaken
Date: 2005-12-11 12:37:46 -0800 (Sun, 11 Dec 2005)
New Revision: 2525
Modified:
branches/r5rs/sigscheme/TODO
branches/r5rs/sigscheme/config.h
branches/r5rs/sigscheme/error.c
branches/r5rs/sigscheme/sigscheme.h
Log:
* sigscheme/config.h
- Make asprintf(3) and vasprintf(3) required
* sigscheme/error.c
- (SCM_BACKTRACE_SEP, ASSERT_ALLOCATED): New macro
- (Scm_FatalError): Replace "Error: " with SCM_ERR_HEADER
- (SigScm_Error, Scm_ErrorObj):
* Remove HAVE_V?ASPRINTF handling
* Add error check for memory allocation
- (SigScm_Die):
* Ditto
* Modify message
- (SigScm_ShowBacktrace): Rewrite with SCM_BACKTRACE_SEP
* sigscheme/sigscheme.h
- (SCM_ASSERT):
* Add FIXME comment
* Modify message
* sigscheme/TODO
- Update
Modified: branches/r5rs/sigscheme/TODO
===================================================================
--- branches/r5rs/sigscheme/TODO 2005-12-11 09:39:36 UTC (rev 2524)
+++ branches/r5rs/sigscheme/TODO 2005-12-11 20:37:46 UTC (rev 2525)
@@ -84,7 +84,7 @@
Assigned to YamaKen:
-* Revise fatal error handling
+* Separate SCM_ASSERT into required validation optional assertion
* Fix character and escape sequence related issues. grep Scm_special_char_table
to find the issues, and make all tests in test-char.scm and test-string.scm
Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h 2005-12-11 09:39:36 UTC (rev 2524)
+++ branches/r5rs/sigscheme/config.h 2005-12-11 20:37:46 UTC (rev 2525)
@@ -128,6 +128,11 @@
/*===========================================================================
Dependency Resolution
===========================================================================*/
+/* FIXME: provide replace functions */
+#if (!HAVE_ASPRINTF || !HAVE_VASPRINTF)
+#error "This platform is not supported yet"
+#endif
+
#if SCM_COMPAT_SIOD
#undef SCM_USE_NONSTD_FEATURES
#define SCM_USE_NONSTD_FEATURES 1
Modified: branches/r5rs/sigscheme/error.c
===================================================================
--- branches/r5rs/sigscheme/error.c 2005-12-11 09:39:36 UTC (rev 2524)
+++ branches/r5rs/sigscheme/error.c 2005-12-11 20:37:46 UTC (rev 2525)
@@ -53,10 +53,13 @@
File Local Macro Declarations
=======================================*/
#define SCM_BACKTRACE_HEADER "**** BACKTRACE ****\n"
+#define SCM_BACKTRACE_SEP "------------------------------\n"
#define ERRMSG_UNHANDLED_EXCEPTION "unhandled exception"
#define ERRMSG_MEMORY_EXHAUSTED "memory exhausted"
+#define ASSERT_ALLOCATED(p) ((p) || (ERR(ERRMSG_MEMORY_EXHAUSTED), 1))
+
/*=======================================
Variable Declarations
=======================================*/
@@ -178,7 +181,7 @@
{
/* don't use Scheme-level ports here */
if (msg) {
- fputs("Error: ", stderr);
+ fputs(SCM_ERR_HEADER, stderr);
fputs(msg, stderr);
fputs(SCM_NEWLINE_STR, stderr);
}
@@ -263,13 +266,8 @@
char *reason;
ScmObj reason_holder;
-#if HAVE_ASPRINTF
- asprintf(&reason, "SigScheme Died : %s (file : %s, line : %d)",
- msg, filename, line);
-#else /* HAVE_ASPRINTF */
- /* FIXME: provide replace asprintf */
- reason = strdup("SigScheme Died");
-#endif /* HAVE_ASPRINTF */
+ asprintf(&reason, "%s: (file : %s, line : %d)", msg, filename, line);
+ ASSERT_ALLOCATED(reason);
/* reason will implicitly be freed via the object on GC */
reason_holder = Scm_NewImmutableString(reason);
@@ -284,14 +282,11 @@
char *reason;
ScmObj err_obj;
-#if HAVE_VASPRINTF
va_start(va, msg);
vasprintf(&reason, msg, va);
va_end(va);
-#else /* HAVE_VASPRINTF */
- /* FIXME: provide replace vasprintf */
- reason = strdup(msg);
-#endif /* HAVE_VASPRINTF */
+ ASSERT_ALLOCATED(reason);
+
err_obj = Scm_MakeErrorObj(Scm_NewImmutableString(reason), SCM_NULL);
Scm_RaiseError(err_obj);
/* NOTREACHED */
@@ -313,12 +308,9 @@
char *reason;
ScmObj err_obj;
-#if HAVE_ASPRINTF
asprintf(&reason, "in %s: %s", func_name, msg);
-#else /* HAVE_ASPRINTF */
- /* FIXME: provide replace asprintf */
- reason = strdup(msg);
-#endif /* HAVE_ASPRINTF */
+ ASSERT_ALLOCATED(reason);
+
err_obj = Scm_MakeErrorObj(Scm_NewImmutableString(reason), LIST_1(obj));
Scm_RaiseError(err_obj);
/* NOTREACHED */
@@ -354,8 +346,8 @@
/* show each frame's obj */
for (top = trace_stack; !NULLP(top); top = CDR(top)) {
#if SCM_DEBUG_BACKTRACE_SEP
- SigScm_ErrorPrintf("------------------------------\n");
-#endif /* SCM_DEBUG_BACKTRACE_SEP */
+ SigScm_ErrorPrintf(SCM_BACKTRACE_SEP);
+#endif
frame = CAR(top);
env = TRACE_FRAME_ENV(frame);
@@ -384,7 +376,7 @@
#endif /* SCM_DEBUG_BACKTRACE_VAL */
}
#if SCM_DEBUG_BACKTRACE_SEP
- SigScm_ErrorPrintf("------------------------------\n");
+ SigScm_ErrorPrintf(SCM_BACKTRACE_SEP);
#endif /* SCM_DEBUG_BACKTRACE_SEP */
#endif /* SCM_DEBUG */
}
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-12-11 09:39:36 UTC (rev 2524)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-12-11 20:37:46 UTC (rev 2525)
@@ -81,8 +81,12 @@
#define SCM_DBG(args)
#endif /* SCM_DEBUG */
-#define SCM_ASSERT(cond) \
- ((cond) || SigScm_Die("assertion failed.", __FILE__, __LINE__))
+/* FIXME:
+ * - separate required validation from optional assertion
+ * - support immediate termination to produce core instead of robust recovery
+ */
+#define SCM_ASSERT(cond) \
+ ((cond) || SigScm_Die("assertion failed", __FILE__, __LINE__))
#define SCM_ERROBJP(obj) (NFALSEP(ScmOp_error_objectp(obj)))
More information about the uim-commit
mailing list