summaryrefslogtreecommitdiffstats
path: root/unwind.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2009-11-16 22:05:28 -0800
committerKaz Kylheku <kaz@kylheku.com>2009-11-16 22:05:28 -0800
commit3a6c04927b4136a195b0bc259f50caf8249dfced (patch)
treed8972160fe49f6ccb60ea868a0af2fdd4d60845e /unwind.c
parentfb2f0af8bd14283524e5842b43461ea3fc7701ca (diff)
downloadtxr-3a6c04927b4136a195b0bc259f50caf8249dfced.tar.gz
txr-3a6c04927b4136a195b0bc259f50caf8249dfced.tar.bz2
txr-3a6c04927b4136a195b0bc259f50caf8249dfced.zip
Big round of changes to switch the code base to use the stream
abstraction instead of directly using C standard I/O, to eliminate most uses of C formatted I/O, and fix numerous bugs, such variadic argument lists which lack a terminating ``nao'' sentinel. Bug 28033 is addressed by this patch, since streams no longer provide printf-compatible formatting. The native formatter is extended with some additional capabilities to take over. The work on literal objects is expanded and they are now used throughout the code base. Fixed bad realloc in string output stream: reallocating by number of wide chars rather than bytes.
Diffstat (limited to 'unwind.c')
-rw-r--r--unwind.c46
1 files changed, 10 insertions, 36 deletions
diff --git a/unwind.c b/unwind.c
index 43c93184..3e3083da 100644
--- a/unwind.c
+++ b/unwind.c
@@ -217,15 +217,15 @@ obj_t *uw_throw(obj_t *sym, obj_t *exception)
if (ex == 0) {
if (opt_loglevel >= 1) {
obj_t *s = stringp(exception);
- format(std_error, L"~a: unhandled exception of type ~a:\n",
+ format(std_error, lit("~a: unhandled exception of type ~a:\n"),
prog_string, sym, nao);
- format(std_error, s ? L"~a: ~a\n" : L"~a: ~s\n",
+ format(std_error, s ? lit("~a: ~a\n") : lit("~a: ~s\n"),
prog_string, exception, nao);
}
if (uw_exception_subtype_p(sym, query_error) ||
uw_exception_subtype_p(sym, file_error)) {
if (!output_produced)
- put_cstring(std_output, L"false\n");
+ put_line(std_output, lit("false"));
exit(EXIT_FAILURE);
}
abort();
@@ -238,7 +238,7 @@ obj_t *uw_throw(obj_t *sym, obj_t *exception)
abort();
}
-obj_t *uw_throwf(obj_t *sym, const wchar_t *fmt, ...)
+obj_t *uw_throwf(obj_t *sym, obj_t *fmt, ...)
{
va_list vl;
obj_t *stream = make_string_output_stream();
@@ -251,7 +251,7 @@ obj_t *uw_throwf(obj_t *sym, const wchar_t *fmt, ...)
abort();
}
-obj_t *uw_errorf(const wchar_t *fmt, ...)
+obj_t *uw_errorf(obj_t *fmt, ...)
{
va_list vl;
obj_t *stream = make_string_output_stream();
@@ -264,33 +264,7 @@ obj_t *uw_errorf(const wchar_t *fmt, ...)
abort();
}
-obj_t *uw_throwcf(obj_t *sym, const wchar_t *fmt, ...)
-{
- va_list vl;
- obj_t *stream = make_string_output_stream();
-
- va_start (vl, fmt);
- (void) vcformat(stream, fmt, vl);
- va_end (vl);
-
- uw_throw(sym, get_string_from_stream(stream));
- abort();
-}
-
-obj_t *uw_errorcf(const wchar_t *fmt, ...)
-{
- va_list vl;
- obj_t *stream = make_string_output_stream();
-
- va_start (vl, fmt);
- (void) vcformat(stream, fmt, vl);
- va_end (vl);
-
- uw_throw(error, get_string_from_stream(stream));
- abort();
-}
-
-obj_t *type_mismatch(const wchar_t *fmt, ...)
+obj_t *type_mismatch(obj_t *fmt, ...)
{
va_list vl;
obj_t *stream = make_string_output_stream();
@@ -317,21 +291,21 @@ obj_t *uw_register_subtype(obj_t *sub, obj_t *sup)
if (sub == t) {
if (sup == t)
return sup;
- uw_throwf(type_error, L"cannot define ~a as an exception subtype of ~a",
+ uw_throwf(type_error, lit("cannot define ~a as an exception subtype of ~a"),
sub, sup, nao);
}
if (sup == nil) {
- uw_throwf(type_error, L"cannot define ~a as an exception subtype of ~a",
+ uw_throwf(type_error, lit("cannot define ~a as an exception subtype of ~a"),
sub, sup, nao);
}
if (uw_exception_subtype_p(sub, sup))
- uw_throwf(type_error, L"~a is already an exception subtype of ~a",
+ uw_throwf(type_error, lit("~a is already an exception subtype of ~a"),
sub, sup, nao);
if (uw_exception_subtype_p(sup, sub))
- uw_throwf(type_error, L"~a is already an exception supertype of ~a",
+ uw_throwf(type_error, lit("~a is already an exception supertype of ~a"),
sub, sup, nao);
/* If sup symbol not registered, then we make it