diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-10 10:37:59 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-10 10:37:59 +0000 |
commit | 985c2efe3b6b099d001a115980eaf0d22e91a890 (patch) | |
tree | 373a5bce8f5033bab314b344e1726a3f26fd6a88 /libgfortran | |
parent | defc80168592ecb030888c160c71320514b2cbf0 (diff) | |
download | gcc-985c2efe3b6b099d001a115980eaf0d22e91a890.tar.gz |
PR libfortran/20788
* runtime/environ.c (init_unsigned_integer): Function for
environment variables we want to be positive.
(init_integer): Function to allow negative environment
variables (e.g. for GFORTRAN_STDIN_UNIT).
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97946 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 8 | ||||
-rw-r--r-- | libgfortran/runtime/environ.c | 32 |
2 files changed, 38 insertions, 2 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 118375417b2..ca2120d26f5 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,11 @@ +2005-04-10 Francois-Xavier Coudert <coudert@clipper.ens.fr> + + PR libfortran/20788 + * runtime/environ.c (init_unsigned_integer): Function for + environment variables we want to be positive. + (init_integer): Function to allow negative environment + variables (e.g. for GFORTRAN_STDIN_UNIT). + 2005-04-10 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/17992 diff --git a/libgfortran/runtime/environ.c b/libgfortran/runtime/environ.c index 8d608aefaf5..c1a71cf6eef 100644 --- a/libgfortran/runtime/environ.c +++ b/libgfortran/runtime/environ.c @@ -97,7 +97,7 @@ var_source (variable * v) } -/* init_integer()-- Initialize an integer environment variable */ +/* init_integer()-- Initialize an integer environment variable. */ static void init_integer (variable * v) @@ -109,6 +109,34 @@ init_integer (variable * v) goto set_default; for (q = p; *q; q++) + if (!isdigit (*q) && (p != q || *q != '-')) + { + v->bad = 1; + goto set_default; + } + + *v->var = atoi (p); + return; + + set_default: + *v->var = v->value; + return; +} + + +/* init_unsigned_integer()-- Initialize an integer environment variable + which has to be positive. */ + +static void +init_unsigned_integer (variable * v) +{ + char *p, *q; + + p = getenv (v->name); + if (p == NULL) + goto set_default; + + for (q = p; *q; q++) if (!isdigit (*q)) { v->bad = 1; @@ -467,7 +495,7 @@ static variable variable_table[] = { "Print optional plus signs in numbers where permitted. Default FALSE."}, {"GFORTRAN_DEFAULT_RECL", DEFAULT_RECL, &options.default_recl, - init_integer, show_integer, + init_integer, show_unsigned_integer, "Default maximum record length for sequential files. Most useful for\n" "adjusting line length of preconnected units. Default " stringize (DEFAULT_RECL)}, |