From patchwork Wed Jan 2 03:36:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 208966 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]) by ozlabs.org (Postfix) with SMTP id DEDA82C0098 for ; Wed, 2 Jan 2013 14:37:06 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1357702627; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=mDW47Bcc0pLoJNhq2AChE0FB9dM=; b=krVhAjdYd+3lzYP KbDA0xv7ezvmGFlZs8OWqLMhbSuhHCyXM8u0xHmiMY2GyCrYC1+Qg7E/9heF1jT4 DkpmXU9SF1Uc0pAnGOpzk7NhWaQMRgHtcEtAJz6pE1NS6NE/FWn28ppmozzP/ra4 ZRuyfkBkycaFow2qGq+Ax+qXvHMM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:X-Authority-Analysis:X-Auth-id:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=YLaJ8pygXuOyVYHfEgdpEHb76fdhoN9OqUUt2DVsinlzQSh8lbXQxJmZlM3jCI p7Y+5NN8eabRUsvdUpw5a+60idaWTnU7mxRbmJlZ7rqUVbUzk/uTAFR0uagEjupx pe5s4yxmYGcan7Mw6xueKHngXRBJ+FQmV0nHtEFlGG/wM=; Received: (qmail 6635 invoked by alias); 2 Jan 2013 03:36:59 -0000 Received: (qmail 6615 invoked by uid 22791); 2 Jan 2013 03:36:58 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL, BAYES_00, KHOP_SPAMHAUS_DROP, KHOP_THREADED, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mta41.charter.net (HELO mta41.charter.net) (216.33.127.83) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Jan 2013 03:36:50 +0000 Received: from imp09 ([10.20.200.9]) by mta41.charter.net (InterMail vM.8.01.05.02 201-2260-151-103-20110920) with ESMTP id <20130102033648.PHLQ10143.mta41.charter.net@imp09>; Tue, 1 Jan 2013 22:36:48 -0500 Received: from quava.localdomain ([71.80.154.83]) by imp09 with smtp.charter.net id ircm1k0011oDdDj05rcnhD; Tue, 01 Jan 2013 22:36:48 -0500 X-Authority-Analysis: v=2.0 cv=Cp/n6QED c=1 sm=1 a=rAgDqpfJr0FWWJ6IzwxP7g==:17 a=uBsBa1gr-CYA:10 a=Sh6HmAv9I8UA:10 a=yUnIBFQkZM0A:10 a=hOpmn2quAAAA:8 a=lHtBJkU6CVwA:10 a=gtKPJlSVMAE1nrW6Kr8A:9 a=wPNLvfGTeEIA:10 a=2j00e-imJ9YD_h5DGI4A:9 a=6CKV6XVqvovnV40P:21 a=pmV4W3cRRmNQ6IkV:21 a=K47jXl0dzWUyAeklJaAA:9 a=rAgDqpfJr0FWWJ6IzwxP7g==:117 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 Message-ID: <50E3AB4D.8030006@charter.net> Date: Tue, 01 Jan 2013 19:36:45 -0800 From: Jerry DeLisle User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gfortran CC: gcc patches Subject: Re: [patch, libgfortran] PR55818 Reading a REAL from a file which doesn't end in a new line fails References: <50DCFB22.1010509@charter.net> <50DDE51B.5080902@charter.net> In-Reply-To: <50DDE51B.5080902@charter.net> 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 This updated patch addresses the issues with infinities, nans, characters, and valid reals. OK for trunk? Test case attached. Regards, Jerry Index: list_read.c =================================================================== --- list_read.c (revision 194731) +++ list_read.c (working copy) @@ -697,6 +697,7 @@ read_logical (st_parameter_dt *dtp, int length) break; CASE_SEPARATORS: + case EOF: unget_char (dtp, c); eat_separator (dtp); return; /* Null value. */ @@ -951,6 +952,7 @@ read_character (st_parameter_dt *dtp, int length _ break; CASE_SEPARATORS: + case EOF: unget_char (dtp, c); /* NULL value. */ eat_separator (dtp); return; @@ -975,8 +977,7 @@ read_character (st_parameter_dt *dtp, int length _ for (;;) { - if ((c = next_char (dtp)) == EOF) - goto eof; + c = next_char (dtp); switch (c) { CASE_DIGITS: @@ -984,6 +985,7 @@ read_character (st_parameter_dt *dtp, int length _ break; CASE_SEPARATORS: + case EOF: unget_char (dtp, c); goto done; /* String was only digits! */ @@ -1041,7 +1043,7 @@ read_character (st_parameter_dt *dtp, int length _ the string. */ if ((c = next_char (dtp)) == EOF) - goto eof; + goto done_eof; if (c == quote) { push_char (dtp, quote); @@ -1167,6 +1169,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, in goto exp2; CASE_SEPARATORS: + case EOF: goto done; default: @@ -1202,6 +1205,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, in break; CASE_SEPARATORS: + case EOF: unget_char (dtp, c); goto done; @@ -1243,7 +1247,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, in && ((c = next_char (dtp)) == 'y' || c == 'Y') && (c = next_char (dtp)))) { - if (is_separator (c)) + if (is_separator (c) || (c == EOF)) unget_char (dtp, c); push_char (dtp, 'i'); push_char (dtp, 'n'); @@ -1255,7 +1259,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, in && ((c = next_char (dtp)) == 'n' || c == 'N') && (c = next_char (dtp))) { - if (is_separator (c)) + if (is_separator (c) || (c == EOF)) unget_char (dtp, c); push_char (dtp, 'n'); push_char (dtp, 'a'); @@ -1269,7 +1273,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, in goto bad; c = next_char (dtp); - if (is_separator (c)) + if (is_separator (c) || (c == EOF)) unget_char (dtp, c); } goto done_infnan; @@ -1315,6 +1319,7 @@ read_complex (st_parameter_dt *dtp, void * dest, i break; CASE_SEPARATORS: + case EOF: unget_char (dtp, c); eat_separator (dtp); return; @@ -1369,7 +1374,7 @@ eol_4: goto bad_complex; c = next_char (dtp); - if (!is_separator (c)) + if (!is_separator (c) && (c != EOF)) goto bad_complex; unget_char (dtp, c); @@ -1429,6 +1434,7 @@ read_real (st_parameter_dt *dtp, void * dest, int goto got_sign; CASE_SEPARATORS: + case EOF: unget_char (dtp, c); /* Single null. */ eat_separator (dtp); return; @@ -1484,6 +1490,7 @@ read_real (st_parameter_dt *dtp, void * dest, int goto got_repeat; CASE_SEPARATORS: + case EOF: if (c != '\n' && c != ',' && c != '\r' && c != ';') unget_char (dtp, c); goto done; @@ -1647,7 +1654,7 @@ read_real (st_parameter_dt *dtp, void * dest, int goto unwind; c = next_char (dtp); l_push_char (dtp, c); - if (!is_separator (c)) + if (!is_separator (c) && (c != EOF)) { if (c != 'i' && c != 'I') goto unwind; @@ -1700,7 +1707,7 @@ read_real (st_parameter_dt *dtp, void * dest, int } } - if (!is_separator (c)) + if (!is_separator (c) && (c != EOF)) goto unwind; if (dtp->u.p.namelist_mode) @@ -2537,16 +2544,16 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info switch (nl->type) { case BT_INTEGER: - read_integer (dtp, len); - break; + read_integer (dtp, len); + break; case BT_LOGICAL: - read_logical (dtp, len); - break; + read_logical (dtp, len); + break; case BT_CHARACTER: - read_character (dtp, len); - break; + read_character (dtp, len); + break; case BT_REAL: /* Need to copy data back from the real location to the temp in order