This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gfortran, patch for PR 20788


Here is what I committed to mainline:

Index: runtime/environ.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/runtime/environ.c,v
retrieving revision 1.9
diff -p -u -r1.9 environ.c
--- runtime/environ.c   27 Feb 2005 20:59:02 -0000      1.9
+++ runtime/environ.c   10 Apr 2005 10:37:12 -0000
@@ -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)},



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]