From patchwork Fri May 23 22:14:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 352046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4251814009A for ; Sat, 24 May 2014 08:14:35 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=hS1AcoEI0FFQvbjUGiBBULoMmCkdefB9H0nwrjywDQm 3RDBYCowkwpLJxz+ZtWp0mREA1kRv4O2MLhyHoi6/ThkGc+/UAiQgFheK/LoqQIq My8KuN1/uvxiyGJElCzoclMqvhTWAGSGoUtWUz+XLjW9akBzTvU12y9/0WUQvU3Q = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=HAe3V4jwYByGg9BYwwP3QFuEXBU=; b=a4O9mWt4mWVC180Cu fD1+m9oQfGV8z0iTubHd6C1PJeYyEJFI2H+coicTv4APTjDJKdlhCavZPImjzVnj j0pOCcsy5hDOEA1ekziU7QSrsD0d5jwePQjmuzdKwMVzjmXG4XzP53nRZjZ/PdYL QRQciWPCteWm+dPxfaslRagmtA= Received: (qmail 15298 invoked by alias); 23 May 2014 22:14:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 15271 invoked by uid 89); 23 May 2014 22:14:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mta11.charter.net Received: from mta11.charter.net (HELO mta11.charter.net) (216.33.127.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 May 2014 22:14:26 +0000 Received: from imp11 ([10.20.200.11]) by mta11.charter.net (InterMail vM.8.01.05.09 201-2260-151-124-20120717) with ESMTP id <20140523221424.LQQV6169.mta11.charter.net@imp11>; Fri, 23 May 2014 18:14:24 -0400 Received: from pavilion.localdomain ([72.194.69.199]) by imp11 with smtp.charter.net id 5aEN1o00a4Hxx8Q05aEPd3; Fri, 23 May 2014 18:14:24 -0400 X-Authority-Analysis: v=2.0 cv=F7QP7ddN c=1 sm=1 a=B1S/AlkX9gmsrZinFLYKFA==:17 a=HlLLTiFvtacA:10 a=TSp8gH9mq4kA:10 a=yUnIBFQkZM0A:10 a=hOpmn2quAAAA:8 a=oYD1ev9MuOBXEi5ZLwcA:9 a=wPNLvfGTeEIA:10 a=2jAeXY_nCqAA:10 a=VERP9kcgIt4A:10 a=vFWk2ACAoabrFOj-0HgA:9 a=TdishIRuMitOl5d-_U4A:9 a=D-1Gv4cNB6QA:10 a=rL91ZVhEnSoA:10 a=B1S/AlkX9gmsrZinFLYKFA==:117 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 Message-ID: <537FC837.1070105@charter.net> Date: Fri, 23 May 2014 15:14:15 -0700 From: Jerry DeLisle User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: gfortran CC: gcc patches Subject: [patch, libgfortran] [4.9/4.10 Regression] Erroneous "end of file" with internal read Hello all, The attached patch fixes this PR by not seeking if the next character is a space. Regression tested on x86-64. New test case provided. OK for trunk and back ports? Regards. Jerry 2014-05-23 Jerry DeLisle PR libgfortran/61173 * io/list_read.c (eat_spaces): If the next character pointed to is a space, don't seek, must be at the end. Index: list_read.c =================================================================== --- list_read.c (revision 210879) +++ list_read.c (working copy) @@ -398,7 +398,7 @@ eat_spaces (st_parameter_dt *dtp) if (is_array_io (dtp)) { gfc_offset offset = stell (dtp->u.p.current_unit->s); - gfc_offset limit = dtp->u.p.current_unit->bytes_left; + gfc_offset limit = offset + dtp->u.p.current_unit->bytes_left; if (dtp->common.unit) /* kind=4 */ { @@ -410,13 +410,15 @@ eat_spaces (st_parameter_dt *dtp) offset += (sizeof (gfc_char4_t)); dtp->u.p.current_unit->bytes_left--; } - while (offset < limit && (cc == (gfc_char4_t)' ' - || cc == (gfc_char4_t)'\t')); + while (offset < limit && cc == (gfc_char4_t)' '); /* Back up, seek ahead, and fall through to complete the process so that END conditions are handled correctly. */ dtp->u.p.current_unit->bytes_left++; - sseek (dtp->u.p.current_unit->s, - offset-(sizeof (gfc_char4_t)), SEEK_SET); + + cc = dtp->internal_unit[offset]; + if (cc != (gfc_char4_t)' ') + sseek (dtp->u.p.current_unit->s, + offset-(sizeof (gfc_char4_t)), SEEK_SET); } else { @@ -425,11 +427,13 @@ eat_spaces (st_parameter_dt *dtp) c = dtp->internal_unit[offset++]; dtp->u.p.current_unit->bytes_left--; } - while (offset < limit && (c == ' ' || c == '\t')); + while (offset < limit && c == ' '); /* Back up, seek ahead, and fall through to complete the process so that END conditions are handled correctly. */ dtp->u.p.current_unit->bytes_left++; - sseek (dtp->u.p.current_unit->s, offset-1, SEEK_SET); + + if (dtp->internal_unit[offset] != ' ') + sseek (dtp->u.p.current_unit->s, offset - 1, SEEK_SET); } } /* Now skip spaces, EOF and EOL are handled in next_char. */