home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcltk805.zip / tcl805s.zip / tcl8.0.5 / os2 / tclOS2Mtherr.c < prev    next >
C/C++ Source or Header  |  2001-02-09  |  1KB  |  57 lines

  1. /* 
  2.  * tclOS2Mtherr.c --
  3.  *
  4.  *    This function provides a default implementation of the
  5.  *    _matherr function for Borland C++.
  6.  *
  7.  * Copyright (c) 1995 Sun Microsystems, Inc.
  8.  * Copyright (c) 1996-2001 Illya Vaes
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  */
  13.  
  14.  
  15. #include "tclOS2Int.h"
  16. #include <math.h>
  17.  
  18. /*
  19.  * The following variable is secretly shared with Tcl so we can
  20.  * tell if expression evaluation is in progress.  If not, matherr
  21.  * just emulates the default behavior, which includes printing
  22.  * a message.
  23.  */
  24.  
  25. extern int tcl_MathInProgress;
  26.  
  27. /*
  28.  *----------------------------------------------------------------------
  29.  *
  30.  * _matherr --
  31.  *
  32.  *    This procedure is invoked by Borland C++ when certain
  33.  *    errors occur in mathematical functions.  This procedure
  34.  *    replaces the default implementation which generates pop-up
  35.  *    warnings.
  36.  *
  37.  * Results:
  38.  *    Returns 1 to indicate that we've handled the error
  39.  *    locally.
  40.  *
  41.  * Side effects:
  42.  *    Sets errno based on what's in xPtr.
  43.  *
  44.  *----------------------------------------------------------------------
  45.  */
  46.  
  47. int
  48. _matherr(xPtr)
  49.     struct _exception *xPtr;    /* Describes error that occurred. */
  50. {
  51.     if (!tcl_MathInProgress) {
  52.     return 0;
  53.     }
  54.     errno = ERANGE;
  55.     return 1;
  56. }
  57.