2005-04-17 22:09:37 +02:00
|
|
|
/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
2004-05-13 08:41:07 +02:00
|
|
|
Contributed by Andy Vaught
|
2005-04-17 22:09:37 +02:00
|
|
|
Namelist input contributed by Paul Thomas
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
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.)
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
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 <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "libgfortran.h"
|
|
|
|
#include "io.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* List directed input. Several parsing subroutines are practically
|
2004-08-23 16:28:31 +02:00
|
|
|
reimplemented from formatted input, the reason being that there are
|
|
|
|
all kinds of small differences between formatted and list directed
|
|
|
|
parsing. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Subroutines for reading characters from the input. Because a
|
2004-08-23 16:28:31 +02:00
|
|
|
repeat count is ambiguous with an integer, we have to read the
|
|
|
|
whole digit string before seeing if there is a '*' which signals
|
|
|
|
the repeat count. Since we can have a lot of potential leading
|
|
|
|
zeros, we have to be able to back up by arbitrary amount. Because
|
|
|
|
the input might not be seekable, we have to buffer the data
|
|
|
|
ourselves. Data is buffered in scratch[] until it becomes too
|
|
|
|
large, after which we start allocating memory on the heap. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
static int repeat_count, saved_length, saved_used;
|
|
|
|
static int input_complete, at_eol, comma_flag;
|
2004-05-13 08:41:07 +02:00
|
|
|
static char last_char, *saved_string;
|
|
|
|
static bt saved_type;
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* A namelist specific flag used in the list directed library
|
|
|
|
to flag that calls are being made from namelist read (eg. to ignore
|
|
|
|
comments or to treat '/' as a terminator) */
|
|
|
|
|
|
|
|
static int namelist_mode;
|
|
|
|
|
|
|
|
/* A namelist specific flag used in the list directed library to flag
|
|
|
|
read errors and return, so that an attempt can be made to read a
|
|
|
|
new object name. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
static int nml_read_error;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
/* Storage area for values except for strings. Must be large enough
|
2004-08-23 16:28:31 +02:00
|
|
|
to hold a complex value (two reals) of the largest kind. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static char value[20];
|
|
|
|
|
|
|
|
#define CASE_DIGITS case '0': case '1': case '2': case '3': case '4': \
|
|
|
|
case '5': case '6': case '7': case '8': case '9'
|
|
|
|
|
2005-03-25 14:35:29 +01:00
|
|
|
#define CASE_SEPARATORS case ' ': case ',': case '/': case '\n': case '\t': \
|
|
|
|
case '\r'
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* This macro assumes that we're operating on a variable. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
#define is_separator(c) (c == '/' || c == ',' || c == '\n' || c == ' ' \
|
2005-03-25 14:35:29 +01:00
|
|
|
|| c == '\t' || c == '\r')
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Maximum repeat count. Less than ten times the maximum signed int32. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
#define MAX_REPEAT 200000000
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Save a character to a string buffer, enlarging it as necessary. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
push_char (char c)
|
|
|
|
{
|
|
|
|
char *new;
|
|
|
|
|
|
|
|
if (saved_string == NULL)
|
|
|
|
{
|
|
|
|
saved_string = scratch;
|
|
|
|
memset (saved_string,0,SCRATCH_SIZE);
|
|
|
|
saved_length = SCRATCH_SIZE;
|
|
|
|
saved_used = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saved_used >= saved_length)
|
|
|
|
{
|
|
|
|
saved_length = 2 * saved_length;
|
|
|
|
new = get_mem (2 * saved_length);
|
|
|
|
|
|
|
|
memset (new,0,2 * saved_length);
|
|
|
|
|
|
|
|
memcpy (new, saved_string, saved_used);
|
|
|
|
if (saved_string != scratch)
|
|
|
|
free_mem (saved_string);
|
|
|
|
|
|
|
|
saved_string = new;
|
|
|
|
}
|
|
|
|
|
|
|
|
saved_string[saved_used++] = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Free the input buffer if necessary. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
free_saved (void)
|
|
|
|
{
|
|
|
|
if (saved_string == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (saved_string != scratch)
|
|
|
|
free_mem (saved_string);
|
|
|
|
|
|
|
|
saved_string = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char
|
|
|
|
next_char (void)
|
|
|
|
{
|
|
|
|
int length;
|
|
|
|
char c, *p;
|
|
|
|
|
|
|
|
if (last_char != '\0')
|
|
|
|
{
|
|
|
|
at_eol = 0;
|
|
|
|
c = last_char;
|
|
|
|
last_char = '\0';
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
|
|
p = salloc_r (current_unit->s, &length);
|
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_OS, NULL);
|
|
|
|
return '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (length == 0)
|
2004-08-31 22:37:43 +02:00
|
|
|
{
|
|
|
|
/* For internal files return a newline instead of signalling EOF. */
|
|
|
|
/* ??? This isn't quite right, but we don't handle internal files
|
|
|
|
with multiple records. */
|
|
|
|
if (is_internal_unit ())
|
|
|
|
c = '\n';
|
|
|
|
else
|
|
|
|
longjmp (g.eof_jump, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c = *p;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
done:
|
2005-03-25 14:35:29 +01:00
|
|
|
at_eol = (c == '\n' || c == '\r');
|
2004-05-13 08:41:07 +02:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Push a character back onto the input. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
unget_char (char c)
|
|
|
|
{
|
|
|
|
last_char = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Skip over spaces in the input. Returns the nonspace character that
|
|
|
|
terminated the eating and also places it back on the input. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static char
|
|
|
|
eat_spaces (void)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
}
|
|
|
|
while (c == ' ' || c == '\t');
|
|
|
|
|
|
|
|
unget_char (c);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Skip over a separator. Technically, we don't always eat the whole
|
|
|
|
separator. This is because if we've processed the last input item,
|
|
|
|
then a separator is unnecessary. Plus the fact that operating
|
|
|
|
systems usually deliver console input on a line basis.
|
|
|
|
|
|
|
|
The upshot is that if we see a newline as part of reading a
|
|
|
|
separator, we stop reading. If there are more input items, we
|
|
|
|
continue reading the separator with finish_separator() which takes
|
|
|
|
care of the fact that we may or may not have seen a comma as part
|
|
|
|
of the separator. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
eat_separator (void)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
|
|
|
|
eat_spaces ();
|
|
|
|
comma_flag = 0;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case ',':
|
|
|
|
comma_flag = 1;
|
|
|
|
eat_spaces ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/':
|
|
|
|
input_complete = 1;
|
2005-04-17 22:09:37 +02:00
|
|
|
if (!namelist_mode)
|
|
|
|
{
|
|
|
|
next_record (0);
|
|
|
|
at_eol = 1;
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '\n':
|
2005-03-25 14:35:29 +01:00
|
|
|
case '\r':
|
2005-04-17 22:09:37 +02:00
|
|
|
at_eol = 1;
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '!':
|
|
|
|
if (namelist_mode)
|
2004-08-23 16:28:31 +02:00
|
|
|
{ /* Eat a namelist comment. */
|
2004-05-13 08:41:07 +02:00
|
|
|
do
|
|
|
|
c = next_char ();
|
|
|
|
while (c != '\n');
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Fall Through... */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
unget_char (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Finish processing a separator that was interrupted by a newline.
|
|
|
|
If we're here, then another data item is present, so we finish what
|
|
|
|
we started on the previous line. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
finish_separator (void)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
|
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
|
|
|
restart:
|
2004-05-13 08:41:07 +02:00
|
|
|
eat_spaces ();
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case ',':
|
|
|
|
if (comma_flag)
|
|
|
|
unget_char (c);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
c = eat_spaces ();
|
|
|
|
if (c == '\n')
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/':
|
|
|
|
input_complete = 1;
|
2005-04-17 22:09:37 +02:00
|
|
|
if (!namelist_mode) next_record (0);
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '\n':
|
2005-03-25 14:35:29 +01:00
|
|
|
case '\r':
|
2004-05-13 08:41:07 +02:00
|
|
|
goto restart;
|
|
|
|
|
|
|
|
case '!':
|
|
|
|
if (namelist_mode)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
c = next_char ();
|
|
|
|
while (c != '\n');
|
|
|
|
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
unget_char (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* This function is needed to catch bad conversions so that namelist can
|
|
|
|
attempt to see if saved_string contains a new object name rather than
|
|
|
|
a bad value. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
nml_bad_return (char c)
|
|
|
|
{
|
|
|
|
if (namelist_mode)
|
|
|
|
{
|
|
|
|
nml_read_error = 1;
|
|
|
|
unget_char(c);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Convert an unsigned string to an integer. The length value is -1
|
|
|
|
if we are working on a repeat count. Returns nonzero if we have a
|
|
|
|
range problem. As a side effect, frees the saved_string. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static int
|
|
|
|
convert_integer (int length, int negative)
|
|
|
|
{
|
|
|
|
char c, *buffer, message[100];
|
|
|
|
int m;
|
|
|
|
int64_t v, max, max10;
|
|
|
|
|
|
|
|
buffer = saved_string;
|
|
|
|
v = 0;
|
|
|
|
|
|
|
|
max = (length == -1) ? MAX_REPEAT : max_value (length, 1);
|
|
|
|
max10 = max / 10;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = *buffer++;
|
|
|
|
if (c == '\0')
|
|
|
|
break;
|
|
|
|
c -= '0';
|
|
|
|
|
|
|
|
if (v > max10)
|
|
|
|
goto overflow;
|
|
|
|
v = 10 * v;
|
|
|
|
|
|
|
|
if (v > max - c)
|
|
|
|
goto overflow;
|
|
|
|
v += c;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = 0;
|
|
|
|
|
|
|
|
if (length != -1)
|
|
|
|
{
|
|
|
|
if (negative)
|
|
|
|
v = -v;
|
|
|
|
set_integer (value, v, length);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
repeat_count = v;
|
|
|
|
|
|
|
|
if (repeat_count == 0)
|
|
|
|
{
|
|
|
|
st_sprintf (message, "Zero repeat count in item %d of list input",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
m = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
return m;
|
|
|
|
|
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
|
|
|
overflow:
|
2004-05-13 08:41:07 +02:00
|
|
|
if (length == -1)
|
|
|
|
st_sprintf (message, "Repeat count overflow in item %d of list input",
|
|
|
|
g.item_count);
|
|
|
|
else
|
|
|
|
st_sprintf (message, "Integer overflow while reading item %d",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Parse a repeat count for logical and complex values which cannot
|
|
|
|
begin with a digit. Returns nonzero if we are done, zero if we
|
|
|
|
should continue on. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static int
|
|
|
|
parse_repeat (void)
|
|
|
|
{
|
|
|
|
char c, message[100];
|
|
|
|
int repeat;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
repeat = c - '0';
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unget_char (c);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
repeat = 10 * repeat + c - '0';
|
|
|
|
|
|
|
|
if (repeat > MAX_REPEAT)
|
|
|
|
{
|
|
|
|
st_sprintf (message,
|
|
|
|
"Repeat count overflow in item %d of list input",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '*':
|
|
|
|
if (repeat == 0)
|
|
|
|
{
|
|
|
|
st_sprintf (message,
|
|
|
|
"Zero repeat count in item %d of list input",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_repeat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
done:
|
2004-05-13 08:41:07 +02:00
|
|
|
repeat_count = repeat;
|
|
|
|
return 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
|
|
|
bad_repeat:
|
2004-05-13 08:41:07 +02:00
|
|
|
st_sprintf (message, "Bad repeat count in item %d of list input",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Read a logical character on the input. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
read_logical (int length)
|
|
|
|
{
|
|
|
|
char c, message[100];
|
|
|
|
int v;
|
|
|
|
|
|
|
|
if (parse_repeat ())
|
|
|
|
return;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 't':
|
|
|
|
case 'T':
|
|
|
|
v = 1;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
case 'F':
|
|
|
|
v = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 't':
|
|
|
|
case 'T':
|
|
|
|
v = 1;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
case 'F':
|
|
|
|
v = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto bad_logical;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
2004-08-23 16:28:31 +02:00
|
|
|
return; /* Null value. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_logical;
|
|
|
|
}
|
|
|
|
|
|
|
|
saved_type = BT_LOGICAL;
|
|
|
|
saved_length = length;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Eat trailing garbage. */
|
2004-05-13 08:41:07 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
}
|
|
|
|
while (!is_separator (c));
|
|
|
|
|
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
free_saved ();
|
|
|
|
set_integer ((int *) value, v, length);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
bad_logical:
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
if (nml_bad_return (c))
|
|
|
|
return;
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
st_sprintf (message, "Bad logical value while reading item %d",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Reading integers is tricky because we can actually be reading a
|
|
|
|
repeat count. We have to store the characters in a buffer because
|
|
|
|
we could be reading an integer that is larger than the default int
|
|
|
|
used for repeat counts. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
read_integer (int length)
|
|
|
|
{
|
|
|
|
char c, message[100];
|
|
|
|
int negative;
|
|
|
|
|
|
|
|
negative = 0;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '-':
|
|
|
|
negative = 1;
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Fall through... */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
case '+':
|
|
|
|
c = next_char ();
|
|
|
|
goto get_integer;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
CASE_SEPARATORS: /* Single null. */
|
2004-05-13 08:41:07 +02:00
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
return;
|
|
|
|
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_integer;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Take care of what may be a repeat count. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '*':
|
|
|
|
push_char ('\0');
|
|
|
|
goto repeat;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
CASE_SEPARATORS: /* Not a repeat count. */
|
2004-05-13 08:41:07 +02:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_integer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
repeat:
|
2004-05-13 08:41:07 +02:00
|
|
|
if (convert_integer (-1, 0))
|
|
|
|
return;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Get the real integer. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case '-':
|
|
|
|
negative = 1;
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Fall through... */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
case '+':
|
|
|
|
c = next_char ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
get_integer:
|
2004-05-13 08:41:07 +02:00
|
|
|
if (!isdigit (c))
|
|
|
|
goto bad_integer;
|
|
|
|
push_char (c);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_integer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
bad_integer:
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
if (nml_bad_return (c))
|
|
|
|
return;
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
free_saved ();
|
|
|
|
|
|
|
|
st_sprintf (message, "Bad integer for item %d in list input", g.item_count);
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
done:
|
2004-05-13 08:41:07 +02:00
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
|
|
|
|
push_char ('\0');
|
|
|
|
if (convert_integer (length, negative))
|
|
|
|
{
|
|
|
|
free_saved ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
saved_type = BT_INTEGER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Read a character variable. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
read_character (int length)
|
|
|
|
{
|
|
|
|
char c, quote, message[100];
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
quote = ' '; /* Space means no quote character. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
2004-08-23 16:28:31 +02:00
|
|
|
unget_char (c); /* NULL value. */
|
2004-05-13 08:41:07 +02:00
|
|
|
eat_separator ();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case '"':
|
|
|
|
case '\'':
|
|
|
|
quote = c;
|
|
|
|
goto get_string;
|
|
|
|
|
|
|
|
default:
|
|
|
|
push_char (c);
|
|
|
|
goto get_string;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Deal with a possible repeat count. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
unget_char (c);
|
2004-08-23 16:28:31 +02:00
|
|
|
goto done; /* String was only digits! */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
case '*':
|
|
|
|
push_char ('\0');
|
|
|
|
goto got_repeat;
|
|
|
|
|
|
|
|
default:
|
|
|
|
push_char (c);
|
2004-08-23 16:28:31 +02:00
|
|
|
goto get_string; /* Not a repeat count after all. */
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
got_repeat:
|
2004-05-13 08:41:07 +02:00
|
|
|
if (convert_integer (-1, 0))
|
|
|
|
return;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Now get the real string. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_SEPARATORS:
|
2004-08-23 16:28:31 +02:00
|
|
|
unget_char (c); /* Repeated NULL values. */
|
2004-05-13 08:41:07 +02:00
|
|
|
eat_separator ();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case '"':
|
|
|
|
case '\'':
|
|
|
|
quote = c;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
get_string:
|
2004-05-13 08:41:07 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '"':
|
|
|
|
case '\'':
|
|
|
|
if (c != quote)
|
|
|
|
{
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* See if we have a doubled quote character or the end of
|
|
|
|
the string. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
if (c == quote)
|
|
|
|
{
|
|
|
|
push_char (quote);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
unget_char (c);
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
if (quote == ' ')
|
|
|
|
{
|
|
|
|
unget_char (c);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c != '\n')
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* At this point, we have to have a separator, or else the string is
|
|
|
|
invalid. */
|
|
|
|
done:
|
2004-05-13 08:41:07 +02:00
|
|
|
c = next_char ();
|
|
|
|
if (is_separator (c))
|
|
|
|
{
|
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
saved_type = BT_CHARACTER;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free_saved ();
|
|
|
|
st_sprintf (message, "Invalid string input in item %d", g.item_count);
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Parse a component of a complex constant or a real number that we
|
|
|
|
are sure is already there. This is a straight real number parser. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static int
|
|
|
|
parse_real (void *buffer, int length)
|
|
|
|
{
|
|
|
|
char c, message[100];
|
|
|
|
int m, seen_dp;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
if (c == '-' || c == '+')
|
|
|
|
{
|
|
|
|
push_char (c);
|
|
|
|
c = next_char ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isdigit (c) && c != '.')
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
push_char (c);
|
|
|
|
|
|
|
|
seen_dp = (c == '.') ? 1 : 0;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
if (seen_dp)
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
seen_dp = 1;
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e':
|
|
|
|
case 'E':
|
|
|
|
case 'd':
|
|
|
|
case 'D':
|
|
|
|
push_char ('e');
|
|
|
|
goto exp1;
|
|
|
|
|
|
|
|
case '-':
|
|
|
|
case '+':
|
|
|
|
push_char ('e');
|
|
|
|
push_char (c);
|
|
|
|
c = next_char ();
|
|
|
|
goto exp2;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
unget_char (c);
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
exp1:
|
2004-05-13 08:41:07 +02:00
|
|
|
c = next_char ();
|
|
|
|
if (c != '-' && c != '+')
|
|
|
|
push_char ('+');
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push_char (c);
|
|
|
|
c = next_char ();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
exp2:
|
2004-05-13 08:41:07 +02:00
|
|
|
if (!isdigit (c))
|
|
|
|
goto bad;
|
|
|
|
push_char (c);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
unget_char (c);
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
done:
|
2004-05-13 08:41:07 +02:00
|
|
|
unget_char (c);
|
|
|
|
push_char ('\0');
|
|
|
|
|
|
|
|
m = convert_real (buffer, saved_string, length);
|
|
|
|
free_saved ();
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
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
|
|
|
bad:
|
2004-05-13 08:41:07 +02:00
|
|
|
free_saved ();
|
|
|
|
st_sprintf (message, "Bad floating point number for item %d", g.item_count);
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Reading a complex number is straightforward because we can tell
|
|
|
|
what it is right away. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
read_complex (int length)
|
|
|
|
{
|
|
|
|
char message[100];
|
|
|
|
char c;
|
|
|
|
|
|
|
|
if (parse_repeat ())
|
|
|
|
return;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '(':
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_complex;
|
|
|
|
}
|
|
|
|
|
|
|
|
eat_spaces ();
|
|
|
|
if (parse_real (value, length))
|
|
|
|
return;
|
|
|
|
|
|
|
|
eat_spaces ();
|
|
|
|
if (next_char () != ',')
|
|
|
|
goto bad_complex;
|
|
|
|
|
|
|
|
eat_spaces ();
|
|
|
|
if (parse_real (value + length, length))
|
|
|
|
return;
|
|
|
|
|
|
|
|
eat_spaces ();
|
|
|
|
if (next_char () != ')')
|
|
|
|
goto bad_complex;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
if (!is_separator (c))
|
|
|
|
goto bad_complex;
|
|
|
|
|
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
saved_type = BT_COMPLEX;
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
bad_complex:
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
if (nml_bad_return (c))
|
|
|
|
return;
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
st_sprintf (message, "Bad complex value in item %d of list input",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Parse a real number with a possible repeat count. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
read_real (int length)
|
|
|
|
{
|
|
|
|
char c, message[100];
|
|
|
|
int seen_dp;
|
|
|
|
|
|
|
|
seen_dp = 0;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
push_char (c);
|
|
|
|
seen_dp = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '+':
|
|
|
|
case '-':
|
|
|
|
goto got_sign;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
2004-08-23 16:28:31 +02:00
|
|
|
unget_char (c); /* Single null. */
|
2004-05-13 08:41:07 +02:00
|
|
|
eat_separator ();
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_real;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Get the digit string that might be a repeat count. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
if (seen_dp)
|
|
|
|
goto bad_real;
|
|
|
|
|
|
|
|
seen_dp = 1;
|
|
|
|
push_char (c);
|
|
|
|
goto real_loop;
|
|
|
|
|
|
|
|
case 'E':
|
|
|
|
case 'e':
|
|
|
|
case 'D':
|
|
|
|
case 'd':
|
|
|
|
goto exp1;
|
|
|
|
|
|
|
|
case '+':
|
|
|
|
case '-':
|
|
|
|
push_char ('e');
|
|
|
|
push_char (c);
|
|
|
|
c = next_char ();
|
|
|
|
goto exp2;
|
|
|
|
|
|
|
|
case '*':
|
|
|
|
push_char ('\0');
|
|
|
|
goto got_repeat;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
2005-03-25 14:35:29 +01:00
|
|
|
if (c != '\n' && c != ',' && c != '\r')
|
|
|
|
unget_char (c);
|
2004-05-13 08:41:07 +02:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_real;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
got_repeat:
|
2004-05-13 08:41:07 +02:00
|
|
|
if (convert_integer (-1, 0))
|
|
|
|
return;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Now get the number itself. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
if (is_separator (c))
|
2004-08-23 16:28:31 +02:00
|
|
|
{ /* Repeated null value. */
|
2004-05-13 08:41:07 +02:00
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c != '-' && c != '+')
|
|
|
|
push_char ('+');
|
|
|
|
else
|
|
|
|
{
|
|
|
|
got_sign:
|
|
|
|
push_char (c);
|
|
|
|
c = next_char ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isdigit (c) && c != '.')
|
|
|
|
goto bad_real;
|
|
|
|
|
|
|
|
if (c == '.')
|
|
|
|
{
|
|
|
|
if (seen_dp)
|
|
|
|
goto bad_real;
|
|
|
|
else
|
|
|
|
seen_dp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
push_char (c);
|
|
|
|
|
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
|
|
|
real_loop:
|
2004-05-13 08:41:07 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
if (seen_dp)
|
|
|
|
goto bad_real;
|
|
|
|
|
|
|
|
seen_dp = 1;
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'E':
|
|
|
|
case 'e':
|
|
|
|
case 'D':
|
|
|
|
case 'd':
|
|
|
|
goto exp1;
|
|
|
|
|
|
|
|
case '+':
|
|
|
|
case '-':
|
|
|
|
push_char ('e');
|
|
|
|
push_char (c);
|
|
|
|
c = next_char ();
|
|
|
|
goto exp2;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_real;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
exp1:
|
2004-05-13 08:41:07 +02:00
|
|
|
push_char ('e');
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
if (c != '+' && c != '-')
|
|
|
|
push_char ('+');
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push_char (c);
|
|
|
|
c = next_char ();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
exp2:
|
2004-05-13 08:41:07 +02:00
|
|
|
if (!isdigit (c))
|
|
|
|
goto bad_real;
|
|
|
|
push_char (c);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_SEPARATORS:
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto bad_real;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
done:
|
2005-02-23 05:09:17 +01:00
|
|
|
unget_char (c);
|
|
|
|
eat_separator ();
|
2004-05-13 08:41:07 +02:00
|
|
|
push_char ('\0');
|
|
|
|
if (convert_real (value, saved_string, length))
|
|
|
|
return;
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
saved_type = BT_REAL;
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
bad_real:
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
if (nml_bad_return (c))
|
|
|
|
return;
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
st_sprintf (message, "Bad real number in item %d of list input",
|
|
|
|
g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Check the current type against the saved type to make sure they are
|
|
|
|
compatible. Returns nonzero if incompatible. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static int
|
|
|
|
check_type (bt type, int len)
|
|
|
|
{
|
|
|
|
char message[100];
|
|
|
|
|
|
|
|
if (saved_type != BT_NULL && saved_type != type)
|
|
|
|
{
|
|
|
|
st_sprintf (message, "Read type %s where %s was expected for item %d",
|
|
|
|
type_name (saved_type), type_name (type), g.item_count);
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saved_type == BT_NULL || saved_type == BT_CHARACTER)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (saved_length != len)
|
|
|
|
{
|
|
|
|
st_sprintf (message,
|
|
|
|
"Read kind %d %s where kind %d is required for item %d",
|
|
|
|
saved_length, type_name (saved_type), len, g.item_count);
|
|
|
|
generate_error (ERROR_READ_VALUE, message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Top level data transfer subroutine for list reads. Because we have
|
|
|
|
to deal with repeat counts, the data item is always saved after
|
|
|
|
reading, usually in the value[] array. If a repeat count is
|
|
|
|
greater than one, we copy the data item multiple times. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
list_formatted_read (bt type, void *p, int len)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
int m;
|
|
|
|
|
|
|
|
namelist_mode = 0;
|
|
|
|
|
|
|
|
if (setjmp (g.eof_jump))
|
|
|
|
{
|
|
|
|
generate_error (ERROR_END, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g.first_item)
|
|
|
|
{
|
|
|
|
g.first_item = 0;
|
|
|
|
input_complete = 0;
|
|
|
|
repeat_count = 1;
|
|
|
|
at_eol = 0;
|
|
|
|
|
|
|
|
c = eat_spaces ();
|
|
|
|
if (is_separator (c))
|
2004-08-23 16:28:31 +02:00
|
|
|
{ /* Found a null value. */
|
2004-05-13 08:41:07 +02:00
|
|
|
eat_separator ();
|
|
|
|
repeat_count = 0;
|
|
|
|
if (at_eol)
|
|
|
|
finish_separator ();
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (input_complete)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (repeat_count > 0)
|
|
|
|
{
|
|
|
|
if (check_type (type, len))
|
|
|
|
return;
|
|
|
|
goto set_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (at_eol)
|
|
|
|
finish_separator ();
|
|
|
|
else
|
2004-09-14 02:56:46 +02:00
|
|
|
{
|
|
|
|
eat_spaces ();
|
|
|
|
/* trailing spaces prior to end of line */
|
|
|
|
if (at_eol)
|
|
|
|
finish_separator ();
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
saved_type = BT_NULL;
|
|
|
|
repeat_count = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case BT_INTEGER:
|
|
|
|
read_integer (len);
|
|
|
|
break;
|
|
|
|
case BT_LOGICAL:
|
|
|
|
read_logical (len);
|
|
|
|
break;
|
|
|
|
case BT_CHARACTER:
|
|
|
|
read_character (len);
|
|
|
|
break;
|
|
|
|
case BT_REAL:
|
|
|
|
read_real (len);
|
|
|
|
break;
|
|
|
|
case BT_COMPLEX:
|
|
|
|
read_complex (len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
internal_error ("Bad type for list read");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saved_type != BT_CHARACTER && saved_type != BT_NULL)
|
|
|
|
saved_length = len;
|
|
|
|
|
|
|
|
if (ioparm.library_return != LIBRARY_OK)
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
set_value:
|
2004-05-13 08:41:07 +02:00
|
|
|
switch (saved_type)
|
|
|
|
{
|
|
|
|
case BT_COMPLEX:
|
|
|
|
len = 2 * len;
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Fall through. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
case BT_INTEGER:
|
|
|
|
case BT_REAL:
|
|
|
|
case BT_LOGICAL:
|
|
|
|
memcpy (p, value, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BT_CHARACTER:
|
2004-06-19 18:42:05 +02:00
|
|
|
if (saved_string)
|
|
|
|
{
|
|
|
|
m = (len < saved_used) ? len : saved_used;
|
|
|
|
memcpy (p, saved_string, m);
|
|
|
|
}
|
2004-08-23 16:28:31 +02:00
|
|
|
else
|
|
|
|
/* Just delimiters encountered, nothing to copy but SPACE. */
|
2004-06-19 18:42:05 +02:00
|
|
|
m = 0;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (m < len)
|
|
|
|
memset (((char *) p) + m, ' ', len - m);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BT_NULL:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (--repeat_count <= 0)
|
|
|
|
free_saved ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
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
|
|
|
init_at_eol(void)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
at_eol = 0;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Finish a list read. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
finish_list_read (void)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
|
|
|
|
if (at_eol)
|
|
|
|
{
|
|
|
|
at_eol = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
}
|
|
|
|
while (c != '\n');
|
|
|
|
}
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* NAMELIST INPUT
|
|
|
|
|
|
|
|
void namelist_read (void)
|
|
|
|
calls:
|
|
|
|
static void nml_match_name (char *name, int len)
|
|
|
|
static int nml_query (void)
|
|
|
|
static int nml_get_obj_data (void)
|
|
|
|
calls:
|
|
|
|
static void nml_untouch_nodes (void)
|
|
|
|
static namelist_info * find_nml_node (char * var_name)
|
|
|
|
static int nml_parse_qualifier(descriptor_dimension * ad,
|
|
|
|
nml_loop_spec * ls, int rank)
|
|
|
|
static void nml_touch_nodes (namelist_info * nl)
|
|
|
|
static int nml_read_obj (namelist_info * nl, index_type offset)
|
|
|
|
calls:
|
|
|
|
-itself- */
|
|
|
|
|
|
|
|
/* Carries error messages from the qualifier parser. */
|
|
|
|
static char parse_err_msg[30];
|
|
|
|
|
|
|
|
/* Carries error messages for error returns. */
|
|
|
|
static char nml_err_msg[100];
|
|
|
|
|
|
|
|
/* Pointer to the previously read object, in case attempt is made to read
|
|
|
|
new object name. Should this fail, error message can give previous
|
|
|
|
name. */
|
|
|
|
|
|
|
|
static namelist_info * prev_nl;
|
|
|
|
|
|
|
|
/* Lower index for substring qualifier. */
|
|
|
|
|
|
|
|
static index_type clow;
|
|
|
|
|
|
|
|
/* Upper index for substring qualifier. */
|
|
|
|
|
|
|
|
static index_type chigh;
|
|
|
|
|
|
|
|
/* Inputs a rank-dimensional qualifier, which can contain
|
|
|
|
singlets, doublets, triplets or ':' with the standard meanings. */
|
|
|
|
|
|
|
|
static try
|
|
|
|
nml_parse_qualifier(descriptor_dimension * ad,
|
|
|
|
nml_loop_spec * ls, int rank)
|
|
|
|
{
|
|
|
|
int dim;
|
|
|
|
int indx;
|
|
|
|
int neg;
|
|
|
|
int null_flag;
|
|
|
|
char c;
|
|
|
|
|
|
|
|
/* The next character in the stream should be the '('. */
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
|
|
|
|
/* Process the qualifier, by dimension and triplet. */
|
|
|
|
|
|
|
|
for (dim=0; dim < rank; dim++ )
|
|
|
|
{
|
|
|
|
for (indx=0; indx<3; indx++)
|
|
|
|
{
|
|
|
|
free_saved ();
|
|
|
|
eat_spaces ();
|
|
|
|
neg = 0;
|
|
|
|
|
|
|
|
/*process a potential sign. */
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '-':
|
|
|
|
neg = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '+':
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unget_char (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*process characters up to the next ':' , ',' or ')' */
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = next_char ();
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case ':':
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ',': case ')':
|
|
|
|
if ( (c==',' && dim == rank -1)
|
|
|
|
|| (c==')' && dim < rank -1))
|
|
|
|
{
|
|
|
|
st_sprintf (parse_err_msg,
|
|
|
|
"Bad number of index fields");
|
|
|
|
goto err_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_DIGITS:
|
|
|
|
push_char (c);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case ' ': case '\t':
|
|
|
|
eat_spaces ();
|
|
|
|
c = next_char ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
st_sprintf (parse_err_msg, "Bad character in index");
|
|
|
|
goto err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (( c==',' || c==')') && indx==0 && saved_string == 0 )
|
|
|
|
{
|
|
|
|
st_sprintf (parse_err_msg, "Null index field");
|
|
|
|
goto err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( c==':' && indx==1 && saved_string == 0)
|
|
|
|
|| (indx==2 && saved_string == 0))
|
|
|
|
{
|
|
|
|
st_sprintf(parse_err_msg, "Bad index triplet");
|
|
|
|
goto err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If '( : ? )' or '( ? : )' break and flag read failure. */
|
|
|
|
null_flag = 0;
|
|
|
|
if ( (c==':' && indx==0 && saved_string == 0)
|
|
|
|
|| (indx==1 && saved_string == 0))
|
|
|
|
{
|
|
|
|
null_flag = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now read the index. */
|
|
|
|
|
|
|
|
if (convert_integer (sizeof(int),neg))
|
|
|
|
{
|
|
|
|
st_sprintf (parse_err_msg, "Bad integer in index");
|
|
|
|
goto err_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*feed the index values to the triplet arrays. */
|
|
|
|
|
|
|
|
if (!null_flag)
|
|
|
|
{
|
|
|
|
if (indx == 0)
|
|
|
|
ls[dim].start = *(int *)value;
|
|
|
|
if (indx == 1)
|
|
|
|
ls[dim].end = *(int *)value;
|
|
|
|
if (indx == 2)
|
|
|
|
ls[dim].step = *(int *)value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*singlet or doublet indices */
|
|
|
|
|
|
|
|
if (c==',' || c==')')
|
|
|
|
{
|
|
|
|
if (indx == 0)
|
|
|
|
{
|
|
|
|
ls[dim].start = *(int *)value;
|
|
|
|
ls[dim].end = *(int *)value;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Check the values of the triplet indices. */
|
|
|
|
|
|
|
|
if ( (ls[dim].start > (ssize_t)ad[dim].ubound)
|
|
|
|
|| (ls[dim].start < (ssize_t)ad[dim].lbound)
|
|
|
|
|| (ls[dim].end > (ssize_t)ad[dim].ubound)
|
|
|
|
|| (ls[dim].end < (ssize_t)ad[dim].lbound))
|
|
|
|
{
|
|
|
|
st_sprintf (parse_err_msg, "Index %d out of range", dim + 1);
|
|
|
|
goto err_ret;
|
|
|
|
}
|
|
|
|
if (((ls[dim].end - ls[dim].start ) * ls[dim].step < 0)
|
|
|
|
|| (ls[dim].step == 0))
|
|
|
|
{
|
|
|
|
st_sprintf (parse_err_msg, "Bad range in index %d", dim + 1);
|
|
|
|
goto err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialise the loop index counter. */
|
|
|
|
|
|
|
|
ls[dim].idx = ls[dim].start;
|
|
|
|
|
|
|
|
}
|
|
|
|
eat_spaces ();
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
err_ret:
|
|
|
|
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
static namelist_info *
|
|
|
|
find_nml_node (char * var_name)
|
|
|
|
{
|
2005-04-17 22:09:37 +02:00
|
|
|
namelist_info * t = ionml;
|
|
|
|
while (t != NULL)
|
|
|
|
{
|
|
|
|
if (strcmp (var_name,t->var_name) == 0)
|
|
|
|
{
|
|
|
|
t->touched = 1;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
t = t->next;
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* Visits all the components of a derived type that have
|
|
|
|
not explicitly been identified in the namelist input.
|
|
|
|
touched is set and the loop specification initialised
|
|
|
|
to default values */
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
static void
|
2005-04-17 22:09:37 +02:00
|
|
|
nml_touch_nodes (namelist_info * nl)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2005-04-17 22:09:37 +02:00
|
|
|
index_type len = strlen (nl->var_name) + 1;
|
|
|
|
int dim;
|
|
|
|
char * ext_name = (char*)get_mem (len + 1);
|
|
|
|
strcpy (ext_name, nl->var_name);
|
|
|
|
strcat (ext_name, "%");
|
|
|
|
for (nl = nl->next; nl; nl = nl->next)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2005-04-17 22:09:37 +02:00
|
|
|
if (strncmp (nl->var_name, ext_name, len) == 0)
|
|
|
|
{
|
|
|
|
nl->touched = 1;
|
|
|
|
for (dim=0; dim < nl->var_rank; dim++)
|
|
|
|
{
|
|
|
|
nl->ls[dim].step = 1;
|
|
|
|
nl->ls[dim].end = nl->dim[dim].ubound;
|
|
|
|
nl->ls[dim].start = nl->dim[dim].lbound;
|
|
|
|
nl->ls[dim].idx = nl->ls[dim].start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
2005-04-19 00:19:27 +02:00
|
|
|
free_mem (ext_name);
|
2005-04-17 22:09:37 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Resets touched for the entire list of nml_nodes, ready for a
|
|
|
|
new object. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
nml_untouch_nodes (void)
|
|
|
|
{
|
|
|
|
namelist_info * t;
|
|
|
|
for (t = ionml; t; t = t->next)
|
|
|
|
t->touched = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempts to input name to namelist name. Returns nml_read_error = 1
|
|
|
|
on no match. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
static void
|
|
|
|
nml_match_name (char *name, index_type len)
|
|
|
|
{
|
|
|
|
index_type i;
|
|
|
|
char c;
|
|
|
|
nml_read_error = 0;
|
|
|
|
for (i = 0; i < len; i++)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
c = next_char ();
|
2005-04-17 22:09:37 +02:00
|
|
|
if (tolower (c) != tolower (name[i]))
|
|
|
|
{
|
|
|
|
nml_read_error = 1;
|
|
|
|
break;
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* If the namelist read is from stdin, output the current state of the
|
|
|
|
namelist to stdout. This is used to implement the non-standard query
|
|
|
|
features, ? and =?. If c == '=' the full namelist is printed. Otherwise
|
|
|
|
the names alone are printed. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
static void
|
|
|
|
nml_query (char c)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2005-04-17 22:09:37 +02:00
|
|
|
gfc_unit * temp_unit;
|
2004-05-13 08:41:07 +02:00
|
|
|
namelist_info * nl;
|
2005-04-17 22:09:37 +02:00
|
|
|
index_type len;
|
|
|
|
char * p;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
if (current_unit->unit_number != options.stdin_unit)
|
|
|
|
return;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* Store the current unit and transfer to stdout. */
|
|
|
|
|
|
|
|
temp_unit = current_unit;
|
|
|
|
current_unit = find_unit (options.stdout_unit);
|
|
|
|
|
|
|
|
if (current_unit)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2005-04-17 22:09:37 +02:00
|
|
|
g.mode =WRITING;
|
|
|
|
next_record (0);
|
|
|
|
|
|
|
|
/* Write the namelist in its entirety. */
|
|
|
|
|
|
|
|
if (c == '=')
|
|
|
|
namelist_write ();
|
|
|
|
|
|
|
|
/* Or write the list of names. */
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
/* "&namelist_name\n" */
|
|
|
|
|
|
|
|
len = ioparm.namelist_name_len;
|
|
|
|
p = write_block (len + 2);
|
|
|
|
if (!p)
|
|
|
|
goto query_return;
|
|
|
|
memcpy (p, "&", 1);
|
|
|
|
memcpy ((char*)(p + 1), ioparm.namelist_name, len);
|
|
|
|
memcpy ((char*)(p + len + 1), "\n", 1);
|
|
|
|
for (nl =ionml; nl; nl = nl->next)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* " var_name\n" */
|
|
|
|
|
|
|
|
len = strlen (nl->var_name);
|
|
|
|
p = write_block (len + 2);
|
|
|
|
if (!p)
|
|
|
|
goto query_return;
|
|
|
|
memcpy (p, " ", 1);
|
|
|
|
memcpy ((char*)(p + 1), nl->var_name, len);
|
|
|
|
memcpy ((char*)(p + len + 1), "\n", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "&end\n" */
|
|
|
|
|
|
|
|
p = write_block (5);
|
|
|
|
if (!p)
|
|
|
|
goto query_return;
|
|
|
|
memcpy (p, "&end\n", 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Flush the stream to force immediate output. */
|
|
|
|
|
|
|
|
flush (current_unit->s);
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
query_return:
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* Restore the current unit. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
current_unit = temp_unit;
|
|
|
|
g.mode = READING;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reads and stores the input for the namelist object nl. For an array,
|
|
|
|
the function loops over the ranges defined by the loop specification.
|
|
|
|
This default to all the data or to the specification from a qualifier.
|
|
|
|
nml_read_obj recursively calls itself to read derived types. It visits
|
|
|
|
all its own components but only reads data for those that were touched
|
|
|
|
when the name was parsed. If a read error is encountered, an attempt is
|
|
|
|
made to return to read a new object name because the standard allows too
|
|
|
|
little data to be available. On the other hand, too much data is an
|
|
|
|
error. */
|
|
|
|
|
|
|
|
static try
|
|
|
|
nml_read_obj (namelist_info * nl, index_type offset)
|
|
|
|
{
|
|
|
|
|
|
|
|
namelist_info * cmp;
|
|
|
|
char * obj_name;
|
|
|
|
int nml_carry;
|
|
|
|
int len;
|
|
|
|
int dim;
|
|
|
|
index_type dlen;
|
|
|
|
index_type m;
|
|
|
|
index_type obj_name_len;
|
|
|
|
void * pdata ;
|
|
|
|
|
|
|
|
/* This object not touched in name parsing. */
|
|
|
|
|
|
|
|
if (!nl->touched)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
repeat_count = 0;
|
|
|
|
eat_spaces();
|
|
|
|
|
|
|
|
len = nl->len;
|
|
|
|
switch (nl->type)
|
|
|
|
{
|
|
|
|
|
|
|
|
case GFC_DTYPE_INTEGER:
|
|
|
|
case GFC_DTYPE_LOGICAL:
|
|
|
|
case GFC_DTYPE_REAL:
|
|
|
|
dlen = len;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GFC_DTYPE_COMPLEX:
|
|
|
|
dlen = 2* len;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GFC_DTYPE_CHARACTER:
|
|
|
|
dlen = chigh ? (chigh - clow + 1) : nl->string_length;
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-04-17 22:09:37 +02:00
|
|
|
dlen = 0;
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
do
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* Update the pointer to the data, using the current index vector */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
pdata = (void*)(nl->mem_pos + offset);
|
|
|
|
for (dim = 0; dim < nl->var_rank; dim++)
|
|
|
|
pdata = (void*)(pdata + (nl->ls[dim].idx - nl->dim[dim].lbound) *
|
|
|
|
nl->dim[dim].stride * nl->size);
|
2004-09-21 13:22:47 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* Reset the error flag and try to read next value, if
|
|
|
|
repeat_count=0 */
|
|
|
|
|
|
|
|
nml_read_error = 0;
|
|
|
|
nml_carry = 0;
|
|
|
|
if (--repeat_count <= 0)
|
|
|
|
{
|
|
|
|
if (input_complete)
|
|
|
|
return SUCCESS;
|
|
|
|
if (at_eol)
|
|
|
|
finish_separator ();
|
|
|
|
if (input_complete)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
/* GFC_TYPE_UNKNOWN through for nulls and is detected
|
|
|
|
after the switch block. */
|
|
|
|
|
|
|
|
saved_type = GFC_DTYPE_UNKNOWN;
|
|
|
|
free_saved ();
|
2004-09-21 13:22:47 +02:00
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
switch (nl->type)
|
2005-04-17 22:09:37 +02:00
|
|
|
{
|
|
|
|
case GFC_DTYPE_INTEGER:
|
2004-05-13 08:41:07 +02:00
|
|
|
read_integer (len);
|
|
|
|
break;
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
case GFC_DTYPE_LOGICAL:
|
2004-05-13 08:41:07 +02:00
|
|
|
read_logical (len);
|
|
|
|
break;
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
case GFC_DTYPE_CHARACTER:
|
2004-05-13 08:41:07 +02:00
|
|
|
read_character (len);
|
|
|
|
break;
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
case GFC_DTYPE_REAL:
|
2004-05-13 08:41:07 +02:00
|
|
|
read_real (len);
|
|
|
|
break;
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
case GFC_DTYPE_COMPLEX:
|
2004-05-13 08:41:07 +02:00
|
|
|
read_complex (len);
|
|
|
|
break;
|
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
case GFC_DTYPE_DERIVED:
|
|
|
|
obj_name_len = strlen (nl->var_name) + 1;
|
|
|
|
obj_name = get_mem (obj_name_len+1);
|
|
|
|
strcpy (obj_name, nl->var_name);
|
|
|
|
strcat (obj_name, "%");
|
|
|
|
|
|
|
|
/* Now loop over the components. Update the component pointer
|
|
|
|
with the return value from nml_write_obj. This loop jumps
|
|
|
|
past nested derived types by testing if the potential
|
|
|
|
component name contains '%'. */
|
|
|
|
|
|
|
|
for (cmp = nl->next;
|
|
|
|
cmp &&
|
|
|
|
!strncmp (cmp->var_name, obj_name, obj_name_len) &&
|
|
|
|
!strchr (cmp->var_name + obj_name_len, '%');
|
|
|
|
cmp = cmp->next)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (nml_read_obj (cmp, (index_type)(pdata - nl->mem_pos)) == FAILURE)
|
2005-04-19 00:19:27 +02:00
|
|
|
{
|
|
|
|
free_mem (obj_name);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
if (input_complete)
|
2005-04-19 00:19:27 +02:00
|
|
|
{
|
|
|
|
free_mem (obj_name);
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
2005-04-17 22:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
free_mem (obj_name);
|
|
|
|
goto incr_idx;
|
|
|
|
|
|
|
|
default:
|
|
|
|
st_sprintf (nml_err_msg, "Bad type for namelist object %s",
|
|
|
|
nl->var_name );
|
|
|
|
internal_error (nml_err_msg);
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
/* The standard permits array data to stop short of the number of
|
|
|
|
elements specified in the loop specification. In this case, we
|
|
|
|
should be here with nml_read_error != 0. Control returns to
|
|
|
|
nml_get_obj_data and an attempt is made to read object name. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
prev_nl = nl;
|
|
|
|
if (nml_read_error)
|
|
|
|
return SUCCESS;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
if (saved_type == GFC_DTYPE_UNKNOWN)
|
|
|
|
goto incr_idx;
|
|
|
|
|
|
|
|
|
|
|
|
/* Note the switch from GFC_DTYPE_type to BT_type at this point.
|
|
|
|
This comes about because the read functions return BT_types. */
|
|
|
|
|
|
|
|
switch (saved_type)
|
|
|
|
{
|
|
|
|
|
|
|
|
case BT_COMPLEX:
|
|
|
|
case BT_REAL:
|
|
|
|
case BT_INTEGER:
|
|
|
|
case BT_LOGICAL:
|
|
|
|
memcpy (pdata, value, dlen);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BT_CHARACTER:
|
|
|
|
m = (dlen < saved_used) ? dlen : saved_used;
|
|
|
|
pdata = (void*)( pdata + clow - 1 );
|
|
|
|
memcpy (pdata, saved_string, m);
|
|
|
|
if (m < dlen)
|
|
|
|
memset ((void*)( pdata + m ), ' ', dlen - m);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Break out of loop if scalar. */
|
|
|
|
|
|
|
|
if (!nl->var_rank)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Now increment the index vector. */
|
|
|
|
|
|
|
|
incr_idx:
|
|
|
|
|
|
|
|
nml_carry = 1;
|
|
|
|
for (dim = 0; dim < nl->var_rank; dim++)
|
|
|
|
{
|
|
|
|
nl->ls[dim].idx += nml_carry * nl->ls[dim].step;
|
|
|
|
nml_carry = 0;
|
|
|
|
if (((nl->ls[dim].step > 0) && (nl->ls[dim].idx > nl->ls[dim].end))
|
|
|
|
||
|
|
|
|
((nl->ls[dim].step < 0) && (nl->ls[dim].idx < nl->ls[dim].end)))
|
|
|
|
{
|
|
|
|
nl->ls[dim].idx = nl->ls[dim].start;
|
|
|
|
nml_carry = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!nml_carry);
|
|
|
|
|
|
|
|
if (repeat_count > 1)
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "Repeat count too large for namelist object %s" ,
|
|
|
|
nl->var_name );
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
nml_err_ret:
|
|
|
|
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parses the object name, including array and substring qualifiers. It
|
|
|
|
iterates over derived type components, touching those components and
|
|
|
|
setting their loop specifications, if there is a qualifier. If the
|
|
|
|
object is itself a derived type, its components and subcomponents are
|
|
|
|
touched. nml_read_obj is called at the end and this reads the data in
|
|
|
|
the manner specified by the object name. */
|
|
|
|
|
|
|
|
static try
|
|
|
|
nml_get_obj_data (void)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
char * ext_name;
|
|
|
|
namelist_info * nl;
|
|
|
|
namelist_info * first_nl;
|
|
|
|
namelist_info * root_nl;
|
|
|
|
int dim;
|
|
|
|
int component_flag;
|
|
|
|
|
|
|
|
/* Look for end of input or object name. If '?' or '=?' are encountered
|
|
|
|
in stdin, print the node names or the namelist to stdout. */
|
|
|
|
|
|
|
|
eat_separator ();
|
|
|
|
if (input_complete)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
if ( at_eol )
|
|
|
|
finish_separator ();
|
|
|
|
if (input_complete)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '=':
|
|
|
|
c = next_char ();
|
|
|
|
if (c != '?')
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "namelist read: missplaced = sign");
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
nml_query ('=');
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
nml_query ('?');
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
case '$':
|
|
|
|
case '&':
|
|
|
|
nml_match_name ("end", 3);
|
|
|
|
if (nml_read_error)
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "namelist not terminated with / or &end");
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
case '/':
|
|
|
|
input_complete = 1;
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Untouch all nodes of the namelist and reset the flag that is set for
|
|
|
|
derived type components. */
|
|
|
|
|
|
|
|
nml_untouch_nodes();
|
|
|
|
component_flag = 0;
|
|
|
|
|
|
|
|
/* Get the object name - should '!' and '\n' be permitted separators? */
|
|
|
|
|
|
|
|
get_name:
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
push_char(tolower(c));
|
|
|
|
c = next_char ();
|
|
|
|
} while (!( c=='=' || c==' ' || c=='\t' || c =='(' || c =='%' ));
|
|
|
|
|
|
|
|
unget_char (c);
|
|
|
|
|
|
|
|
/* Check that the name is in the namelist and get pointer to object.
|
|
|
|
Three error conditions exist: (i) An attempt is being made to
|
|
|
|
identify a non-existent object, following a failed data read or
|
|
|
|
(ii) The object name does not exist or (iii) Too many data items
|
|
|
|
are present for an object. (iii) gives the same error message
|
|
|
|
as (i) */
|
|
|
|
|
|
|
|
push_char ('\0');
|
|
|
|
|
|
|
|
if (component_flag)
|
|
|
|
{
|
2005-04-23 14:38:08 +02:00
|
|
|
ext_name = (char*)get_mem (strlen (root_nl->var_name)
|
|
|
|
+ (saved_string ? strlen (saved_string) : 0)
|
|
|
|
+ 1);
|
2005-04-17 22:09:37 +02:00
|
|
|
strcpy (ext_name, root_nl->var_name);
|
|
|
|
strcat (ext_name, saved_string);
|
|
|
|
nl = find_nml_node (ext_name);
|
2005-04-19 00:19:27 +02:00
|
|
|
free_mem (ext_name);
|
2005-04-17 22:09:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nl = find_nml_node (saved_string);
|
|
|
|
|
|
|
|
if (nl == NULL)
|
|
|
|
{
|
|
|
|
if (nml_read_error && prev_nl)
|
|
|
|
st_sprintf (nml_err_msg, "Bad data for namelist object %s",
|
|
|
|
prev_nl->var_name);
|
|
|
|
|
|
|
|
else
|
|
|
|
st_sprintf (nml_err_msg, "Cannot match namelist object name %s",
|
|
|
|
saved_string);
|
|
|
|
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the length, data length, base pointer and rank of the variable.
|
|
|
|
Set the default loop specification first. */
|
|
|
|
|
|
|
|
for (dim=0; dim < nl->var_rank; dim++)
|
|
|
|
{
|
|
|
|
nl->ls[dim].step = 1;
|
|
|
|
nl->ls[dim].end = nl->dim[dim].ubound;
|
|
|
|
nl->ls[dim].start = nl->dim[dim].lbound;
|
|
|
|
nl->ls[dim].idx = nl->ls[dim].start;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check to see if there is a qualifier: if so, parse it.*/
|
|
|
|
|
|
|
|
if (c == '(' && nl->var_rank)
|
|
|
|
{
|
|
|
|
if (nml_parse_qualifier (nl->dim, nl->ls, nl->var_rank) == FAILURE)
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "%s for namelist variable %s",
|
|
|
|
parse_err_msg, nl->var_name);
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
c = next_char ();
|
|
|
|
unget_char (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now parse a derived type component. The root namelist_info address
|
|
|
|
is backed up, as is the previous component level. The component flag
|
|
|
|
is set and the iteration is made by jumping back to get_name. */
|
|
|
|
|
|
|
|
if (c == '%')
|
|
|
|
{
|
|
|
|
|
|
|
|
if (nl->type != GFC_DTYPE_DERIVED)
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "Attempt to get derived component for %s",
|
|
|
|
nl->var_name);
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!component_flag)
|
|
|
|
first_nl = nl;
|
|
|
|
|
|
|
|
root_nl = nl;
|
|
|
|
component_flag = 1;
|
|
|
|
c = next_char ();
|
|
|
|
goto get_name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse a character qualifier, if present. chigh = 0 is a default
|
|
|
|
that signals that the string length = string_length. */
|
|
|
|
|
|
|
|
clow = 1;
|
|
|
|
chigh = 0;
|
|
|
|
|
|
|
|
if (c == '(' && nl->type == GFC_DTYPE_CHARACTER)
|
|
|
|
{
|
|
|
|
descriptor_dimension chd[1] = {1, clow, nl->string_length};
|
|
|
|
nml_loop_spec ind[1] = {1, clow, nl->string_length, 1};
|
|
|
|
|
|
|
|
if (nml_parse_qualifier (chd, ind, 1) == FAILURE)
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "%s for namelist variable %s",
|
|
|
|
parse_err_msg, nl->var_name);
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
clow = ind[0].start;
|
|
|
|
chigh = ind[0].end;
|
|
|
|
|
|
|
|
if (ind[0].step != 1)
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg,
|
|
|
|
"Bad step in substring for namelist object %s",
|
|
|
|
nl->var_name);
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
unget_char (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If a derived type touch its components and restore the root
|
|
|
|
namelist_info if we have parsed a qualified derived type
|
|
|
|
component. */
|
|
|
|
|
|
|
|
if (nl->type == GFC_DTYPE_DERIVED)
|
|
|
|
nml_touch_nodes (nl);
|
|
|
|
if (component_flag)
|
|
|
|
nl = first_nl;
|
|
|
|
|
|
|
|
/*make sure no extraneous qualifiers are there.*/
|
|
|
|
|
|
|
|
if (c == '(')
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "Qualifier for a scalar or non-character"
|
|
|
|
" namelist object %s", nl->var_name);
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* According to the standard, an equal sign MUST follow an object name. The
|
|
|
|
following is possibly lax - it allows comments, blank lines and so on to
|
|
|
|
intervene. eat_spaces (); c = next_char (); would be compliant*/
|
|
|
|
|
|
|
|
free_saved ();
|
|
|
|
|
|
|
|
eat_separator ();
|
|
|
|
if (input_complete)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
if (at_eol)
|
|
|
|
finish_separator ();
|
|
|
|
if (input_complete)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
c = next_char ();
|
|
|
|
|
|
|
|
if (c != '=')
|
|
|
|
{
|
|
|
|
st_sprintf (nml_err_msg, "Equal sign must follow namelist object name %s",
|
|
|
|
nl->var_name);
|
|
|
|
goto nml_err_ret;
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-04-17 22:09:37 +02:00
|
|
|
if (nml_read_obj (nl, 0) == FAILURE)
|
|
|
|
goto nml_err_ret;
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
nml_err_ret:
|
|
|
|
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Entry point for namelist input. Goes through input until namelist name
|
|
|
|
is matched. Then cycles through nml_get_obj_data until the input is
|
|
|
|
completed or there is an error. */
|
|
|
|
|
|
|
|
void
|
|
|
|
namelist_read (void)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
|
|
|
|
namelist_mode = 1;
|
|
|
|
input_complete = 0;
|
|
|
|
|
|
|
|
if (setjmp (g.eof_jump))
|
|
|
|
{
|
|
|
|
generate_error (ERROR_END, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for &namelist_name . Skip all characters, testing for $nmlname.
|
|
|
|
Exit on success or EOF. If '?' or '=?' encountered in stdin, print
|
|
|
|
node names or namelist on stdout. */
|
|
|
|
|
|
|
|
find_nml_name:
|
|
|
|
switch (c = next_char ())
|
|
|
|
{
|
|
|
|
case '$':
|
|
|
|
case '&':
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
case '=':
|
|
|
|
c = next_char ();
|
|
|
|
if (c == '?')
|
|
|
|
nml_query ('=');
|
|
|
|
else
|
|
|
|
unget_char (c);
|
|
|
|
goto find_nml_name;
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
nml_query ('?');
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto find_nml_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Match the name of the namelist. */
|
|
|
|
|
|
|
|
nml_match_name (ioparm.namelist_name, ioparm.namelist_name_len);
|
|
|
|
|
|
|
|
if (nml_read_error)
|
|
|
|
goto find_nml_name;
|
|
|
|
|
|
|
|
/* Ready to read namelist objects. If there is an error in input
|
|
|
|
from stdin, output the error message and continue. */
|
|
|
|
|
|
|
|
while (!input_complete)
|
|
|
|
{
|
|
|
|
if (nml_get_obj_data () == FAILURE)
|
|
|
|
{
|
|
|
|
if (current_unit->unit_number != options.stdin_unit)
|
|
|
|
goto nml_err_ret;
|
|
|
|
|
|
|
|
st_printf ("%s\n", nml_err_msg);
|
|
|
|
flush (find_unit (options.stderr_unit)->s);
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
2005-04-17 22:09:37 +02:00
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
2005-04-17 22:09:37 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* All namelist error calls return from here */
|
|
|
|
|
|
|
|
nml_err_ret:
|
|
|
|
|
|
|
|
generate_error (ERROR_READ_VALUE , nml_err_msg);
|
|
|
|
return;
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|