From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 148C63858427 for ; Fri, 4 Nov 2022 15:16:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 148C63858427 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667574977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=45+pQKttjyP2ASE+ze/Z+1YF4OWi5mRsRq8AKCbh8Fg=; b=alIRB2jCKqcY0nzBwm85CAZ+LlZL9IRHQWCsrqRqNiBCibQyL0KxuxrkjALviBREYvMNIG SPuWgWW7mawfRbMDKJ6sHtR85a9yuU5pXoETbJkrIsfMnr2T+K9q/xF7xuHs/rfOENibJr C7GhNLOfo3EfhpCp4WI8nZRhaJxLA2U= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-669-sXxnxv8hNM6Dv6O740h97g-1; Fri, 04 Nov 2022 11:16:16 -0400 X-MC-Unique: sXxnxv8hNM6Dv6O740h97g-1 Received: by mail-qk1-f197.google.com with SMTP id u6-20020a05620a430600b006e47fa02576so4623644qko.22 for ; Fri, 04 Nov 2022 08:16:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=45+pQKttjyP2ASE+ze/Z+1YF4OWi5mRsRq8AKCbh8Fg=; b=yXKAMzLf1CaIgwZECtJngLkZoDd6PqaHqxTu8mKUmWwluEzN8ubM2oOxb/YkwoLbPC GkkYFJgEkAoub+kb/aWqUPzAs8ZpcXpqvVL9aMeljf0U0QZLETGLijMM86PiOo0oAiKW va5f/d2VfKcUiL4xdknFxOSCphKu0AsSZ6TDlbSYzlgJQ/XLsQNqBinXKrrnrIHicIV/ F3dHcjMEmAGgoR5zjWCuePWQPF3K6+X081CO1dhv9Wman6n1XpQStv3PP4chuNmoQNIj F6tkEVUkQUJostPFyd/021t+ttvAy5TiPbxxDeUKuqI2jol3yYgcVOJX6M1JRS+ka7m0 ezgA== X-Gm-Message-State: ACrzQf3Y1zmgd3B2XIZpDqH6t9jQaqtC6rDna7cgxXyJ0MHiQb/23tLG 6VyIe6grpkGyKhnQ2AQYmeQQCdp+Khr402hQj1nOiMYLLIr6tAZi5CH+3MmXxdQUYGzL6MGemb0 z+nleranmHk74o8KrFw== X-Received: by 2002:a05:620a:4146:b0:6fa:c8e:b60 with SMTP id k6-20020a05620a414600b006fa0c8e0b60mr26700173qko.454.1667574975956; Fri, 04 Nov 2022 08:16:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6H4f7ljfTpO43pnPdyaNfwYESwji+b5g2BH+YePyE6JzzQCMDryyLd6ipNFQlj6LWXatc4vw== X-Received: by 2002:a05:620a:4146:b0:6fa:c8e:b60 with SMTP id k6-20020a05620a414600b006fa0c8e0b60mr26700153qko.454.1667574975653; Fri, 04 Nov 2022 08:16:15 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id c5-20020a05620a268500b006fa4b111c76sm3099750qkp.36.2022.11.04.08.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 08:16:15 -0700 (PDT) Message-ID: <41648997dfcb55920d54e93622501d4264068911.camel@redhat.com> Subject: Re: [PATCH RFA] input: add get_source_text_between From: David Malcolm To: Jason Merrill , gcc-patches@gcc.gnu.org Date: Fri, 04 Nov 2022 11:16:14 -0400 In-Reply-To: <22136833-3ba8-686b-4eae-a709f2c1780d@redhat.com> References: <20221103195902.2114479-1-jason@redhat.com> <906b1326bd95c094331f7a5ff46723986215e3cf.camel@redhat.com> <22136833-3ba8-686b-4eae-a709f2c1780d@redhat.com> User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 2022-11-04 at 10:27 -0400, Jason Merrill wrote: > On 11/3/22 19:06, David Malcolm wrote: > > On Thu, 2022-11-03 at 15:59 -0400, Jason Merrill via Gcc-patches > > wrote: [...snip...] > >=20 > >=20 > > Do you have test coverage for this from the DejaGnu side?=C2=A0 If not, > > you > > could add selftest coverage for this; see input.cc's > > test_reading_source_line for something similar. >=20 > There is test coverage for the output of the the contract violation=20 > handler, which involves printing the result of this function. Thanks. =C2=A0 Is this test posted somwehere? I was looking in: https://gcc.gnu.org/pipermail/gcc-patches/2022-November/604974.html but I'm not seeing it. Sorry if I'm missing something here. Ideally we should have coverage for the three cases of: (a) bails out and returns NULL (b) single-line case (c) multi-line case > index a28abfac5ac..04d0809bfdf 100644 > --- a/gcc/input.cc > +++ b/gcc/input.cc > @@ -949,6 +949,97 @@ location_get_source_line (const char *file_path, int= line) > return char_span (buffer, len); > } Strings in input.cc are not always NUL-terminated, so... > =20 > +/* Return a copy of the source text between two locations. The caller i= s > + responsible for freeing the return value. */ ...please note in the comment that if non-NULL, the copy is NUL- terminated (I checked both exit paths that can return non-NULL, and they do NUL-terminate their buffers). OK with that nit fixed. Thanks Dave