From patchwork Sun Mar 31 03:53:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 232587 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id E44D02C00CC for ; Sun, 31 Mar 2013 14:54:00 +1100 (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=yu+M/0kTyoCRhQX/uRwFUulfGcOGdwdTLo3BU2GdHE3 TwuU55DhoBIJqlGKJwUMlUE/mY4AwDFCGVD+vxNVkbdtJQeFTAT1GOQVZVNsPogt 0sOLYtEzddu2+qujrXt56PPKL8d1t1mxRZoTY2mw3B87GaMoqrrsJNwExHR1TGTw = 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=B4G1BSwrfhyLmrRdbwMxvp9zWlY=; b=e5PsbFJCAIKxGM2UF LXlq93W5VSNR22odDBi9t63pPjrbfIbwDGzm6t35LPZd4YXu4R2lq/K/3NPOUk/5 iboI1lV8jPujfKeQwknE/JuwJOdz83byA7hKW0MQzYbXcEn/hkEVT72d8+sTj7E+ dmfrQjsi/Y4cIIDEm4zlCVD9fc= Received: (qmail 11241 invoked by alias); 31 Mar 2013 03:53:40 -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 11209 invoked by uid 89); 31 Mar 2013 03:53:33 -0000 X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mta41.charter.net (HELO mta41.charter.net) (216.33.127.83) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 31 Mar 2013 03:53:29 +0000 Received: from imp10 ([10.20.200.15]) by mta41.charter.net (InterMail vM.8.01.05.02 201-2260-151-103-20110920) with ESMTP id <20130331035327.GAGW10143.mta41.charter.net@imp10>; Sat, 30 Mar 2013 23:53:27 -0400 Received: from quava.localdomain ([72.194.70.222]) by imp10 with smtp.charter.net id J3tS1l00B4nkj6o053tTmE; Sat, 30 Mar 2013 23:53:27 -0400 X-Authority-Analysis: v=2.0 cv=foeE/yEf c=1 sm=1 a=L8sds5GVmE6e+zP2dgJA1w==:17 a=VW8mOq7NZXgA:10 a=8MKEfAtP-NkA:10 a=yUnIBFQkZM0A:10 a=hOpmn2quAAAA:8 a=38TlbTyqK7kA:10 a=mDV3o1hIAAAA:8 a=F65cAjr-8YNzsypJzIoA:9 a=wPNLvfGTeEIA:10 a=YMlA9X72Pj1mw0FYwxoA:9 a=5hx9ntR7sQVSIWJSE6gA:9 a=L8sds5GVmE6e+zP2dgJA1w==:117 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 Message-ID: <5157B336.8010301@charter.net> Date: Sat, 30 Mar 2013 20:53:26 -0700 From: Jerry DeLisle User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: gfortran CC: gcc patches Subject: [Patch, libgfortran] [4.6/4.7/4.8/4.9 Regression] Namelist read fails with designators containing embedded spaces X-Virus-Found: No Hi all, The attached patch fixes this PR by removing a spurious call to next_char which threw off the parsing sequence. In addition, I audited the file for other tests of EOF and corrected the error handling. This eliminated some wrong error messages or undefined error messages when an EOF is encountered during a namelist read. Also needed to modify hit_eof to not set the file position status for namelist mode to AFTER_ENDFILE to assure we get the correct EOF error. Also attached is the original test case from the PR, modified to include some reads cut short by EOF. Regression tested on x86-64. OK for trunk? Regards, Jerry 2013-03-29 Jerry DeLisle PR libfortran/56786 * io/list_read.c (nml_parse_qualifier): Remove spurious next_char call when checking for EOF. Use error return mechanism when EOF detected. Do not return false unless parse_err_msg and parse_err_msg_size have been set. Use hit_eof. (nml_get_obj_data): Likewise use the correct error mechanism. * io/transfer.c (hit_eof): Do not set AFTER_ENDFILE if in namelist mode. Index: list_read.c =================================================================== --- list_read.c (revision 197268) +++ list_read.c (working copy) @@ -2078,7 +2078,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip /* The next character in the stream should be the '('. */ if ((c = next_char (dtp)) == EOF) - return false; + goto err_ret; /* Process the qualifier, by dimension and triplet. */ @@ -2092,7 +2092,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip /* Process a potential sign. */ if ((c = next_char (dtp)) == EOF) - return false; + goto err_ret; switch (c) { case '-': @@ -2110,11 +2110,12 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip /* Process characters up to the next ':' , ',' or ')'. */ for (;;) { - if ((c = next_char (dtp)) == EOF) - return false; - + c = next_char (dtp); switch (c) { + case EOF: + goto err_ret; + case ':': is_array_section = 1; break; @@ -2137,10 +2138,8 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip push_char (dtp, c); continue; - case ' ': case '\t': + case ' ': case '\t': case '\r': case '\n': eat_spaces (dtp); - if ((c = next_char (dtp) == EOF)) - return false; break; default: @@ -2282,6 +2281,14 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip err_ret: + /* Do not return false unless parse_err_msg and parse_err_msg_size have + been set. */ + if (c == EOF) + { + hit_eof (dtp); + dtp->u.p.input_complete = 1; + return true; + } return false; } @@ -2751,12 +2758,12 @@ nml_get_obj_data (st_parameter_dt *dtp, namelist_i return true; if ((c = next_char (dtp)) == EOF) - return false; + goto nml_err_ret; switch (c) { case '=': if ((c = next_char (dtp)) == EOF) - return false; + goto nml_err_ret; if (c != '?') { snprintf (nml_err_msg, nml_err_msg_size, @@ -2806,8 +2813,9 @@ get_name: if (!is_separator (c)) push_char (dtp, tolower(c)); if ((c = next_char (dtp)) == EOF) - return false; - } while (!( c=='=' || c==' ' || c=='\t' || c =='(' || c =='%' )); + goto nml_err_ret; + } + while (!( c=='=' || c==' ' || c=='\t' || c =='(' || c =='%' )); unget_char (dtp, c); @@ -2882,7 +2890,7 @@ get_name: qualifier_flag = 1; if ((c = next_char (dtp)) == EOF) - return false; + goto nml_err_ret; unget_char (dtp, c); } else if (nl->var_rank > 0) @@ -2909,7 +2917,7 @@ get_name: component_flag = 1; if ((c = next_char (dtp)) == EOF) - return false; + goto nml_err_ret; goto get_name; } @@ -2946,7 +2954,7 @@ get_name: } if ((c = next_char (dtp)) == EOF) - return false; + goto nml_err_ret; unget_char (dtp, c); } @@ -2986,7 +2994,7 @@ get_name: return true; if ((c = next_char (dtp)) == EOF) - return false; + goto nml_err_ret; if (c != '=') { @@ -3021,6 +3029,15 @@ get_name: nml_err_ret: + /* Do not return false unless nml_err_msg and nml_err_msg_size have + been set. */ + if (c == EOF) + { + dtp->u.p.input_complete = 1; + unget_char (dtp, c); + hit_eof (dtp); + return true; + } return false; } Index: transfer.c =================================================================== --- transfer.c (revision 197268) +++ transfer.c (working copy) @@ -3840,7 +3840,7 @@ hit_eof (st_parameter_dt * dtp) case NO_ENDFILE: case AT_ENDFILE: generate_error (&dtp->common, LIBERROR_END, NULL); - if (!is_internal_unit (dtp)) + if (!is_internal_unit (dtp) && !dtp->u.p.namelist_mode) { dtp->u.p.current_unit->endfile = AFTER_ENDFILE; dtp->u.p.current_unit->current_record = 0;