57dea9f62e
2005-01-12 Toon Moene <toon@moene.indiv.nluug.nl> PR libfortran/19280 c99_protos.h: License changed to GPL+exception. libgfortran.h: Ditto. intrinsics/abort.c: Ditto. intrinsics/args.c: Ditto. intrinsics/associated.c: Ditto. intrinsics/bessel.c: Ditto. intrinsics/c99_functions.c: Ditto. intrinsics/cpu_time.c: Ditto. intrinsics/cshift0.c: Ditto. intrinsics/date_and_time.c: Ditto. intrinsics/env.c: Ditto. intrinsics/eoshift0.c: Ditto. intrinsics/eoshift2.c: Ditto. intrinsics/erf.c: Ditto. intrinsics/etime.c: Ditto. intrinsics/exit.c: Ditto. intrinsics/flush.c: Ditto. intrinsics/fnum.c: Ditto. intrinsics/getXid.c: Ditto. intrinsics/getcwd.c: Ditto. intrinsics/ishftc.c: Ditto. intrinsics/mvbits.c: Ditto. intrinsics/pack_generic.c: Ditto. intrinsics/rand.c: Ditto. intrinsics/random.c: Ditto. intrinsics/reshape_generic.c: Ditto. intrinsics/reshape_packed.c: Ditto. intrinsics/size.c: Ditto. intrinsics/spread_generic.c: Ditto. intrinsics/stat.c: Ditto. intrinsics/string_intrinsics.c: Ditto. intrinsics/system.c: Ditto. intrinsics/system_clock.c: Ditto. intrinsics/transpose_generic.c: Ditto. intrinsics/umask.c: Ditto. intrinsics/unlink.c: Ditto. intrinsics/unpack_generic.c: Ditto. io/backspace.c: Ditto. io/close.c: Ditto. io/endfile.c: Ditto. io/format.c: Ditto. io/inquire.c: Ditto. io/io.h: Ditto. io/list_read.c: Ditto. io/lock.c: Ditto. io/open.c: Ditto. io/read.c: Ditto. io/rewind.c: Ditto. io/transfer.c: Ditto. io/unit.c: Ditto. io/unix.c: Ditto. io/write.c: Ditto. m4/all.m4: Ditto. m4/any.m4: Ditto. m4/cexp.m4: Ditto. m4/chyp.m4: Ditto. m4/count.m4: Ditto. m4/cshift1.m4: Ditto. m4/ctrig.m4: Ditto. m4/dotprod.m4: Ditto. m4/dotprodc.m4: Ditto. m4/dotprodl.m4: Ditto. m4/eoshift1.m4: Ditto. m4/eoshift3.m4: Ditto. m4/exponent.m4: Ditto. m4/fraction.m4: Ditto. m4/head.m4: Ditto. m4/iforeach.m4: Ditto. m4/ifunction.m4: Ditto. m4/in_pack.m4: Ditto. m4/in_unpack.m4: Ditto. m4/iparm.m4: Ditto. m4/matmul.m4: Ditto. m4/matmull.m4: Ditto. m4/maxloc0.m4: Ditto. m4/maxloc1.m4: Ditto. m4/maxval.m4: Ditto. m4/minloc0.m4: Ditto. m4/minloc1.m4: Ditto. m4/minval.m4: Ditto. m4/mtype.m4: Ditto. m4/nearest.m4: Ditto. m4/pow.m4: Ditto. m4/product.m4: Ditto. m4/reshape.m4: Ditto. m4/set_exponent.m4: Ditto. m4/shape.m4: Ditto. m4/specific.m4: Ditto. m4/specific2.m4: Ditto. m4/sum.m4: Ditto. m4/transpose.m4: Ditto. m4/types.m4: Ditto. runtime/environ.c: Ditto. runtime/error.c: Ditto. runtime/in_pack_generic.c: Ditto. runtime/in_unpack_generic.c: Ditto. runtime/main.c: Ditto. runtime/memory.c: Ditto. runtime/normalize.c: Ditto. runtime/pause.c: Ditto. runtime/select.c: Ditto. runtime/stop.c: Ditto. runtime/string.c: Ditto. generated/_abs_c4.f90: Regenerated. generated/_abs_c8.f90: Regenerated. generated/_abs_i4.f90: Regenerated. generated/_abs_i8.f90: Regenerated. generated/_abs_r4.f90: Regenerated. generated/_abs_r8.f90: Regenerated. generated/_acos_r4.f90: Regenerated. generated/_acos_r8.f90: Regenerated. generated/_aint_r4.f90: Regenerated. generated/_aint_r8.f90: Regenerated. generated/_anint_r4.f90: Regenerated. generated/_anint_r8.f90: Regenerated. generated/_asin_r4.f90: Regenerated. generated/_asin_r8.f90: Regenerated. generated/_atan2_r4.f90: Regenerated. generated/_atan2_r8.f90: Regenerated. generated/_atan_r4.f90: Regenerated. generated/_atan_r8.f90: Regenerated. generated/_conjg_c4.f90: Regenerated. generated/_conjg_c8.f90: Regenerated. generated/_cos_c4.f90: Regenerated. generated/_cos_c8.f90: Regenerated. generated/_cos_r4.f90: Regenerated. generated/_cos_r8.f90: Regenerated. generated/_cosh_r4.f90: Regenerated. generated/_cosh_r8.f90: Regenerated. generated/_dim_i4.f90: Regenerated. generated/_dim_i8.f90: Regenerated. generated/_dim_r4.f90: Regenerated. generated/_dim_r8.f90: Regenerated. generated/_exp_c4.f90: Regenerated. generated/_exp_c8.f90: Regenerated. generated/_exp_r4.f90: Regenerated. generated/_exp_r8.f90: Regenerated. generated/_log10_r4.f90: Regenerated. generated/_log10_r8.f90: Regenerated. generated/_log_c4.f90: Regenerated. generated/_log_c8.f90: Regenerated. generated/_log_r4.f90: Regenerated. generated/_log_r8.f90: Regenerated. generated/_mod_i4.f90: Regenerated. generated/_mod_i8.f90: Regenerated. generated/_mod_r4.f90: Regenerated. generated/_mod_r8.f90: Regenerated. generated/_sign_i4.f90: Regenerated. generated/_sign_i8.f90: Regenerated. generated/_sign_r4.f90: Regenerated. generated/_sign_r8.f90: Regenerated. generated/_sin_c4.f90: Regenerated. generated/_sin_c8.f90: Regenerated. generated/_sin_r4.f90: Regenerated. generated/_sin_r8.f90: Regenerated. generated/_sinh_r4.f90: Regenerated. generated/_sinh_r8.f90: Regenerated. generated/_sqrt_c4.f90: Regenerated. generated/_sqrt_c8.f90: Regenerated. generated/_sqrt_r4.f90: Regenerated. generated/_sqrt_r8.f90: Regenerated. generated/_tan_r4.f90: Regenerated. generated/_tan_r8.f90: Regenerated. generated/_tanh_r4.f90: Regenerated. generated/_tanh_r8.f90: Regenerated. generated/all_l4.c: Regenerated. generated/all_l8.c: Regenerated. generated/any_l4.c: Regenerated. generated/any_l8.c: Regenerated. generated/count_4_l4.c: Regenerated. generated/count_4_l8.c: Regenerated. generated/count_8_l4.c: Regenerated. generated/count_8_l8.c: Regenerated. generated/cshift1_4.c: Regenerated. generated/cshift1_8.c: Regenerated. generated/dotprod_c4.c: Regenerated. generated/dotprod_c8.c: Regenerated. generated/dotprod_i4.c: Regenerated. generated/dotprod_i8.c: Regenerated. generated/dotprod_l4.c: Regenerated. generated/dotprod_l8.c: Regenerated. generated/dotprod_r4.c: Regenerated. generated/dotprod_r8.c: Regenerated. generated/eoshift1_4.c: Regenerated. generated/eoshift1_8.c: Regenerated. generated/eoshift3_4.c: Regenerated. generated/eoshift3_8.c: Regenerated. generated/exp_c4.c: Regenerated. generated/exp_c8.c: Regenerated. generated/exponent_r4.c: Regenerated. generated/exponent_r8.c: Regenerated. generated/fraction_r4.c: Regenerated. generated/fraction_r8.c: Regenerated. generated/hyp_c4.c: Regenerated. generated/hyp_c8.c: Regenerated. generated/in_pack_i4.c: Regenerated. generated/in_pack_i8.c: Regenerated. generated/in_unpack_i4.c: Regenerated. generated/in_unpack_i8.c: Regenerated. generated/matmul_c4.c: Regenerated. generated/matmul_c8.c: Regenerated. generated/matmul_i4.c: Regenerated. generated/matmul_i8.c: Regenerated. generated/matmul_l4.c: Regenerated. generated/matmul_l8.c: Regenerated. generated/matmul_r4.c: Regenerated. generated/matmul_r8.c: Regenerated. generated/maxloc0_4_i4.c: Regenerated. generated/maxloc0_4_i8.c: Regenerated. generated/maxloc0_4_r4.c: Regenerated. generated/maxloc0_4_r8.c: Regenerated. generated/maxloc0_8_i4.c: Regenerated. generated/maxloc0_8_i8.c: Regenerated. generated/maxloc0_8_r4.c: Regenerated. generated/maxloc0_8_r8.c: Regenerated. generated/maxloc1_4_i4.c: Regenerated. generated/maxloc1_4_i8.c: Regenerated. generated/maxloc1_4_r4.c: Regenerated. generated/maxloc1_4_r8.c: Regenerated. generated/maxloc1_8_i4.c: Regenerated. generated/maxloc1_8_i8.c: Regenerated. generated/maxloc1_8_r4.c: Regenerated. generated/maxloc1_8_r8.c: Regenerated. generated/maxval_i4.c: Regenerated. generated/maxval_i8.c: Regenerated. generated/maxval_r4.c: Regenerated. generated/maxval_r8.c: Regenerated. generated/minloc0_4_i4.c: Regenerated. generated/minloc0_4_i8.c: Regenerated. generated/minloc0_4_r4.c: Regenerated. generated/minloc0_4_r8.c: Regenerated. generated/minloc0_8_i4.c: Regenerated. generated/minloc0_8_i8.c: Regenerated. generated/minloc0_8_r4.c: Regenerated. generated/minloc0_8_r8.c: Regenerated. generated/minloc1_4_i4.c: Regenerated. generated/minloc1_4_i8.c: Regenerated. generated/minloc1_4_r4.c: Regenerated. generated/minloc1_4_r8.c: Regenerated. generated/minloc1_8_i4.c: Regenerated. generated/minloc1_8_i8.c: Regenerated. generated/minloc1_8_r4.c: Regenerated. generated/minloc1_8_r8.c: Regenerated. generated/minval_i4.c: Regenerated. generated/minval_i8.c: Regenerated. generated/minval_r4.c: Regenerated. generated/minval_r8.c: Regenerated. generated/nearest_r4.c: Regenerated. generated/nearest_r8.c: Regenerated. generated/pow_c4_i4.c: Regenerated. generated/pow_c4_i8.c: Regenerated. generated/pow_c8_i4.c: Regenerated. generated/pow_c8_i8.c: Regenerated. generated/pow_i4_i4.c: Regenerated. generated/pow_i4_i8.c: Regenerated. generated/pow_i8_i4.c: Regenerated. generated/pow_i8_i8.c: Regenerated. generated/pow_r4_i4.c: Regenerated. generated/pow_r4_i8.c: Regenerated. generated/pow_r8_i4.c: Regenerated. generated/pow_r8_i8.c: Regenerated. generated/product_c4.c: Regenerated. generated/product_c8.c: Regenerated. generated/product_i4.c: Regenerated. generated/product_i8.c: Regenerated. generated/product_r4.c: Regenerated. generated/product_r8.c: Regenerated. generated/reshape_i4.c: Regenerated. generated/reshape_i8.c: Regenerated. generated/set_exponent_r4.c: Regenerated. generated/set_exponent_r8.c: Regenerated. generated/shape_i4.c: Regenerated. generated/shape_i8.c: Regenerated. generated/sum_c4.c: Regenerated. generated/sum_c8.c: Regenerated. generated/sum_i4.c: Regenerated. generated/sum_i8.c: Regenerated. generated/sum_r4.c: Regenerated. generated/sum_r8.c: Regenerated. generated/transpose_i4.c: Regenerated. generated/transpose_i8.c: Regenerated. generated/trig_c4.c: Regenerated. generated/trig_c8.c: Regenerated. From-SVN: r93235
491 lines
9.7 KiB
C
491 lines
9.7 KiB
C
/* Copyright (C) 2002-2003 Free Software Foundation, Inc.
|
|
Contributed by Andy Vaught
|
|
|
|
This file is part of the GNU Fortran 95 runtime library (libgfortran).
|
|
|
|
Libgfortran is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
any later version.
|
|
|
|
In addition to the permissions in the GNU General Public License, the
|
|
Free Software Foundation gives you unlimited permission to link the
|
|
compiled version of this file into combinations with other programs,
|
|
and to distribute those combinations without any restriction coming
|
|
from the use of this file. (The General Public License restrictions
|
|
do apply in other respects; for example, they cover modification of
|
|
the file, and distribution when not linked into a combine
|
|
executable.)
|
|
|
|
Libgfortran is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with libgfortran; see the file COPYING. If not, write to
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
#include "config.h"
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#include <float.h>
|
|
|
|
#include "libgfortran.h"
|
|
#include "../io/io.h"
|
|
|
|
/* Error conditions. The tricky part here is printing a message when
|
|
* it is the I/O subsystem that is severely wounded. Our goal is to
|
|
* try and print something making the fewest assumptions possible,
|
|
* then try to clean up before actually exiting.
|
|
*
|
|
* The following exit conditions are defined:
|
|
* 0 Normal program exit.
|
|
* 1 Terminated because of operating system error.
|
|
* 2 Error in the runtime library
|
|
* 3 Internal error in runtime library
|
|
* 4 Error during error processing (very bad)
|
|
*
|
|
* Other error returns are reserved for the STOP statement with a numeric code.
|
|
*/
|
|
|
|
/* locus variables. These are optionally set by a caller before a
|
|
* library subroutine is called. They are always cleared on exit so
|
|
* that files that report loci and those that do not can be linked
|
|
* together without reporting an erroneous position. */
|
|
|
|
char *filename = 0;
|
|
iexport_data(filename);
|
|
|
|
unsigned line = 0;
|
|
iexport_data(line);
|
|
|
|
static char buffer[32]; /* buffer for integer/ascii conversions */
|
|
|
|
|
|
/* Returns a pointer to a static buffer. */
|
|
|
|
char *
|
|
gfc_itoa (int64_t n)
|
|
{
|
|
int negative;
|
|
char *p;
|
|
uint64_t t;
|
|
|
|
if (n == 0)
|
|
{
|
|
buffer[0] = '0';
|
|
buffer[1] = '\0';
|
|
return buffer;
|
|
}
|
|
|
|
negative = 0;
|
|
t = n;
|
|
if (n < 0)
|
|
{
|
|
negative = 1;
|
|
t = -n; /*must use unsigned to protect from overflow*/
|
|
}
|
|
|
|
p = buffer + sizeof (buffer) - 1;
|
|
*p-- = '\0';
|
|
|
|
while (t != 0)
|
|
{
|
|
*p-- = '0' + (t % 10);
|
|
t /= 10;
|
|
}
|
|
|
|
if (negative)
|
|
*p-- = '-';
|
|
return ++p;
|
|
}
|
|
|
|
|
|
/* xtoa()-- Integer to hexadecimal conversion. Returns a pointer to a
|
|
* static buffer. */
|
|
|
|
char *
|
|
xtoa (uint64_t n)
|
|
{
|
|
int digit;
|
|
char *p;
|
|
|
|
if (n == 0)
|
|
{
|
|
buffer[0] = '0';
|
|
buffer[1] = '\0';
|
|
return buffer;
|
|
}
|
|
|
|
p = buffer + sizeof (buffer) - 1;
|
|
*p-- = '\0';
|
|
|
|
while (n != 0)
|
|
{
|
|
digit = n & 0xF;
|
|
if (digit > 9)
|
|
digit += 'A' - '0' - 10;
|
|
|
|
*p-- = '0' + digit;
|
|
n >>= 4;
|
|
}
|
|
|
|
return ++p;
|
|
}
|
|
|
|
|
|
/* st_printf()-- simple printf() function for streams that handles the
|
|
* formats %d, %s and %c. This function handles printing of error
|
|
* messages that originate within the library itself, not from a user
|
|
* program. */
|
|
|
|
int
|
|
st_printf (const char *format, ...)
|
|
{
|
|
int count, total;
|
|
va_list arg;
|
|
char *p, *q;
|
|
stream *s;
|
|
|
|
total = 0;
|
|
s = init_error_stream ();
|
|
va_start (arg, format);
|
|
|
|
for (;;)
|
|
{
|
|
count = 0;
|
|
|
|
while (format[count] != '%' && format[count] != '\0')
|
|
count++;
|
|
|
|
if (count != 0)
|
|
{
|
|
p = salloc_w (s, &count);
|
|
memmove (p, format, count);
|
|
sfree (s);
|
|
}
|
|
|
|
total += count;
|
|
format += count;
|
|
if (*format++ == '\0')
|
|
break;
|
|
|
|
switch (*format)
|
|
{
|
|
case 'c':
|
|
count = 1;
|
|
|
|
p = salloc_w (s, &count);
|
|
*p = (char) va_arg (arg, int);
|
|
|
|
sfree (s);
|
|
break;
|
|
|
|
case 'd':
|
|
q = gfc_itoa (va_arg (arg, int));
|
|
count = strlen (q);
|
|
|
|
p = salloc_w (s, &count);
|
|
memmove (p, q, count);
|
|
sfree (s);
|
|
break;
|
|
|
|
case 'x':
|
|
q = xtoa (va_arg (arg, unsigned));
|
|
count = strlen (q);
|
|
|
|
p = salloc_w (s, &count);
|
|
memmove (p, q, count);
|
|
sfree (s);
|
|
break;
|
|
|
|
case 's':
|
|
q = va_arg (arg, char *);
|
|
count = strlen (q);
|
|
|
|
p = salloc_w (s, &count);
|
|
memmove (p, q, count);
|
|
sfree (s);
|
|
break;
|
|
|
|
case '\0':
|
|
return total;
|
|
|
|
default:
|
|
count = 2;
|
|
p = salloc_w (s, &count);
|
|
p[0] = format[-1];
|
|
p[1] = format[0];
|
|
sfree (s);
|
|
break;
|
|
}
|
|
|
|
total += count;
|
|
format++;
|
|
}
|
|
|
|
va_end (arg);
|
|
return total;
|
|
}
|
|
|
|
|
|
/* st_sprintf()-- Simple sprintf() for formatting memory buffers. */
|
|
|
|
void
|
|
st_sprintf (char *buffer, const char *format, ...)
|
|
{
|
|
va_list arg;
|
|
char c, *p;
|
|
int count;
|
|
|
|
va_start (arg, format);
|
|
|
|
for (;;)
|
|
{
|
|
c = *format++;
|
|
if (c != '%')
|
|
{
|
|
*buffer++ = c;
|
|
if (c == '\0')
|
|
break;
|
|
continue;
|
|
}
|
|
|
|
c = *format++;
|
|
switch (c)
|
|
{
|
|
case 'c':
|
|
*buffer++ = (char) va_arg (arg, int);
|
|
break;
|
|
|
|
case 'd':
|
|
p = gfc_itoa (va_arg (arg, int));
|
|
count = strlen (p);
|
|
|
|
memcpy (buffer, p, count);
|
|
buffer += count;
|
|
break;
|
|
|
|
case 's':
|
|
p = va_arg (arg, char *);
|
|
count = strlen (p);
|
|
|
|
memcpy (buffer, p, count);
|
|
buffer += count;
|
|
break;
|
|
|
|
default:
|
|
*buffer++ = c;
|
|
}
|
|
}
|
|
|
|
va_end (arg);
|
|
}
|
|
|
|
|
|
/* show_locus()-- Print a line number and filename describing where
|
|
* something went wrong */
|
|
|
|
void
|
|
show_locus (void)
|
|
{
|
|
if (!options.locus || filename == NULL)
|
|
return;
|
|
|
|
st_printf ("At line %d of file %s\n", line, filename);
|
|
}
|
|
|
|
|
|
/* recursion_check()-- It's possible for additional errors to occur
|
|
* during fatal error processing. We detect this condition here and
|
|
* exit with code 4 immediately. */
|
|
|
|
#define MAGIC 0x20DE8101
|
|
|
|
static void
|
|
recursion_check (void)
|
|
{
|
|
static int magic = 0;
|
|
|
|
/* Don't even try to print something at this point */
|
|
if (magic == MAGIC)
|
|
sys_exit (4);
|
|
|
|
magic = MAGIC;
|
|
}
|
|
|
|
|
|
/* os_error()-- Operating system error. We get a message from the
|
|
* operating system, show it and leave. Some operating system errors
|
|
* are caught and processed by the library. If not, we come here. */
|
|
|
|
void
|
|
os_error (const char *message)
|
|
{
|
|
recursion_check ();
|
|
show_locus ();
|
|
st_printf ("Operating system error: %s\n%s\n", get_oserror (), message);
|
|
sys_exit (1);
|
|
}
|
|
|
|
|
|
/* void runtime_error()-- These are errors associated with an
|
|
* invalid fortran program. */
|
|
|
|
void
|
|
runtime_error (const char *message)
|
|
{
|
|
recursion_check ();
|
|
show_locus ();
|
|
st_printf ("Fortran runtime error: %s\n", message);
|
|
sys_exit (2);
|
|
}
|
|
iexport(runtime_error);
|
|
|
|
|
|
/* void internal_error()-- These are this-can't-happen errors
|
|
* that indicate something deeply wrong. */
|
|
|
|
void
|
|
internal_error (const char *message)
|
|
{
|
|
recursion_check ();
|
|
show_locus ();
|
|
st_printf ("Internal Error: %s\n", message);
|
|
sys_exit (3);
|
|
}
|
|
|
|
|
|
/* translate_error()-- Given an integer error code, return a string
|
|
* describing the error. */
|
|
|
|
const char *
|
|
translate_error (int code)
|
|
{
|
|
const char *p;
|
|
|
|
switch (code)
|
|
{
|
|
case ERROR_EOR:
|
|
p = "End of record";
|
|
break;
|
|
|
|
case ERROR_END:
|
|
p = "End of file";
|
|
break;
|
|
|
|
case ERROR_OK:
|
|
p = "Successful return";
|
|
break;
|
|
|
|
case ERROR_OS:
|
|
p = "Operating system error";
|
|
break;
|
|
|
|
case ERROR_BAD_OPTION:
|
|
p = "Bad statement option";
|
|
break;
|
|
|
|
case ERROR_MISSING_OPTION:
|
|
p = "Missing statement option";
|
|
break;
|
|
|
|
case ERROR_OPTION_CONFLICT:
|
|
p = "Conflicting statement options";
|
|
break;
|
|
|
|
case ERROR_ALREADY_OPEN:
|
|
p = "File already opened in another unit";
|
|
break;
|
|
|
|
case ERROR_BAD_UNIT:
|
|
p = "Unattached unit";
|
|
break;
|
|
|
|
case ERROR_FORMAT:
|
|
p = "FORMAT error";
|
|
break;
|
|
|
|
case ERROR_BAD_ACTION:
|
|
p = "Incorrect ACTION specified";
|
|
break;
|
|
|
|
case ERROR_ENDFILE:
|
|
p = "Read past ENDFILE record";
|
|
break;
|
|
|
|
case ERROR_BAD_US:
|
|
p = "Corrupt unformatted sequential file";
|
|
break;
|
|
|
|
case ERROR_READ_VALUE:
|
|
p = "Bad value during read";
|
|
break;
|
|
|
|
case ERROR_READ_OVERFLOW:
|
|
p = "Numeric overflow on read";
|
|
break;
|
|
|
|
default:
|
|
p = "Unknown error code";
|
|
break;
|
|
}
|
|
|
|
return p;
|
|
}
|
|
|
|
|
|
/* generate_error()-- Come here when an error happens. This
|
|
* subroutine is called if it is possible to continue on after the
|
|
* error. If an IOSTAT variable exists, we set it. If the IOSTAT or
|
|
* ERR label is present, we return, otherwise we terminate the program
|
|
* after print a message. The error code is always required but the
|
|
* message parameter can be NULL, in which case a string describing
|
|
* the most recent operating system error is used. */
|
|
|
|
void
|
|
generate_error (int family, const char *message)
|
|
{
|
|
/* Set the error status. */
|
|
if (ioparm.iostat != NULL)
|
|
*ioparm.iostat = family;
|
|
|
|
/* Report status back to the compiler. */
|
|
switch (family)
|
|
{
|
|
case ERROR_EOR:
|
|
ioparm.library_return = LIBRARY_EOR;
|
|
if (ioparm.eor != 0)
|
|
return;
|
|
break;
|
|
|
|
case ERROR_END:
|
|
ioparm.library_return = LIBRARY_END;
|
|
if (ioparm.end != 0)
|
|
return;
|
|
break;
|
|
|
|
default:
|
|
ioparm.library_return = LIBRARY_ERROR;
|
|
if (ioparm.err != 0)
|
|
return;
|
|
break;
|
|
}
|
|
|
|
/* Return if the user supplied an iostat variable. */
|
|
if (ioparm.iostat != NULL)
|
|
return;
|
|
|
|
/* Terminate the program */
|
|
|
|
if (message == NULL)
|
|
message =
|
|
(family == ERROR_OS) ? get_oserror () : translate_error (family);
|
|
|
|
runtime_error (message);
|
|
}
|