From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10160 invoked by alias); 21 Jul 2005 10:12:26 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10126 invoked by alias); 21 Jul 2005 10:12:18 -0000 Date: Thu, 21 Jul 2005 10:53:00 -0000 Message-ID: <20050721101218.10124.qmail@sourceware.org> From: "stevenb at suse dot de" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050720153355.22570.dir@lanl.gov> References: <20050720153355.22570.dir@lanl.gov> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libfortran/22570] Null Characters instead of blanks in text output. X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg02548.txt.bz2 List-Id: ------- Additional Comments From stevenb at suse dot de 2005-07-21 10:12 ------- Subject: Re: Null Characters instead of blanks in t extoutput On Thursday 21 July 2005 11:10, THOMAS Paul Richard 169137 wrote: > Steven, > > Whilst waiting for somebody to show up to a meeting, I developed the third > correction. > > > To recap- > > > > The three buglets that I produced are: > > > > (1) The receipt of a slash should clear the pending skips and > > spaces(last night's patch); > > (2) The skips and spaces need to accumulate to cope with > > sequences of tabs and X-edits, > > as mentioned and tested this morning; and > > (3) The function read.c(read_x)must ignore > > current_unit->bytes_left, except where the > > record length is known. I will check out a clean way to do > > this tonight. I think that > > it is trivial but need to be sure that I pick the right condition. > > The patches to transfer.c and read.c that correct all three of the above > are enclosed. > > They have been regtested on Cygwin. > > Will provide changelog entries and testcase(s) tonight, when I will > resubmit. I would be grateful if you would try the various failing SPEC > cases and let me know what happens. Hi Paul, Thanks for your efforts. Sadly these patches still do not fix mgrid :-( In addition, it makes sixtrack worse. The expected output is of the form, 1.340689733836071700000000000000000 0.146543110072956760000000000000000 1.260311090193034800000000000000000 -0.042293577150839000000000000000000 -64.139440118247251000000000000000000 0.000703903375558890710000000000000 1.340690456452690900000000000000000 0.146543147601565030000000000000000 1.260311267783928500000000000000000 -0.042293584340409571000000000000000 -64.139440156078706000000000000000000 0.000703903375535219540000000000000 450000.000000000000000000000000000000000 450316.755142387060000000000000000000000 450316.755142376410000000000000000000000 But now I get something that looks like memory corruption: 1.291130196023531517823812000000000 0000000000 0.143847492053550962687325000000000 4800000000 1.230797727535498431450378000000000 4200000000 -0.041176487158203642358067500000000 M SEED 1 -64.137216332498809379103480000000000 UTION 0.000703904640534278491954822700000 0957530000 1.291130872561160991551787000000000 1602036000 0.143847531118832500096615900000000 5055850000 1.230797901908041502849755000000000 3846270600 -0.041176494385251151408855460000000 6256300000 -64.137216367717257980984870000000000 8443759257 0.000703904640508020307959613500000 5815140000 450000.000000000000000000000000000000000 2841676000 450316.755711623525712639100000000000000 5223840000 450316.755711611709557473700000000000000 A test case demonstrating the problem with the '\0' characters is this: IMPLICIT NONE INTEGER IOUT,IOA, III REAL CC IOA=18 CC=3.1425 OPEN(UNIT=18, FORM='FORMATTED', STATUS='UNKNOWN') WRITE(18,100) IOA, IOA, CC, IOA C REWIND(18) C READ(18,'(A10,18(2X,I4))') C10, K 100 FORMAT(1x/5x,'PARTICLE ',i3,' STABLE - RANDOM SEED ', i8, +' MOMENTUM DEVIATION ',g12.5 /5x,'REVOLUTION ',i8/) CLOSE(UNIT=18)!,STATUS='DELETE') END The output I get is (with '^@' == '\0' again): ================================================ PARTICLE 18 STABLE - RANDOM SEED 18 MOMENTUM DEVIATION 3.1425 ^@^@^@^@^@REVOLUTION 18 ================================================ I have attached the whole collection of patches that is in my local tree right now. It is your fixes plus Jerry's for the BN/BZ thing. Gr. Steven Index: io/read.c =================================================================== RCS file: /cvs/gcc/gcc/libgfortran/io/read.c,v retrieving revision 1.14 diff -u -3 -p -r1.14 read.c --- io/read.c 13 Jul 2005 18:43:11 -0000 1.14 +++ io/read.c 21 Jul 2005 09:44:30 -0000 @@ -691,24 +691,46 @@ read_f (fnode * f, char *dest, int lengt p++; w--; - while (w > 0) + if (g.blank_status == BLANK_UNSPECIFIED) /* Normal processing of exponent */ { - if (*p == ' ') + while (w > 0 && isdigit (*p)) { - if (g.blank_status == BLANK_ZERO) *p = '0'; - if (g.blank_status == BLANK_NULL) + exponent = 10 * exponent + *p - '0'; + p++; + w--; + } + + /* Only allow trailing blanks */ + + while (w > 0) + { + if (*p != ' ') + goto bad_float; + p++; + w--; + } + } + else /* BZ or BN status is enabled */ + { + while (w > 0) + { + if (*p == ' ') { - p++; - w--; - continue; + if (g.blank_status == BLANK_ZERO) *p = '0'; + if (g.blank_status == BLANK_NULL) + { + p++; + w--; + continue; + } } + else if (!isdigit (*p)) + goto bad_float; + + exponent = 10 * exponent + *p - '0'; + p++; + w--; } - if (!isdigit (*p)) - goto bad_float; - - exponent = 10 * exponent + *p - '0'; - p++; - w--; } exponent = exponent * exponent_sign; @@ -784,12 +806,14 @@ read_f (fnode * f, char *dest, int lengt void read_x (fnode * f) { - int n, m; + int n; n = f->u.n; - m = (int)current_unit->bytes_left; - if (f->format == FMT_X) - n = (n > m) ? m : n; - if (n) + + if ((current_unit->flags.pad == PAD_NO || is_internal_unit ()) + && current_unit->bytes_left < n) + n = current_unit->bytes_left; + + if (n > 0) read_block (&n); } Index: io/transfer.c =================================================================== RCS file: /cvs/gcc/gcc/libgfortran/io/transfer.c,v retrieving revision 1.48 diff -u -3 -p -r1.48 transfer.c --- io/transfer.c 14 Jul 2005 06:21:58 -0000 1.48 +++ io/transfer.c 21 Jul 2005 09:44:31 -0000 @@ -687,8 +687,8 @@ formatted_transfer (bt type, void *p, in case FMT_TR: consume_data_flag = 0 ; - pos = current_unit->recl - current_unit->bytes_left + f->u.n; - skips = f->u.n; + pos = current_unit->recl - current_unit->bytes_left + f->u.n +skips; + skips = f->u.n + skips; pending_spaces = pos - max_pos; /* Writes occur just before the switch on f->format, above, so that @@ -776,6 +776,7 @@ formatted_transfer (bt type, void *p, in case FMT_SLASH: consume_data_flag = 0 ; + skips = pending_spaces = 0; next_record (0); break; Index: io/unit.c =================================================================== RCS file: /cvs/gcc/gcc/libgfortran/io/unit.c,v retrieving revision 1.12 diff -u -3 -p -r1.12 unit.c --- io/unit.c 17 May 2005 17:02:38 -0000 1.12 +++ io/unit.c 21 Jul 2005 09:44:31 -0000 @@ -304,7 +304,7 @@ init_units (void) u->flags.access = ACCESS_SEQUENTIAL; u->flags.form = FORM_FORMATTED; u->flags.status = STATUS_OLD; - u->flags.blank = BLANK_ZERO; + u->flags.blank = BLANK_UNSPECIFIED; u->flags.position = POSITION_ASIS; u->recl = options.default_recl; @@ -326,7 +326,7 @@ init_units (void) u->flags.access = ACCESS_SEQUENTIAL; u->flags.form = FORM_FORMATTED; u->flags.status = STATUS_OLD; - u->flags.blank = BLANK_ZERO; + u->flags.blank = BLANK_UNSPECIFIED; u->flags.position = POSITION_ASIS; u->recl = options.default_recl; @@ -348,7 +348,7 @@ init_units (void) u->flags.access = ACCESS_SEQUENTIAL; u->flags.form = FORM_FORMATTED; u->flags.status = STATUS_OLD; - u->flags.blank = BLANK_ZERO; + u->flags.blank = BLANK_UNSPECIFIED; u->flags.position = POSITION_ASIS; u->recl = options.default_recl; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22570