OSDN Git Service

* io/list_read.c (nml_parse_qualifier): Use memcpy to extract
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Nov 2005 22:15:20 +0000 (22:15 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Nov 2005 22:15:20 +0000 (22:15 +0000)
        values from dtp->u.p.value.
        * io/io.h (struct st_parameter_dt): Change reversion_flag, first_item,
        seen_dollar, sf_seen_eor, eor_condition, no_leading_blank, char_flag,
        input_complete, at_eol, comma_flag, namelist_mode, nml_read_error to
        single-bit fields.  Move value to where it'll be at least pointer
        aligned.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107520 138bc75d-0d04-0410-961f-82ee72b054a4

libgfortran/ChangeLog
libgfortran/io/io.h
libgfortran/io/list_read.c

index c777d34..a637ee4 100644 (file)
@@ -1,3 +1,13 @@
+2005-11-25  Richard Henderson  <rth@redhat.com>
+
+       * io/list_read.c (nml_parse_qualifier): Use memcpy to extract
+       values from dtp->u.p.value.
+       * io/io.h (struct st_parameter_dt): Change reversion_flag, first_item,
+       seen_dollar, sf_seen_eor, eor_condition, no_leading_blank, char_flag,
+       input_complete, at_eol, comma_flag, namelist_mode, nml_read_error to
+       single-bit fields.  Move value to where it'll be at least pointer
+       aligned.
+
 2005-11-23  Alan Modra  <amodra@bigpond.net.au>
 
        * io/open.c (new_unit): Use the right unit number when checking
index 967a3a2..e0b251a 100644 (file)
@@ -380,30 +380,30 @@ typedef struct st_parameter_dt
          /* Number of spaces to be done for T and X-editing.  */
          int pending_spaces;
          unit_advance advance_status;
-         char reversion_flag; /* Format reversion has occurred.  */
-         char first_item;
-         char seen_dollar;
-         char sf_seen_eor;
-         char eor_condition;
-         char no_leading_blank;
-         char nml_delim;
-         char char_flag;
-         char input_complete;
-         char at_eol;
-         char comma_flag;
-         char last_char;
+
+         unsigned reversion_flag : 1; /* Format reversion has occurred.  */
+         unsigned first_item : 1;
+         unsigned seen_dollar : 1;
+         unsigned sf_seen_eor : 1;
+         unsigned eor_condition : 1;
+         unsigned no_leading_blank : 1;
+         unsigned char_flag : 1;
+         unsigned input_complete : 1;
+         unsigned at_eol : 1;
+         unsigned comma_flag : 1;
          /* A namelist specific flag used in the list directed library
             to flag that calls are being made from namelist read (eg. to
             ignore comments or to treat '/' as a terminator)  */
-         char namelist_mode;
+         unsigned namelist_mode : 1;
          /* A namelist specific flag used in the list directed library
             to flag read errors and return, so that an attempt can be
             made to read a new object name.  */
-         char nml_read_error;
-         /* Storage area for values except for strings.  Must be large
-            enough to hold a complex value (two reals) of the largest
-            kind.  */
-         char value[32];
+         unsigned nml_read_error : 1;
+         /* 20 unused bits.  */
+
+         char last_char;
+         char nml_delim;
+
          int repeat_count;
          int saved_length;
          int saved_used;
@@ -414,6 +414,11 @@ typedef struct st_parameter_dt
          struct format_data *fmt;
          jmp_buf *eof_jump;
          namelist_info *ionml;
+
+         /* Storage area for values except for strings.  Must be large
+            enough to hold a complex value (two reals) of the largest
+            kind.  */
+         char value[32];
        } p;
       char pad[16 * sizeof (char *) + 32 * sizeof (int)];
     } u;
index 75f2b65..1eb38d2 100644 (file)
@@ -1489,8 +1489,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
          eat_spaces (dtp);
          neg = 0;
 
-         /*process a potential sign.  */
-
+         /* Process a potential sign.  */
          c = next_char (dtp);
          switch (c)
            {
@@ -1506,8 +1505,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
              break;
            }
 
