From patchwork Mon May 2 09:50:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 617444 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 3qz01Y59C2z9t49 for ; Mon, 2 May 2016 19:51:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=w0DWaw7h; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=EOKQyo+NybrQaaPWPqfty8LN3gjv4vEw80IsVJHfTs5o4L0sf5 qeMFAuz1wnXYy9i8F8QCSDzLMqhfFTebBLQz2v8TwH2jIG9+Nry23Am1Zw1Svh3o Cw61e3igJsOsuq1KfHpSq07GmSvrC4CCyJah/emSWeMkXjyukMMqZz148= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=3KY1UoH3MAku8ohTSiWv8hSL0Do=; b=w0DWaw7hTSJUZ9mjiRzy MnhoiR3rWZj4jhkkl6w17WJRl7LXHowEz+XI2YhPm60Gw9+aQK6IR7ntgWrsnCyC K0QvGhlDCUT51d0GLkTEArxaNKO6CK7WJG1IIir5HVizMaSwRoYh84ZBSctqy9KZ ioG3cF7+1WyqXiSYoWBckgQ= Received: (qmail 31789 invoked by alias); 2 May 2016 09:51:05 -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 31770 invoked by uid 89); 2 May 2016 09:51:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.8 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=Hx-languages-length:1205, yannick, get_line, U*moy X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 02 May 2016 09:50:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id E2901116B30; Mon, 2 May 2016 05:50:52 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 95ancDZ2GA3x; Mon, 2 May 2016 05:50:52 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id D03F8116AC2; Mon, 2 May 2016 05:50:52 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id CCA7941B; Mon, 2 May 2016 05:50:52 -0400 (EDT) Date: Mon, 2 May 2016 05:50:52 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [Ada] Correctly set Last when calling Text_IO.Get_Line on empty string Message-ID: <20160502095052.GA104781@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Ada RM requires that procedure Text_IO_Get_Line sets Last to Item'First - 1 when parameter Item is the empty string, which was not performed until now. Tested on x86_64-pc-linux-gnu, committed on trunk 2016-05-02 Yannick Moy * a-tigeli.adb (Get_Line): Always set Last prior to returning. Index: a-tigeli.adb =================================================================== --- a-tigeli.adb (revision 235710) +++ a-tigeli.adb (working copy) @@ -150,6 +150,12 @@ begin FIO.Check_Read_Status (AP (File)); + -- Set Last to Item'First - 1 when no characters are read, as mandated by + -- Ada RM. In the case where Item'First is negative or null, this results + -- in Constraint_Error being raised. + + Last := Item'First - 1; + -- Immediate exit for null string, this is a case in which we do not -- need to test for end of file and we do not skip a line mark under -- any circumstances. @@ -160,8 +166,6 @@ N := Item'Last - Item'First + 1; - Last := Item'First - 1; - -- Here we have at least one character, if we are immediately before -- a line mark, then we will just skip past it storing no characters.