Commit 485adf79 by Francois-Xavier Coudert Committed by François-Xavier Coudert

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
parent 35401640
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.
......
...@@ -793,9 +793,6 @@ internal_proto(xrealloc); ...@@ -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);
......
...@@ -33,32 +33,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -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) ...@@ -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. */
char buffer[80];
int i;
if (n <= 0)
return;
for (i = 0; i < n; i++)
buffer[i] = ' ';
buffer[i] = '\0';
estr_write (buffer);
}
options_t options;
/* var_source()-- Return a string that describes where the value of a typedef struct variable
* variable comes from */
static const char *
var_source (variable * v)
{ {
if (getenv (v->name) == NULL) const char *name;
return "Default"; int default_value;
int *var;
if (v->bad) void (*init) (struct variable *);
return "Bad ";
return "Set ";
} }
variable;
static void init_unformatted (variable *);
/* init_integer()-- Initialize an integer environment variable. */ /* 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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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: ...@@ -257,92 +170,51 @@ set_default:
} }
static void static variable variable_table[] = {
show_sep (variable * v)
{
st_printf ("%s \"%s\"\n", var_source (v), options.separator);
}
/* Unit number that will be preconnected to standard input */
{ "GFORTRAN_STDIN_UNIT", GFC_STDIN_UNIT_NUMBER, &options.stdin_unit,
init_integer },
static void /* Unit number that will be preconnected to standard output */
init_string (variable * v __attribute__ ((unused))) { "GFORTRAN_STDOUT_UNIT", GFC_STDOUT_UNIT_NUMBER, &options.stdout_unit,
{ init_integer },
}
static void /* Unit number that will be preconnected to standard error */
show_string (variable * v) { "GFORTRAN_STDERR_UNIT", GFC_STDERR_UNIT_NUMBER, &options.stderr_unit,
{ init_integer },
const char *p;
p = getenv (v->name); /* If TRUE, all output will be unbuffered */
if (p == NULL) { "GFORTRAN_UNBUFFERED_ALL", 0, &options.all_unbuffered, init_boolean },
p = "";
estr_write (var_source (v)); /* If TRUE, output to preconnected units will be unbuffered */
estr_write (" \""); { "GFORTRAN_UNBUFFERED_PRECONNECTED", 0, &options.unbuffered_preconnected,
estr_write (p); init_boolean },
estr_write ("\"\n");
}
/* Whether to print filename and line number on runtime error */
{ "GFORTRAN_SHOW_LOCUS", 1, &options.locus, init_boolean },
static variable variable_table[] = { /* Print optional plus signs in numbers where permitted */
{"GFORTRAN_STDIN_UNIT", GFC_STDIN_UNIT_NUMBER, &options.stdin_unit, { "GFORTRAN_OPTIONAL_PLUS", 0, &options.optional_plus, init_boolean },
init_integer, show_integer,
"Unit number that will be preconnected to standard input\n" /* Default maximum record length for sequential files */
"(No preconnection if negative)", 0}, { "GFORTRAN_DEFAULT_RECL", DEFAULT_RECL, &options.default_recl,
init_unsigned_integer },
{"GFORTRAN_STDOUT_UNIT", GFC_STDOUT_UNIT_NUMBER, &options.stdout_unit,
init_integer, show_integer, /* Separator to use when writing list output */
"Unit number that will be preconnected to standard output\n" { "GFORTRAN_LIST_SEPARATOR", 0, NULL, init_sep },
"(No preconnection if negative)", 0},
/* Set the default data conversion for unformatted I/O */
{"GFORTRAN_STDERR_UNIT", GFC_STDERR_UNIT_NUMBER, &options.stderr_unit, { "GFORTRAN_CONVERT_UNIT", 0, 0, init_unformatted },
init_integer, show_integer,
"Unit number that will be preconnected to standard error\n" /* Print out a backtrace if possible on runtime error */
"(No preconnection if negative)", 0}, { "GFORTRAN_ERROR_BACKTRACE", -1, &options.backtrace, init_boolean },
{"TMPDIR", 0, NULL, init_string, show_string, { NULL, 0, NULL, NULL }
"Directory for scratch files.", 0},
{"GFORTRAN_UNBUFFERED_ALL", 0, &options.all_unbuffered, init_boolean,
show_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,
init_boolean, show_boolean,
"If TRUE, output to preconnected units is unbuffered.", 0},
{"GFORTRAN_SHOW_LOCUS", 1, &options.locus, init_boolean, show_boolean,
"If TRUE, print filename and line number where runtime errors happen.", 0},
{"GFORTRAN_OPTIONAL_PLUS", 0, &options.optional_plus, init_boolean, show_boolean,
"Print optional plus signs in numbers where permitted. Default FALSE.", 0},
{"GFORTRAN_DEFAULT_RECL", DEFAULT_RECL, &options.default_recl,
init_unsigned_integer, show_integer,
"Default maximum record length for sequential files. Most useful for\n"
"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. May contain any number of "
"spaces\nand at most one comma. Default is a single space.", 0},
/* GFORTRAN_CONVERT_UNIT - Set the default data conversion for
unformatted I/O. */
{"GFORTRAN_CONVERT_UNIT", 0, 0, init_unformatted, show_string,
"Set format for unformatted files", 0},
{"GFORTRAN_ERROR_BACKTRACE", -1, &options.backtrace,
init_boolean, show_boolean,
"Print out a backtrace (if possible) on runtime error", -1},
{NULL, 0, NULL, NULL, NULL, NULL, 0}
}; };
/* init_variables()-- Initialize most runtime variables from /* Initialize most runtime variables from
* environment variables. */ * environment variables. */
void void
...@@ -351,57 +223,14 @@ init_variables (void) ...@@ -351,57 +223,14 @@ init_variables (void)
variable *v; variable *v;
for (v = variable_table; v->name; 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++)
{ {
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) ...@@ -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) ...@@ -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.
......
...@@ -120,15 +120,6 @@ init (void) ...@@ -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);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment