[patch, libfortran] Fix for PR 20163, first bug

Thomas Koenig Thomas.Koenig@online.de
Sat Feb 26 20:36:00 GMT 2005


This fixes the first bug in PR 20163.  Bootstrapped and
regression-tested, hereby donated to the FSF (and I'll start
working on that copyright assignment).

This fixes a regression against g77.  If this is OK, please
apply to mainline.  If this is applicable for the 4.0 release
branch, please apply there as well.

2005-02-26  Thomas Koenig <Thomas.Koenig@online.de>

	PR libfortran/20163
	* runtime/string.c (compare0): Use fstrlen() to 
	strip trailing blanks from option string.
-------------- next part --------------
! { dg do-run }
! PR 20163, first half:  Trailing blanks on an option to
!                        open used to cause an error
      CHARACTER*8 ST
      OPEN(UNIT=10,STATUS=ST)
      END
-------------- next part --------------
Index: string.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/runtime/string.c,v
retrieving revision 1.4
diff -c -r1.4 string.c
*** string.c	12 Jan 2005 21:27:31 -0000	1.4
--- string.c	26 Feb 2005 09:03:39 -0000
***************
*** 41,57 ****
  compare0 (const char *s1, int s1_len, const char *s2)
  {
    int i;
  
!   if (strncasecmp (s1, s2, s1_len) != 0)
!     return 0;
! 
!   /* The rest of s1 needs to be blanks for equality.  */
! 
!   for (i = strlen (s2); i < s1_len; i++)
!     if (s1[i] != ' ')
!       return 0;
! 
!   return 1;
  }
  
  
--- 41,51 ----
  compare0 (const char *s1, int s1_len, const char *s2)
  {
    int i;
+   int len;
  
!   /* Strip traling blanks from the Fortran string.  */
!   len = fstrlen(s1, s1_len);
!   return strncasecmp(s1,s2,len) == 0;
  }
  
  


More information about the Fortran mailing list