/* Printing of backtraces and error messages
- * Copyright (C) 1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2009, 2010, 2011 Free Software Foundation
+ * Copyright (C) 1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2009,
+ * 2010, 2011, 2014 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#include "libguile/_scm.h"
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
}
#undef FUNC_NAME
+static SCM print_exception_var;
+
+static void
+init_print_exception_var (void)
+{
+ print_exception_var
+ = scm_module_variable (scm_the_root_module (),
+ scm_from_latin1_symbol ("print-exception"));
+}
+
SCM
scm_print_exception (SCM port, SCM frame, SCM key, SCM args)
#define FUNC_NAME "print-exception"
{
- static SCM print_exception = SCM_BOOL_F;
+ static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT;
+ scm_i_pthread_once (&once, init_print_exception_var);
SCM_VALIDATE_OPOUTPORT (1, port);
if (scm_is_true (frame))
SCM_VALIDATE_FRAME (2, frame);
SCM_VALIDATE_SYMBOL (3, key);
SCM_VALIDATE_LIST (4, args);
-
- if (scm_is_false (print_exception))
- print_exception =
- scm_module_variable (scm_the_root_module (),
- scm_from_latin1_symbol ("print-exception"));
- return scm_call_4 (scm_variable_ref (print_exception),
+ return scm_call_4 (scm_variable_ref (print_exception_var),
port, frame, key, args);
}
#undef FUNC_NAME
{
SCM_VALIDATE_OUTPUT_PORT (2, port);
+#if SCM_ENABLE_DEPRECATED
+ if (SCM_STACKP (frame))
+ {
+ scm_c_issue_deprecation_warning
+ ("Passing a stack as the first argument to `scm_display_error' is "
+ "deprecated. Pass a frame instead.");
+ if (SCM_STACK_LENGTH (frame))
+ frame = scm_stack_ref (frame, SCM_INUM0);
+ else
+ frame = SCM_BOOL_F;
+ }
+#endif
+
scm_i_display_error (frame, port, subr, message, args, rest);
return SCM_UNSPECIFIED;
scm_print_state *pstate;
/* Create a string port used for adaptation of printing parameters. */
- sport = scm_mkstrport (SCM_INUM0,
- scm_make_string (scm_from_int (240),
- SCM_UNDEFINED),
+ sport = scm_mkstrport (SCM_INUM0, SCM_BOOL_F,
SCM_OPN | SCM_WRTNG,
FUNC_NAME);
#define FUNC_NAME "display_backtrace_body"
{
int n_frames, beg, end, n, i, j;
- int nfield, indent_p, indentation;
+ int nfield, indentation;
SCM frame, sport, print_state;
SCM last_file;
scm_print_state *pstate;
SCM_ASSERT (n > 0, a->depth, SCM_ARG4, s_display_backtrace);
/* Create a string port used for adaptation of printing parameters. */
- sport = scm_mkstrport (SCM_INUM0,
- scm_make_string (scm_from_int (240), SCM_UNDEFINED),
+ sport = scm_mkstrport (SCM_INUM0, SCM_BOOL_F,
SCM_OPN | SCM_WRTNG,
FUNC_NAME);
pstate->fancyp = 1;
pstate->highlight_objects = a->highlight_objects;
- /* First find out if it's reasonable to do indentation. */
- indent_p = 0;
-
/* Determine size of frame number field. */
j = end;
for (i = 0; j > 0; ++i) j /= 10;