home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tkisrc04.zip / tcl / os2 / tclOS2Mtherr.c < prev    next >
C/C++ Source or Header  |  1998-08-07  |  1KB  |  58 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-1997 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 "tclInt.h"
  16. #include "tclPort.h"
  17. #include <math.h>
  18.  
  19. /*
  20.  * The following variable is secretly shared with Tcl so we can
  21.  * tell if expression evaluation is in progress.  If not, matherr
  22.  * just emulates the default behavior, which includes printing
  23.  * a message.
  24.  */
  25.  
  26. extern int tcl_MathInProgress;
  27.  
  28. /*
  29.  *----------------------------------------------------------------------
  30.  *
  31.  * _matherr --
  32.  *
  33.  *    This procedure is invoked by Borland C++ when certain
  34.  *    errors occur in mathematical functions.  This procedure
  35.  *    replaces the default implementation which generates pop-up
  36.  *    warnings.
  37.  *
  38.  * Results:
  39.  *    Returns 1 to indicate that we've handled the error
  40.  *    locally.
  41.  *
  42.  * Side effects:
  43.  *    Sets errno based on what's in xPtr.
  44.  *
  45.  *----------------------------------------------------------------------
  46.  */
  47.  
  48. int
  49. _matherr(xPtr)
  50.     struct _exception *xPtr;    /* Describes error that occurred. */
  51. {
  52.     if (!tcl_MathInProgress) {
  53.     return 0;
  54.     }
  55.     errno = ERANGE;
  56.     return 1;
  57. }
  58.