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]

[PATCH, libgfortran] Fix PR21875 (FM111.f) BN and BZ format specifiers


This patch implements the BZ and BN format specifiers correctly.

Bubblestrapped and regression tested. Tested with original NIST FM111.f and attached test case.

After this there are three remaining failures in NIST being tracked in PR21875.

OK to commit to mainline? 4.0?

Regards

Jerry
? io.diff
Index: read.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/read.c,v
retrieving revision 1.12
diff -c -3 -p -r1.12 read.c
*** read.c	23 Jun 2005 18:50:24 -0000	1.12
--- read.c	9 Jul 2005 06:48:34 -0000
*************** next_char (char **p, int *w)
*** 266,273 ****
  
    if (c != ' ')
      return c;
!   if (g.blank_status == BLANK_ZERO)
!     return '0';
  
    /* At this point, the rest of the field has to be trailing blanks */
  
--- 266,273 ----
  
    if (c != ' ')
      return c;
!   if (g.blank_status != BLANK_UNSPECIFIED)
!     return ' ';  /* return a blank to signal a null */ 
  
    /* At this point, the rest of the field has to be trailing blanks */
  
*************** read_decimal (fnode * f, char *dest, int
*** 336,342 ****
        c = next_char (&p, &w);
        if (c == '\0')
  	break;
! 
        if (c < '0' || c > '9')
  	goto bad;
  
--- 336,348 ----
        c = next_char (&p, &w);
        if (c == '\0')
  	break;
! 	
!       if (c == ' ')
!         {
!           if (g.blank_status == BLANK_NULL) continue;
!           if (g.blank_status == BLANK_ZERO) c = '0';
!         }
!         
        if (c < '0' || c > '9')
  	goto bad;
  
*************** read_decimal (fnode * f, char *dest, int
*** 348,354 ****
  
        if (value > maxv - c)
  	goto overflow;
!       value += c;
      }
  
    v = value;
--- 354,360 ----
  
        if (value > maxv - c)
  	goto overflow;
!       value += c;      
      }
  
    v = value;
*************** read_radix (fnode * f, char *dest, int l
*** 424,429 ****
--- 430,440 ----
        c = next_char (&p, &w);
        if (c == '\0')
  	break;
+       if (c == ' ')
+         {
+           if (g.blank_status == BLANK_NULL) continue;
+           if (g.blank_status == BLANK_ZERO) c = '0';
+         }
  
        switch (radix)
  	{
*************** read_f (fnode * f, char *dest, int lengt
*** 582,588 ****
  	case '8':
  	case '9':
  	case ' ':
! 	  ndigits++;
  	  *p++;
  	  w--;
  	  break;
--- 593,599 ----
  	case '8':
  	case '9':
  	case ' ':
!  	  ndigits++;
  	  *p++;
  	  w--;
  	  break;
*************** read_f (fnode * f, char *dest, int lengt
*** 732,749 ****
      buffer = get_mem (i);
  
    /* Reformat the string into a temporary buffer.  As we're using atof it's
!      easiest to just leave the dcimal point in place.  */
    p = buffer;
    if (val_sign < 0)
      *(p++) = '-';
    for (; ndigits > 0; ndigits--)
      {
!       if (*digits == ' ' && g.blank_status == BLANK_ZERO)
! 	*p = '0';
        else
! 	*p = *digits;
!       p++;
!       digits++;
      }
    *(p++) = 'e';
    sprintf (p, "%d", exponent);
--- 743,770 ----
      buffer = get_mem (i);
  
    /* Reformat the string into a temporary buffer.  As we're using atof it's
!      easiest to just leave the decimal point in place.  */
    p = buffer;
    if (val_sign < 0)
      *(p++) = '-';
    for (; ndigits > 0; ndigits--)
      {
!       if (*digits == ' ')
!         {
!           if (g.blank_status == BLANK_NULL) digits++;
!           if (g.blank_status == BLANK_ZERO)
!             {
!               *p = '0';
!               p++;
!               digits++;
!             }
!         }
        else
!         {
!           *p = *digits;
!           p++;
!           digits++;
!         }
      }
    *(p++) = 'e';
    sprintf (p, "%d", exponent);

Attachment: test-bn.f90
Description: application/extension-f90


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