------- Additional Comments From dir at lanl dot gov  2005-02-26 03:28 -------
I looked into the fortran source code and found a quick fix for the the
backspace bugs that were stopping my programs. In source file backspace.c. 

1). changed 

new = file_position (current_unit->s) - *p - length;
to 
new = file_position (current_unit->s) - *p - 2*length;

2). deleted
    if (u->current_record)
       next_record (1);
 
3). added 
       if (u->mode==WRITING){
          flush(u->s);
          struncate (u->s);
          u->mode = READING;
       }
       
4). added 
     u->endfile = NO_ENDFILE;
     u->current_record = 0;

These changes fix  bugs 20125 and 20156 and a few others that I had not yet
reported. I have run 48 test problems with 5 of my programs on the Macintosh
with these changes and they all ran correctly. If this is of value to the person
that actually fixes these problems please feel free to use it in any way.

[dir:~/fe/mystic/decks] dir% diff -c
/Users/dir/gfortran/gcc/libgfortran/io/backspace.c 
/Users/dir/junk/io/backspace.c
*** /Users/dir/gfortran/gcc/libgfortran/io/backspace.c  Fri Feb 25 18:48:05 2005
--- /Users/dir/junk/io/backspace.c      Wed Jan 12 13:27:30 2005
***************
*** 111,117 ****
    if (p == NULL)
      goto io_error;
  
!   new = file_position (current_unit->s) - *p - 2*length;
    if (sseek (current_unit->s, new) == FAILURE)
      goto io_error;
  
--- 111,117 ----
    if (p == NULL)
      goto io_error;
  
!   new = file_position (current_unit->s) - *p - length;
    if (sseek (current_unit->s, new) == FAILURE)
      goto io_error;
  
***************
*** 155,175 ****
      u->endfile = AT_ENDFILE;
    else
      {
        if (file_position (u->s) == 0)
        goto done;              /* Common special case */
!       if (u->mode==WRITING){
!          flush(u->s);
!          struncate (u->s);
!            u->mode = READING;
!       }
        if (u->flags.form == FORM_FORMATTED)
        formatted_backspace ();
        else
        unformatted_backspace ();
-     u->endfile = NO_ENDFILE;
-       u->current_record = 0;
      }
- 
  
   done:
    library_end ();
--- 155,171 ----
      u->endfile = AT_ENDFILE;
    else
      {
+       if (u->current_record)
+       next_record (1);
+ 
        if (file_position (u->s) == 0)
        goto done;              /* Common special case */
! 
        if (u->flags.form == FORM_FORMATTED)
        formatted_backspace ();
        else
        unformatted_backspace ();
      }
  
   done:
    library_end ();



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20156

Reply via email to