2005-07-09 11:33:31 +02:00
|
|
|
/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
|
2004-05-13 08:41:07 +02:00
|
|
|
Contributed by Andy Vaught
|
|
|
|
|
2005-01-12 22:27:33 +01:00
|
|
|
This file is part of the GNU Fortran 95 runtime library (libgfortran).
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-01-12 22:27:33 +01:00
|
|
|
Libgfortran is free software; you can redistribute it and/or modify
|
2004-05-13 08:41:07 +02:00
|
|
|
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.
|
|
|
|
|
2005-01-12 22:27:33 +01:00
|
|
|
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,
|
2004-05-13 08:41:07 +02:00
|
|
|
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
|
2005-01-12 22:27:33 +01:00
|
|
|
along with libgfortran; see the file COPYING. If not, write to
|
2005-08-17 04:49:08 +02:00
|
|
|
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
#include <assert.h>
|
2004-05-13 08:41:07 +02:00
|
|
|
#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. */
|
|
|
|
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 09:59:05 +01:00
|
|
|
char *filename = 0;
|
|
|
|
iexport_data(filename);
|
|
|
|
|
|
|
|
unsigned line = 0;
|
|
|
|
iexport_data(line);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
/* gfc_itoa()-- Integer to decimal conversion. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
const char *
|
|
|
|
gfc_itoa (GFC_INTEGER_LARGEST n, char *buffer, size_t len)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
int negative;
|
|
|
|
char *p;
|
2005-06-23 20:50:25 +02:00
|
|
|
GFC_UINTEGER_LARGEST t;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
assert (len >= GFC_ITOA_BUF_SIZE);
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
if (n == 0)
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
return "0";
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
negative = 0;
|
2004-08-25 02:31:33 +02:00
|
|
|
t = n;
|
2004-05-13 08:41:07 +02:00
|
|
|
if (n < 0)
|
|
|
|
{
|
|
|
|
negative = 1;
|
2004-08-25 02:31:33 +02:00
|
|
|
t = -n; /*must use unsigned to protect from overflow*/
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
p = buffer + GFC_ITOA_BUF_SIZE - 1;
|
|
|
|
*p = '\0';
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-08-25 02:31:33 +02:00
|
|
|
while (t != 0)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
*--p = '0' + (t % 10);
|
2004-08-25 02:31:33 +02:00
|
|
|
t /= 10;
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (negative)
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
*--p = '-';
|
|
|
|
return p;
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
/* xtoa()-- Integer to hexadecimal conversion. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
const char *
|
|
|
|
xtoa (GFC_UINTEGER_LARGEST n, char *buffer, size_t len)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
int digit;
|
|
|
|
char *p;
|
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
assert (len >= GFC_XTOA_BUF_SIZE);
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
if (n == 0)
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
return "0";
|
2004-05-13 08:41:07 +02:00
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
p = buffer + GFC_XTOA_BUF_SIZE - 1;
|
|
|
|
*p = '\0';
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
while (n != 0)
|
|
|
|
{
|
|
|
|
digit = n & 0xF;
|
|
|
|
if (digit > 9)
|
|
|
|
digit += 'A' - '0' - 10;
|
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
*--p = '0' + digit;
|
2004-05-13 08:41:07 +02:00
|
|
|
n >>= 4;
|
|
|
|
}
|
|
|
|
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
return p;
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 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;
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
char *p;
|
|
|
|
const char *q;
|
2004-05-13 08:41:07 +02:00
|
|
|
stream *s;
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
char itoa_buf[GFC_ITOA_BUF_SIZE];
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
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':
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
q = gfc_itoa (va_arg (arg, int), itoa_buf, sizeof (itoa_buf));
|
2004-05-13 08:41:07 +02:00
|
|
|
count = strlen (q);
|
|
|
|
|
|
|
|
p = salloc_w (s, &count);
|
|
|
|
memmove (p, q, count);
|
|
|
|
sfree (s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'x':
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
q = xtoa (va_arg (arg, unsigned), itoa_buf, sizeof (itoa_buf));
|
2004-05-13 08:41:07 +02:00
|
|
|
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;
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
char c;
|
|
|
|
const char *p;
|
2004-05-13 08:41:07 +02:00
|
|
|
int count;
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
char itoa_buf[GFC_ITOA_BUF_SIZE];
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
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':
|
libgfortran.h (GFC_ITOA_BUF_SIZE, [...]): Define.
* libgfortran.h (GFC_ITOA_BUF_SIZE, GFC_XTOA_BUF_SIZE,
GFC_OTOA_BUF_SIZE, GFC_BTOA_BUF_SIZE): Define.
(gfc_itoa, xtoa): Add 2 extra arguments.
* runtime/environ.c: Include stdio.h.
(check_buffered): Use sprintf.
* runtime/error.c: Include assert.h.
(gfc_itoa, xtoa): Add 2 extra arguments, avoid using static
buffers.
(st_printf, st_sprintf): Adjust callers.
* io/write.c (otoa, btoa): Add 2 extra arguments, avoid using
static buffers.
(write_int, write_decimal): Add 2 extra arguments to conv
function pointer, adjust caller.
(write_integer): Adjust gfc_itoa caller.
* io/unit.c (get_array_unit_len): Return 0 rather than NULL.
* io/read.c (read_f): Remove spurious pointer dereference.
From-SVN: r104855
2005-10-01 13:50:10 +02:00
|
|
|
p = gfc_itoa (va_arg (arg, int), itoa_buf, sizeof (itoa_buf));
|
2004-05-13 08:41:07 +02:00
|
|
|
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;
|
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
/* Don't even try to print something at this point */
|
2004-05-13 08:41:07 +02:00
|
|
|
if (magic == MAGIC)
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
sys_exit (4);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 09:59:05 +01:00
|
|
|
iexport(runtime_error);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* 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);
|
2005-11-04 09:44:29 +01:00
|
|
|
|
|
|
|
/* This function call is here to get the main.o object file included
|
|
|
|
when linking statically. This works because error.o is supposed to
|
|
|
|
be always linked in (and the function call is in internal_error
|
|
|
|
because hopefully it doesn't happen too often). */
|
|
|
|
stupid_function_name_for_static_linking();
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
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
|
gfortran.h: Add iomsg to gfc_open, gfc_close, gfc_filepos, gfc_inquire and gfc_dt.
2005-09-09 Thomas Koenig <Thomas.Koenig@online.de>
* gfortran.h: Add iomsg to gfc_open, gfc_close, gfc_filepos,
gfc_inquire and gfc_dt.
* dump-parse-tree.c (gfc_show_code_node): Add iomsg
for open, close, file positioning, inquire and namelist.
* io.c (io_tag): Add tag_iomsg.
(resolve_tag): Add standards warning for iomsg.
(match_open_element): Add iomsg.
(gfc_free_open): Add iomsg.
(gfc_resolve_open): Add iomsg.
(gfc_free_close): Add iomsg.
(match_close_element): Add iomsg.
(gfc_resolve_close): Add iomsg.
(gfc_free_filepos): Add iomsg.
(match_file_element): Add iomsg.
(gfc_resolve_filepos): Add iostat and iomsg.
(match-dt_element): Add iomsg.
(gfc_free_dt): Add iomsg.
(gfc_resolve_dt): Add iomsg.
(gfc_free_inquire): Add iomsg.
(match_inquire_element): Add iomsg.
(gfc_resolve_inquire): Add iomsg.
* trans_io.c: Add ioparm_iomsg and ioparm_iomsg_len.
(gfc_build_io_library_fndecls): Add iomsg as last field.
(gfc_trans_open): Add iomsg.
(gfc_trans_close): Add iomsg.
(build_fileos): Call set_string for iomsg.
(gfc_trans_inquire): Add iomsg.
(build_dt): Add iomsg.
2005-09-09 Thomas Koenig <Thomas.Koenig@online.de>
* io/io.h: Add iomsg as last field of st_parameter.
* runtime/error.c (generate_error): If iomsg is present, copy
the message there.
2005-09-09 Thomas Koenig <Thomas.Koenig@online.de>
* gfortran.dg/iomsg_1.f90: New test case.
From-SVN: r104102
2005-09-09 20:21:45 +02:00
|
|
|
* subroutine is called if it is possible to continue on after the error.
|
|
|
|
* If an IOSTAT or IOMSG variable exists, we set it. If IOSTAT or
|
|
|
|
* ERR labels are present, we return, otherwise we terminate the program
|
|
|
|
* after printing a message. The error code is always required but the
|
2004-05-13 08:41:07 +02:00
|
|
|
* 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)
|
|
|
|
{
|
2004-09-01 01:43:21 +02:00
|
|
|
/* Set the error status. */
|
2004-05-13 08:41:07 +02:00
|
|
|
if (ioparm.iostat != NULL)
|
2004-09-01 01:43:21 +02:00
|
|
|
*ioparm.iostat = family;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
gfortran.h: Add iomsg to gfc_open, gfc_close, gfc_filepos, gfc_inquire and gfc_dt.
2005-09-09 Thomas Koenig <Thomas.Koenig@online.de>
* gfortran.h: Add iomsg to gfc_open, gfc_close, gfc_filepos,
gfc_inquire and gfc_dt.
* dump-parse-tree.c (gfc_show_code_node): Add iomsg
for open, close, file positioning, inquire and namelist.
* io.c (io_tag): Add tag_iomsg.
(resolve_tag): Add standards warning for iomsg.
(match_open_element): Add iomsg.
(gfc_free_open): Add iomsg.
(gfc_resolve_open): Add iomsg.
(gfc_free_close): Add iomsg.
(match_close_element): Add iomsg.
(gfc_resolve_close): Add iomsg.
(gfc_free_filepos): Add iomsg.
(match_file_element): Add iomsg.
(gfc_resolve_filepos): Add iostat and iomsg.
(match-dt_element): Add iomsg.
(gfc_free_dt): Add iomsg.
(gfc_resolve_dt): Add iomsg.
(gfc_free_inquire): Add iomsg.
(match_inquire_element): Add iomsg.
(gfc_resolve_inquire): Add iomsg.
* trans_io.c: Add ioparm_iomsg and ioparm_iomsg_len.
(gfc_build_io_library_fndecls): Add iomsg as last field.
(gfc_trans_open): Add iomsg.
(gfc_trans_close): Add iomsg.
(build_fileos): Call set_string for iomsg.
(gfc_trans_inquire): Add iomsg.
(build_dt): Add iomsg.
2005-09-09 Thomas Koenig <Thomas.Koenig@online.de>
* io/io.h: Add iomsg as last field of st_parameter.
* runtime/error.c (generate_error): If iomsg is present, copy
the message there.
2005-09-09 Thomas Koenig <Thomas.Koenig@online.de>
* gfortran.dg/iomsg_1.f90: New test case.
From-SVN: r104102
2005-09-09 20:21:45 +02:00
|
|
|
if (message == NULL)
|
|
|
|
message =
|
|
|
|
(family == ERROR_OS) ? get_oserror () : translate_error (family);
|
|
|
|
|
|
|
|
if (ioparm.iomsg)
|
|
|
|
cf_strcpy (ioparm.iomsg, ioparm.iomsg_len, message);
|
|
|
|
|
2004-09-01 01:43:21 +02:00
|
|
|
/* Report status back to the compiler. */
|
2004-05-13 08:41:07 +02:00
|
|
|
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;
|
2004-09-01 01:43:21 +02:00
|
|
|
if (ioparm.err != 0)
|
|
|
|
return;
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-09-01 01:43:21 +02:00
|
|
|
/* Return if the user supplied an iostat variable. */
|
|
|
|
if (ioparm.iostat != NULL)
|
2004-05-13 08:41:07 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Terminate the program */
|
|
|
|
|
|
|
|
runtime_error (message);
|
|
|
|
}
|
2005-08-11 15:50:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Possibly issue a warning/error about use of a nonstandard (or deleted)
|
|
|
|
feature. An error/warning will be issued if the currently selected
|
|
|
|
standard does not contain the requested bits. */
|
|
|
|
|
|
|
|
try
|
|
|
|
notify_std (int std, const char * message)
|
|
|
|
{
|
|
|
|
int warning;
|
|
|
|
|
|
|
|
warning = compile_options.warn_std & std;
|
|
|
|
if ((compile_options.allow_std & std) != 0 && !warning)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
show_locus ();
|
|
|
|
if (!warning)
|
|
|
|
{
|
|
|
|
st_printf ("Fortran runtime error: %s\n", message);
|
|
|
|
sys_exit (2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
st_printf ("Fortran runtime warning: %s\n", message);
|
|
|
|
return FAILURE;
|
|
|
|
}
|