libgfortran.h (show_variables): Remove prototype.

* libgfortran.h (show_variables): Remove prototype.
	* runtime/environ.c (print_spaces, var_source, show_integer,
	show_boolean, show_sep, show_string): Remove functions.
	* runtime/main.c (init): Remove dead code.

From-SVN: r227208
This commit is contained in:
Francois-Xavier Coudert 2015-08-26 06:34:05 +00:00 committed by François-Xavier Coudert
parent 3540164033
commit 485adf79b5
4 changed files with 71 additions and 249 deletions

View File

@ -1,3 +1,10 @@
2015-08-26 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* libgfortran.h (show_variables): Remove prototype.
* runtime/environ.c (print_spaces, var_source, show_integer,
show_boolean, show_sep, show_string): Remove functions.
* runtime/main.c (init): Remove dead code.
2015-08-25 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 2015-08-25 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* io/unit.c (get_internal_unit): Make default sign mode unspecified. * io/unit.c (get_internal_unit): Make default sign mode unspecified.

View File

@ -793,9 +793,6 @@ internal_proto(xrealloc);
extern void init_variables (void); extern void init_variables (void);
internal_proto(init_variables); internal_proto(init_variables);
extern void show_variables (void);
internal_proto(show_variables);
unit_convert get_unformatted_convert (int); unit_convert get_unformatted_convert (int);
internal_proto(get_unformatted_convert); internal_proto(get_unformatted_convert);

View File

