-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of the GNU Fortran 95 runtime library (libgfortran).
the Free Software Foundation; either version 2, or (at your option)
any later version.
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file. (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
Libgfortran is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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. */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
/* format.c-- parse a FORMAT string into a binary format suitable for
static format_token saved_token;
static int value, format_string_len, reversion_ok;
-static fnode *saved_format, colon_node = { FMT_COLON };
+static fnode *saved_format;
+static fnode colon_node = { FMT_COLON, 0, NULL, NULL, {{ 0, 0, 0 }}, 0,
+ NULL };
/* Error messages */
-static char posint_required[] = "Positive width required in format",
+static const char posint_required[] = "Positive width required in format",
period_required[] = "Period required in format",
nonneg_required[] = "Nonnegative width required in format",
unexpected_element[] = "Unexpected element in format",
void
free_fnodes (void)
{
-
if (avail - array >= FARRAY_SIZE)
free_fnode (&array[0]);
{
format_token token;
int negative_flag;
- char c, delim;
+ int c;
+ char delim;
if (saved_token != FMT_NONE)
{
head = tail = NULL;
-/* Get the next format item */
-
-format_item:
+ /* Get the next format item */
+ format_item:
t = format_lex ();
+ format_item_1:
switch (t)
{
case FMT_POSINT:
p_descriptor:
get_fnode (&head, &tail, FMT_P);
tail->u.k = value;
+ tail->repeat = 1;
t = format_lex ();
if (t == FMT_F || t == FMT_EN || t == FMT_ES || t == FMT_D
tail->u.string.p = string;
tail->u.string.length = value;
tail->repeat = 1;
- goto between_desc;
+ goto optional_comma;
case FMT_S:
case FMT_SS:
case FMT_BN:
case FMT_BZ:
get_fnode (&head, &tail, t);
+ tail->repeat = 1;
goto between_desc;
case FMT_COLON:
get_fnode (&head, &tail, FMT_COLON);
+ tail->repeat = 1;
goto optional_comma;
case FMT_SLASH:
case FMT_DOLLAR:
get_fnode (&head, &tail, FMT_DOLLAR);
+ tail->repeat = 1;
+ notify_std (GFC_STD_GNU, "Extension: $ descriptor");
goto between_desc;
case FMT_T:
goto finished;
}
-/* In this state, t must currently be a data descriptor. Deal with
- * things that can/must follow the descriptor */
-
-data_desc:
+ /* In this state, t must currently be a data descriptor. Deal with
+ things that can/must follow the descriptor */
+ data_desc:
switch (t)
{
case FMT_P:
tail->u.real.e = -1;
-/* Look for optional exponent */
-
+ /* Look for optional exponent */
t = format_lex ();
if (t != FMT_E)
saved_token = t;
goto finished;
}
-/* Between a descriptor and what comes next */
-between_desc:
+ /* Between a descriptor and what comes next */
+ between_desc:
t = format_lex ();
switch (t)
{
goto finished;
default:
- error = "Missing comma in format";
- goto finished;
+ /* Assume a missing comma, this is a GNU extension */
+ goto format_item_1;
}
-/* Optional comma is a weird between state where we've just finished
- * reading a colon, slash or P descriptor. */
-
-optional_comma:
+ /* Optional comma is a weird between state where we've just finished
+ reading a colon, slash or P descriptor. */
+ optional_comma:
t = format_lex ();
switch (t)
{
goto format_item;
-finished:
+ finished:
return head;
}
void
parse_format (void)
{
-
format_string = ioparm.format;
format_string_len = ioparm.format_len;
saved_token = FMT_NONE;
error = NULL;
-/* Initialize variables used during traversal of the tree */
+ /* Initialize variables used during traversal of the tree */
reversion_ok = 0;
g.reversion_flag = 0;
saved_format = NULL;
-/* Allocate the first format node as the root of the tree */
+ /* Allocate the first format node as the root of the tree */
avail = array;
}
/* If this is a data edit descriptor, then reversion has become OK. */
-
-done:
+ done:
t = f->format;
if (!reversion_ok &&
void
unget_format (fnode * f)
{
-
saved_format = f;
}
static void
dump_format1 (fnode * f)
{
-
for (; f; f = f->next)
dump_format1 (f);
}
void
dump_format (void)
{
-
st_printf ("format = ");
dump_format0 (&array[0]);
st_printf ("\n");