tclWinMtherr.c
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:1k
源码类别:

通讯编程

开发平台:

Visual C++

  1. /* 
  2.  * tclWinMtherr.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.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * RCS: @(#) $Id: tclWinMtherr.c,v 1.5 2002/05/31 22:20:22 dgp Exp $
  13.  */
  14. #include "tclWinInt.h"
  15. #include <math.h>
  16. /*
  17.  *----------------------------------------------------------------------
  18.  *
  19.  * _matherr --
  20.  *
  21.  * This procedure is invoked by Borland C++ when certain
  22.  * errors occur in mathematical functions.  This procedure
  23.  * replaces the default implementation which generates pop-up
  24.  * warnings.
  25.  *
  26.  * Results:
  27.  * Returns 1 to indicate that we've handled the error
  28.  * locally.
  29.  *
  30.  * Side effects:
  31.  * Sets errno based on what's in xPtr.
  32.  *
  33.  *----------------------------------------------------------------------
  34.  */
  35. int
  36. _matherr(xPtr)
  37.     struct exception *xPtr; /* Describes error that occurred. */
  38. {
  39.     if ((xPtr->type == DOMAIN)
  40. #ifdef __BORLANDC__
  41.     || (xPtr->type == TLOSS)
  42. #endif
  43.     || (xPtr->type == SING)) {
  44. errno = EDOM;
  45.     } else {
  46. errno = ERANGE;
  47.     }
  48.     return 1;
  49. }