-         /*process characters up to the next ':' , ',' or ')'  */
-
+         /* Process characters up to the next ':' , ',' or ')'.  */
          for (;;)
            {
              c = next_char (dtp);
@@ -1518,8 +1516,8 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
                  break;
 
                case ',': case ')':
-                 if ( (c==',' && dim == rank -1)
-                   || (c==')' && dim  < rank -1))
+                 if ((c==',' && dim == rank -1)
+                     || (c==')' && dim < rank -1))
                    {
                      st_sprintf (parse_err_msg,
                                  "Bad number of index fields");
@@ -1549,7 +1547,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
                }
 
              if ((c == ':' && indx == 1 && dtp->u.p.saved_string == 0)
-               || (indx == 2 && dtp->u.p.saved_string == 0))
+                 || (indx == 2 && dtp->u.p.saved_string == 0))
                {
                  st_sprintf(parse_err_msg, "Bad index triplet");
                  goto err_ret;
@@ -1558,14 +1556,13 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
              /* If '( : ? )' or '( ? : )' break and flag read failure.  */
              null_flag = 0;
              if ((c == ':' && indx == 0 && dtp->u.p.saved_string == 0)
-               || (indx==1 && dtp->u.p.saved_string == 0))
+                 || (indx==1 && dtp->u.p.saved_string == 0))
                {
                  null_flag = 1;
                  break;
                }
 
              /* Now read the index.  */
-
              if (convert_integer (dtp, sizeof(int), neg))
                {
                  st_sprintf (parse_err_msg, "Bad integer in index");
@@ -1574,52 +1571,47 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
              break;
            }
 
-         /*feed the index values to the triplet arrays.  */
-
+         /* Feed the index values to the triplet arrays.  */
          if (!null_flag)
            {
              if (indx == 0)
-               ls[dim].start = *(int *)dtp->u.p.value;
+               memcpy (&ls[dim].start, dtp->u.p.value, sizeof(int));
              if (indx == 1)
-               ls[dim].end   = *(int *)dtp->u.p.value;
+               memcpy (&ls[dim].end, dtp->u.p.value, sizeof(int));
              if (indx == 2)
-               ls[dim].step  = *(int *)dtp->u.p.value;
+               memcpy (&ls[dim].step, dtp->u.p.value, sizeof(int));
            }
 
-         /*singlet or doublet indices  */
-
+         /* Singlet or doublet indices.  */
          if (c==',' || c==')')
            {
              if (indx == 0)
                {
-                 ls[dim].start = *(int *)dtp->u.p.value;
-                 ls[dim].end = *(int *)dtp->u.p.value;
+                 memcpy (&ls[dim].start, dtp->u.p.value, sizeof(int));
+                 ls[dim].end = ls[dim].start;
                }
              break;
            }
        }
 
-      /*Check the values of the triplet indices.  */
-
-      if ( (ls[dim].start > (ssize_t)ad[dim].ubound)
-       || (ls[dim].start < (ssize_t)ad[dim].lbound)
-       || (ls[dim].end   > (ssize_t)ad[dim].ubound)
-       || (ls[dim].end   < (ssize_t)ad[dim].lbound))
+      /* Check the values of the triplet indices.  */
+      if ((ls[dim].start > (ssize_t)ad[dim].ubound)
+         || (ls[dim].start < (ssize_t)ad[dim].lbound)
+         || (ls[dim].end > (ssize_t)ad[dim].ubound)
+         || (ls[dim].end < (ssize_t)ad[dim].lbound))
        {
          st_sprintf (parse_err_msg, "Index %d out of range", dim + 1);
          goto err_ret;
        }
       if (((ls[dim].end - ls[dim].start ) * ls[dim].step < 0)
-       || (ls[dim].step == 0))
+         || (ls[dim].step == 0))
        {
          st_sprintf (parse_err_msg, "Bad range in index %d", dim + 1);
          goto err_ret;
        }
 
       /* Initialise the loop index counter.  */
-
       ls[dim].idx = ls[dim].start;
-
     }
   eat_spaces (dtp);
   return SUCCESS;