mtherr.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* mtherr.c
  2. *
  3. * Library common error handling routine
  4. *
  5. *
  6. *
  7. * SYNOPSIS:
  8. *
  9. * char *fctnam;
  10. * int code;
  11. * int mtherr();
  12. *
  13. * mtherr( fctnam, code );
  14. *
  15. *
  16. *
  17. * DESCRIPTION:
  18. *
  19. * This routine may be called to report one of the following
  20. * error conditions (in the include file mconf.h).
  21. *
  22. * Mnemonic Value Significance
  23. *
  24. * DOMAIN 1 argument domain error
  25. * SING 2 function singularity
  26. * OVERFLOW 3 overflow range error
  27. * UNDERFLOW 4 underflow range error
  28. * TLOSS 5 total loss of precision
  29. * PLOSS 6 partial loss of precision
  30. * EDOM 33 Unix domain error code
  31. * ERANGE 34 Unix range error code
  32. *
  33. * The default version of the file prints the function name,
  34. * passed to it by the pointer fctnam, followed by the
  35. * error condition. The display is directed to the standard
  36. * output device. The routine then returns to the calling
  37. * program. Users may wish to modify the program to abort by
  38. * calling exit() under severe error conditions such as domain
  39. * errors.
  40. *
  41. * Since all error conditions pass control to this function,
  42. * the display may be easily changed, eliminated, or directed
  43. * to an error logging device.
  44. *
  45. * SEE ALSO:
  46. *
  47. * mconf.h
  48. *
  49. */
  50. /*
  51. Cephes Math Library Release 2.0: April, 1987
  52. Copyright 1984, 1987 by Stephen L. Moshier
  53. Direct inquiries to 30 Frost Street, Cambridge, MA 02140
  54. */
  55. #if 0
  56. #include <stdio.h>
  57. #endif
  58. #include "mconf.h"
  59. int merror = 0;
  60. /* Notice: the order of appearance of the following
  61. * messages is bound to the error codes defined
  62. * in mconf.h.
  63. */
  64. static char *ermsg[7] = {
  65. "unknown", /* error code 0 */
  66. "domain", /* error code 1 */
  67. "singularity", /* et seq. */
  68. "overflow",
  69. "underflow",
  70. "total loss of precision",
  71. "partial loss of precision"
  72. };
  73. int mtherr( name, code )
  74. char *name;
  75. int code;
  76. {
  77. #if 0
  78. /* Display string passed by calling program,
  79. * which is supposed to be the name of the
  80. * function in which the error occurred:
  81. */
  82. printf( "\n%s ", name );
  83. /* Set global error message word */
  84. merror = code;
  85. /* Display error message defined
  86. * by the code argument.
  87. */
  88. if( (code <= 0) || (code >= 7) )
  89. code = 0;
  90. printf( "%s error\n", ermsg[code] );
  91. #endif
  92. /* Return to calling
  93. * program
  94. */
  95. return( 0 );
  96. }