From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!backlog3.nntp.dca3.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 26 Jul 2014 14:06:33 -0500 Date: Sat, 26 Jul 2014 15:06:32 -0400 From: Peter Chapin User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Troubles with C strings References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Message-ID: <3bOdnRP2NdykYU7ORVn_vwA@giganews.com> X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-8VNLxAFotiCEA+9fdWCRq5uWiKehoGHtR0Fjm3rQBpDavOZywp6CMjPYh83OljySa1iDpK5UB8C9JlF!zj4CK5cdZe32rMPnD0XTpxOTcdoSgekNWJDHGmYUXw9ZsSBiqqA8ozOiQ8HKg60= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2183 X-Received-Bytes: 2295 X-Received-Body-CRC: 1530256625 Xref: news.eternal-september.org comp.lang.ada:21260 Date: 2014-07-26T15:06:32-04:00 List-Id: On 2014-07-26 11:15, Shark8 wrote: > On 26-Jul-14 08:13, Victor Porton wrote: >> Also: It seems that in Interfaces.C.Strings there is no function which >> creates an Ada string of specified length from a chars_ptr (without >> checking for NUL). > > Such a function cannot exist: to determine the length of a C-style > string you *must* scan through it for the terminating NULL. What you > describe would be a "substring" method that can read beyond the > string-bounds without raising an error... and I see no way that would > end well. Well the function could exist; it would just require an additional parameter to specify how much should be copied. While such an approach might be contrary to the sensibilities of Ada programmers, I don't think C programmers would find it shocking. Of course we are talking about an Ada interface here so adding a function that by its nature could easily lead to undefined behave... er... erroneous execution probably wouldn't be great.