@ -33,32 +33,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#endif #endif
/* Environment scanner. Examine the environment for controlling minor /* Implementation of secure_getenv() for targets where it is not
* aspects of the program's execution. Our philosophy here that the provided. */
* environment should not prevent the program from running, so an
* environment variable with a messed-up value will be interpreted in
* the default way.
*
* Most of the environment is checked early in the startup sequence,
* but other variables are checked during execution of the user's
* program. */
options_t options;
typedef struct variable
{
const char *name;
int value, *var;
void (*init) (struct variable *);
void (*show) (struct variable *);
const char *desc;
int bad;
}
variable;
static void init_unformatted (variable *);
#ifdef FALLBACK_SECURE_GETENV #ifdef FALLBACK_SECURE_GETENV
char * char *
@ -72,43 +48,27 @@ secure_getenv (const char *name)
#endif #endif
/* print_spaces()-- Print a particular number of spaces. */
static void /* Examine the environment for controlling aspects of the program's
print_spaces (int n) execution. Our philosophy here that the environment should not prevent
the program from running, so any invalid value will be ignored. */
options_t options;
typedef struct variable
{ {
char buffer[80]; const char *name;
int i; int default_value;
int *var;
if (n <= 0) void (*init) (struct variable *);
return;
for (i = 0; i < n; i++)
buffer[i] = ' ';
buffer[i] = '\0';
estr_write (buffer);
} }
variable;
static void init_unformatted (variable *);
/* var_source()-- Return a string that describes where the value of a /* Initialize an integer environment variable. */
* variable comes from */
static const char *
var_source (variable * v)
{
if (getenv (v->name) == NULL)
return "Default";
if (v->bad)
return "Bad ";
return "Set ";
}
/* init_integer()-- Initialize an integer environment variable. */
static void static void
init_integer (variable * v) init_integer (variable * v)
@ -117,26 +77,17 @@ init_integer (variable * v)
p = getenv (v->name); p = getenv (v->name);
if (p == NULL) if (p == NULL)
goto set_default; return;
for (q = p; *q; q++) for (q = p; *q; q++)
if (!isdigit (*q) && (p != q || *q != '-')) if (!isdigit (*q) && (p != q || *q != '-'))
{ return;
v->bad = 1;
goto set_default;
}
*v->var = atoi (p); *v->var = atoi (p);
return;
set_default:
*v->var = v->value;
return;
} }
/* init_unsigned_integer()-- Initialize an integer environment variable /* Initialize an integer environment variable which has to be positive. */
which has to be positive. */
static void static void
init_unsigned_integer (variable * v) init_unsigned_integer (variable * v)
@ -145,35 +96,18 @@ init_unsigned_integer (variable * v)
p = getenv (v->name); p = getenv (v->name);
if (p == NULL) if (p == NULL)
goto set_default; return;
for (q = p; *q; q++) for (q = p; *q; q++)
if (!isdigit (*q)) if (!isdigit (*q))
{ return;
v->bad = 1;
goto set_default;
}
*v->var = atoi (p); *v->var = atoi (p);
return;
set_default:
*v->var = v->value;
return;
} }
/* show_integer()-- Show an integer environment variable */ /* Initialize a boolean environment variable. We only look at the first
letter of the value. */
static void
show_integer (variable * v)
{
st_printf ("%s %d\n", var_source (v), *v->var);
}
/* init_boolean()-- Initialize a boolean environment variable. We
* only look at the first letter of the variable. */
static void static void
init_boolean (variable * v) init_boolean (variable * v)
@ -182,36 +116,17 @@ init_boolean (variable * v)
p = getenv (v->name); p = getenv (v->name);
if (p == NULL) if (p == NULL)
goto set_default; return;
if (*p == '1' || *p == 'Y' || *p == 'y') if (*p == '1' || *p == 'Y' || *p == 'y')
{ *v->var = 1;
*v->var = 1; else if (*p == '0' || *p == 'N' || *p == 'n')
return; *v->var = 0;
}
if (*p == '0' || *p == 'N' || *p == 'n')
{
*v->var = 0;
return;
}
v->bad = 1;
set_default:
*v->var = v->value;
return;
} }
/* show_boolean()-- Show a boolean environment variable */ /* Initialize a list output separator. It may contain any number of spaces
and at most one comma. */
static void
show_boolean (variable * v)
{
st_printf ("%s %s\n", var_source (v), *v->var ? "Yes" : "No");
}
static void static void
init_sep (variable * v) init_sep (variable * v)
@ -223,7 +138,6 @@ init_sep (variable * v)
if (p == NULL) if (p == NULL)
goto set_default; goto set_default;
v->bad = 1;
options.separator = p; options.separator = p;
options.separator_len = strlen (p); options.separator_len = strlen (p);
@ -248,7 +162,6 @@ init_sep (variable * v)
goto set_default; goto set_default;
} }
v->bad = 0;
return; return;
set_default: set_default:
@ -257,92 +170,51 @@ set_default:
} }
static void
show_sep (variable * v)
{
st_printf ("%s \"%s\"\n", var_source (v), options.separator);
}
static void
init_string (variable * v __attribute__ ((unused)))
{
}
static void
show_string (variable * v)
{
const char *p;
p = getenv (v->name);
if (p == NULL)
p = "";
estr_write (var_source (v));
estr_write (" \"");
estr_write (p);
estr_write ("\"\n");
}
static variable variable_table[] = { static variable variable_table[] = {
{"GFORTRAN_STDIN_UNIT", GFC_STDIN_UNIT_NUMBER, &options.stdin_unit,
init_integer, show_integer,
"Unit number that will be preconnected to standard input\n"
"(No preconnection if negative)", 0},
{"GFORTRAN_STDOUT_UNIT", GFC_STDOUT_UNIT_NUMBER, &options.stdout_unit, /* Unit number that will be preconnected to standard input */
init_integer, show_integer, { "GFORTRAN_STDIN_UNIT", GFC_STDIN_UNIT_NUMBER, &options.stdin_unit,
"Unit number that will be preconnected to standard output\n" init_integer },
"(No preconnection if negative)", 0},
{"GFORTRAN_STDERR_UNIT", GFC_STDERR_UNIT_NUMBER, &options.stderr_unit, /* Unit number that will be preconnected to standard output */
init_integer, show_integer, { "GFORTRAN_STDOUT_UNIT", GFC_STDOUT_UNIT_NUMBER, &options.stdout_unit,
"Unit number that will be preconnected to standard error\n" init_integer },
"(No preconnection if negative)", 0},
{"TMPDIR", 0, NULL, init_string, show_string, /* Unit number that will be preconnected to standard error */
"Directory for scratch files.", 0}, { "GFORTRAN_STDERR_UNIT", GFC_STDERR_UNIT_NUMBER, &options.stderr_unit,
init_integer },
{"GFORTRAN_UNBUFFERED_ALL", 0, &options.all_unbuffered, init_boolean, /* If TRUE, all output will be unbuffered */
show_boolean, { "GFORTRAN_UNBUFFERED_ALL", 0, &options.all_unbuffered, init_boolean },
"If TRUE, all output is unbuffered. This will slow down large writes "
"but can be\nuseful for forcing data to be displayed immediately.", 0},
{"GFORTRAN_UNBUFFERED_PRECONNECTED", 0, &options.unbuffered_preconnected, /* If TRUE, output to preconnected units will be unbuffered */
init_boolean, show_boolean, { "GFORTRAN_UNBUFFERED_PRECONNECTED", 0, &options.unbuffered_preconnected,
"If TRUE, output to preconnected units is unbuffered.", 0}, init_boolean },
{"GFORTRAN_SHOW_LOCUS", 1, &options.locus, init_boolean, show_boolean, /* Whether to print filename and line number on runtime error */
"If TRUE, print filename and line number where runtime errors happen.", 0}, { "GFORTRAN_SHOW_LOCUS", 1, &options.locus, init_boolean },
{"GFORTRAN_OPTIONAL_PLUS", 0, &options.optional_plus, init_boolean, show_boolean, /* Print optional plus signs in numbers where permitted */
"Print optional plus signs in numbers where permitted. Default FALSE.", 0}, { "GFORTRAN_OPTIONAL_PLUS", 0, &options.optional_plus, init_boolean },
{"GFORTRAN_DEFAULT_RECL", DEFAULT_RECL, &options.default_recl, /* Default maximum record length for sequential files */
init_unsigned_integer, show_integer, { "GFORTRAN_DEFAULT_RECL", DEFAULT_RECL, &options.default_recl,
"Default maximum record length for sequential files. Most useful for\n" init_unsigned_integer },
"adjusting line length of preconnected units. Default "
stringize (DEFAULT_RECL), 0},
{"GFORTRAN_LIST_SEPARATOR", 0, NULL, init_sep, show_sep, /* Separator to use when writing list output */
"Separator to use when writing list output. May contain any number of " { "GFORTRAN_LIST_SEPARATOR", 0, NULL, init_sep },
"spaces\nand at most one comma. Default is a single space.", 0},
/* GFORTRAN_CONVERT_UNIT - Set the default data conversion for /* Set the default data conversion for unformatted I/O */
unformatted I/O. */ { "GFORTRAN_CONVERT_UNIT", 0, 0, init_unformatted },
{"GFORTRAN_CONVERT_UNIT", 0, 0, init_unformatted, show_string,
"Set format for unformatted files", 0},
{"GFORTRAN_ERROR_BACKTRACE", -1, &options.backtrace, /* Print out a backtrace if possible on runtime error */
init_boolean, show_boolean, { "GFORTRAN_ERROR_BACKTRACE", -1, &options.backtrace, init_boolean },
"Print out a backtrace (if possible) on runtime error", -1},
{NULL, 0, NULL, NULL, NULL, NULL, 0} { NULL, 0, NULL, NULL }
}; };
/* init_variables()-- Initialize most runtime variables from /* Initialize most runtime variables from
* environment variables. */ * environment variables. */
void void
@ -350,58 +222,15 @@ init_variables (void)
{ {
variable *v; variable *v;
for (v = variable_table; v->name; v++)
v->init (v);
}
void
show_variables (void)
{
variable *v;
int n;
/* TODO: print version number. */
estr_write ("GNU Fortran runtime library version "
"UNKNOWN" "\n\n");
estr_write ("Environment variables:\n");
estr_write ("----------------------\n");
for (v = variable_table; v->name; v++) for (v = variable_table; v->name; v++)
{ {
n = estr_write (v->name); if (v->var)
print_spaces (25 - n); *v->var = v->default_value;
v->init (v);
if (v->show == show_integer)
estr_write ("Integer ");
else if (v->show == show_boolean)
estr_write ("Boolean ");
else
estr_write ("String ");
v->show (v);
estr_write (v->desc);
estr_write ("\n\n");
} }
/* System error codes */
estr_write ("\nRuntime error codes:");
estr_write ("\n--------------------\n");
for (n = LIBERROR_FIRST + 1; n < LIBERROR_LAST; n++)
if (n < 0 || n > 9)
st_printf ("%d %s\n", n, translate_error (n));
else
st_printf (" %d %s\n", n, translate_error (n));
estr_write ("\nCommand line arguments:\n");
estr_write (" --help Print this list\n");
exit (0);
} }
/* This is the handling of the GFORTRAN_CONVERT_UNITS environment variable. /* This is the handling of the GFORTRAN_CONVERT_UNITS environment variable.
It is called from environ.c to parse this variable, and from It is called from environ.c to parse this variable, and from
open.c to determine if the user specified a default for an open.c to determine if the user specified a default for an
@ -509,7 +338,6 @@ match_word (const char *word, int tok)
else else
res = ILLEGAL; res = ILLEGAL;
return res; return res;
} }
/* Match an integer and store its value in unit_num. This only works /* Match an integer and store its value in unit_num. This only works
@ -523,7 +351,6 @@ match_integer (void)
while (isdigit (*p)) while (isdigit (*p))
unit_num = unit_num * 10 + (*p++ - '0'); unit_num = unit_num * 10 + (*p++ - '0');
return INTEGER; return INTEGER;
} }
/* This reads the next token from the GFORTRAN_CONVERT_UNITS variable. /* This reads the next token from the GFORTRAN_CONVERT_UNITS variable.

View File

@ -120,15 +120,6 @@ init (void)
init_compile_options (); init_compile_options ();
#ifdef DEBUG
/* Check for special command lines. */
if (argc > 1 && strcmp (argv[1], "--help") == 0)
show_variables ();
/* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume(); */
#endif
random_seed_i4 (NULL, NULL, NULL); random_seed_i4 (NULL, NULL, NULL);
} }