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 15413


> You're correct. I didn't consider long numbers like above. Also I
> noticed that complex numbers suffer from the same problem, the "("
> gets printed without a preceeding blank. Please consider the patch
> below instead of my original patch. It is even simpler than the
> original one by virtue of unconditionally printing a blank before
> proceeding with the list i/o. This means that all numeric output is
> shifted one character to the right, also those that previously were
> compliant. But I wouldn't consider that a problem since the (draft
> 2003) standard only specifies that a "reasonable" value should be used
> for the field width. And there is no mention nor implication as far as
> I can tell that the width of the first field should be one less than
> for the other fields to compensate for the initial blank.

I've applied the patch with a couple of additions:
- The comment for write_logical no longer applies, so should be removed.
- Made the field width for integer types depend on the type kind.

> > Do you have a copyright assignment for GCC? If not we will need one
> > before we can accept any more patches from you.
>
> No, I thought that I'm so far well below the "legally significant"
> level.

You were, but it doesn't take long to reach 15 lines of code :)

> Is there anything else I have to do other than follow the instruction
> e.g. on http://gcc.gnu.org/ml/gcc/2003-06/msg02298.html (fill in the
> form and send it to assign@gnu.org, wait for papers to arrive by snail
> mail)?

You may need to a copyright assignment from your employer/university if they 
have claims on the work you do.

Paul

2004-05-16  Janne Blomqvist  <jblomqvi@cc.hut.fi>
	Paul Brook  <paul@codesourcery.com>

	* io/write.c (write_logical): Don't print extra blank.
	(write_integer): Base field width on kind.
	(list_formatted_write): Output initial blank.

Index: write.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libgfortran/io/write.c,v
retrieving revision 1.3
diff -u -p -r1.3 write.c
--- a/write.c	15 May 2004 18:35:39 -0000	1.3
+++ b/write.c	16 May 2004 14:04:30 -0000
@@ -875,12 +875,10 @@ write_char (char c)
 
 
 /* write_logical()-- Write a list-directed logical value */
-/* Default logical output should be L2
-  according to DEC fortran Manual. */
+
 static void
 write_logical (const char *source, int length)
 {
-  write_char (' ');
   write_char (extract_int (source, length) ? 'T' : 'F');
 }
 
@@ -893,10 +891,33 @@ write_integer (const char *source, int l
   char *p;
   const char *q;
   int digits;
-  int width = 12;
+  int width;
 
   q = itoa (extract_int (source, length));
 
+  switch (length)
+    {
+    case 1:
+      width = 4;
+      break;
+
+    case 2:
+      width = 6;
+      break;
+
+    case 4:
+      width = 11;
+      break;
+
+    case 8:
+      width = 20;
+      break;
+
+    default:
+      width = 0;
+      break;
+    }
+
   digits = strlen (q);
 
   if(width < digits )
@@ -1039,6 +1060,7 @@ list_formatted_write (bt type, void *p, 
     {
       g.first_item = 0;
       char_flag = 0;
+      write_char (' ');
     }
   else
     {


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