os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/tclPanic.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /* 
     2  * tclPanic.c --
     3  *
     4  *	Source code for the "Tcl_Panic" library procedure for Tcl;
     5  *	individual applications will probably call Tcl_SetPanicProc()
     6  *	to set an application-specific panic procedure.
     7  *
     8  * Copyright (c) 1988-1993 The Regents of the University of California.
     9  * Copyright (c) 1994 Sun Microsystems, Inc.
    10  * Copyright (c) 1998-1999 by Scriptics Corporation.
    11  * Portions Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiaries. All rights reserved.  
    12  *
    13  * See the file "license.terms" for information on usage and redistribution
    14  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    15  *
    16  * RCS: @(#) $Id: tclPanic.c,v 1.4.12.2 2006/03/09 23:11:23 dgp Exp $
    17  */
    18 
    19 #include "tclInt.h"
    20 #include "tclPort.h"
    21 
    22 /*
    23  * The panicProc variable contains a pointer to an application
    24  * specific panic procedure.
    25  */
    26 
    27 static Tcl_PanicProc *panicProc = NULL;
    28 
    29 /*
    30  * The platformPanicProc variable contains a pointer to a platform
    31  * specific panic procedure, if any.  ( TclpPanic may be NULL via
    32  * a macro. )
    33  */
    34 
    35 static Tcl_PanicProc * CONST platformPanicProc = TclpPanic;
    36 
    37 
    38 /*
    39  *----------------------------------------------------------------------
    40  *
    41  * Tcl_SetPanicProc --
    42  *
    43  *	Replace the default panic behavior with the specified functiion.
    44  *
    45  * Results:
    46  *	None.
    47  *
    48  * Side effects:
    49  *	Sets the panicProc variable.
    50  *
    51  *----------------------------------------------------------------------
    52  */
    53 
    54 EXPORT_C void
    55 Tcl_SetPanicProc(proc)
    56     Tcl_PanicProc *proc;
    57 {
    58     panicProc = proc;
    59 }
    60 
    61 /*
    62  *----------------------------------------------------------------------
    63  *
    64  * Tcl_PanicVA --
    65  *
    66  *	Print an error message and kill the process.
    67  *
    68  * Results:
    69  *	None.
    70  *
    71  * Side effects:
    72  *	The process dies, entering the debugger if possible.
    73  *
    74  *----------------------------------------------------------------------
    75  */
    76 
    77 EXPORT_C void
    78 Tcl_PanicVA (format, argList)
    79     CONST char *format;		/* Format string, suitable for passing to
    80 				 * fprintf. */
    81     va_list argList;		/* Variable argument list. */
    82 {
    83     char *arg1, *arg2, *arg3, *arg4;	/* Additional arguments (variable in
    84 					 * number) to pass to fprintf. */
    85     char *arg5, *arg6, *arg7, *arg8;
    86 
    87     arg1 = va_arg(argList, char *);
    88     arg2 = va_arg(argList, char *);
    89     arg3 = va_arg(argList, char *);
    90     arg4 = va_arg(argList, char *);
    91     arg5 = va_arg(argList, char *);
    92     arg6 = va_arg(argList, char *);
    93     arg7 = va_arg(argList, char *);
    94     arg8 = va_arg(argList, char *);
    95     
    96     if (panicProc != NULL) {
    97 	(void) (*panicProc)(format, arg1, arg2, arg3, arg4,
    98 		arg5, arg6, arg7, arg8);
    99     } else if (platformPanicProc != NULL) {
   100 	(void) (*platformPanicProc)(format, arg1, arg2, arg3, arg4,
   101 		arg5, arg6, arg7, arg8);
   102     } else {
   103 	(void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6,
   104 		arg7, arg8);
   105 	(void) fprintf(stderr, "\n");
   106 	(void) fflush(stderr);
   107 	abort();
   108     }
   109 }
   110 
   111 /*
   112  *----------------------------------------------------------------------
   113  *
   114  * Tcl_Panic --
   115  *
   116  *	Print an error message and kill the process.
   117  *
   118  * Results:
   119  *	None.
   120  *
   121  * Side effects:
   122  *	The process dies, entering the debugger if possible.
   123  *
   124  *----------------------------------------------------------------------
   125  */
   126 
   127 	/* VARARGS ARGSUSED */
   128 EXPORT_C void
   129 Tcl_Panic TCL_VARARGS_DEF(CONST char *,arg1)
   130 {
   131     va_list argList;
   132     CONST char *format;
   133 
   134     format = TCL_VARARGS_START(CONST char *,arg1,argList);
   135     Tcl_PanicVA(format, argList);
   136     va_end (argList);
   137 }