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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b41415bcc9748556 X-Google-Attributes: gid103376,public From: Anton Gibbs Subject: Re: Use of C.Strings.Value Function Considered Harmful Date: 1999/12/06 Message-ID: <384B907C.6583@dera.gov.uk>#1/1 X-Deja-AN: 557202311 Content-Transfer-Encoding: 7bit References: <3847E5CE.4F9E@dera.gov.uk> <829115$b6h$1@hobbes2.crc.com> Content-Type: text/plain; charset=us-ascii Organization: Eurocontrol Integration Team Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-12-06T00:00:00+00:00 List-Id: David C. Hoos, Sr. wrote: > You can use the function Interfaces.C.To_Ada, to convert the char_array > result of the function from B.3.1 (35) to an Ada String. > Read the manual?? I am just baffled by how unhelpful the Length parameter is in: function Value( Item : in chars_ptr; Length : in size_t ) return String; -- B3.1(39) As far as I can tell (from reading the manual, funny enough), if the designated string contains fewer than `Length' characters before its first null, then it returns a string of length < `Length' otherwise it raises Terminator_Error. What I have ended up doing (as David C. Hoos, Sr. suggests) is to call: function Value (Item : in chars_ptr; Length : in size_t) return char_array; -- B3.1(35) and then append a (sometimes superfluous) ASCII.nul before calling C_To_Ada with Trim_Null set to True. I would have liked a single call to Value to do all this for me; afterall, what I am trying to do here is not that unusual is it ? Thanks. Best -- Anton. -- Civil Air Traffic Management Group Defence Evaluation and Research Agency Bedford, UK "The Information contained in this E-Mail and any subsequent correspondence is private and is intended solely for the intended recipient(s). For those other than the intended recipient any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on such information is prohibited and may be unlawful."