matherr.c revision 151498
1163953Srrs/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
2169382Srrs     Written by James Clark (jjc@jclark.com)
3163953Srrs
4163953SrrsThis file is part of groff.
5163953Srrs
6163953Srrsgroff is free software; you can redistribute it and/or modify it under
7163953Srrsthe terms of the GNU General Public License as published by the Free
8163953SrrsSoftware Foundation; either version 2, or (at your option) any later
9163953Srrsversion.
10163953Srrs
11163953Srrsgroff is distributed in the hope that it will be useful, but WITHOUT ANY
12163953SrrsWARRANTY; without even the implied warranty of MERCHANTABILITY or
13163953SrrsFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14163953Srrsfor more details.
15163953Srrs
16163953SrrsYou should have received a copy of the GNU General Public License along
17163953Srrswith groff; see the file COPYING.  If not, write to the Free Software
18163953SrrsFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
19163953Srrs
20163953Srrs#ifdef HAVE_CONFIG_H
21163953Srrs#include <config.h>
22163953Srrs#endif
23163953Srrs
24163953Srrs#include <math.h>
25163953Srrs#include <errno.h>
26163953Srrs
27163953Srrs#ifdef HAVE_STRUCT_EXCEPTION
28163953Srrs#ifdef TLOSS
29163953Srrs
30163953Srrsint matherr(exc)
31163953Srrsstruct exception *exc;
32163953Srrs{
33163953Srrs  switch (exc->type) {
34163953Srrs  case SING:
35163953Srrs  case DOMAIN:
36163953Srrs    errno = EDOM;
37163953Srrs    break;
38167598Srrs  case OVERFLOW:
39163953Srrs  case UNDERFLOW:
40163953Srrs  case TLOSS:
41163953Srrs  case PLOSS:
42163953Srrs    errno = ERANGE;
43163953Srrs    break;
44163953Srrs  }
45163953Srrs  return 1;
46163953Srrs}
47163953Srrs
48163953Srrs#endif /* TLOSS */
49163953Srrs#endif /* HAVE_STRUCT_EXCEPTION */
50163953Srrs