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: lutz@iks-jena.de (Lutz Donnerhacke) Subject: Re: Use of C.Strings.Value Function Considered Harmful Date: 1999/12/06 Message-ID: #1/1 X-Deja-AN: 557251550 Distribution: world Content-Transfer-Encoding: 8bit References: <3847E5CE.4F9E@dera.gov.uk> <829115$b6h$1@hobbes2.crc.com> <384B907C.6583@dera.gov.uk> Content-Type: text/plain; charset=ISO-8859-1 Organization: IKS GmbH Jena Mime-Version: 1.0 User-Agent: slrn/0.9.5.7 (UNIX) Newsgroups: comp.lang.ada Date: 1999-12-06T00:00:00+00:00 List-Id: * Anton Gibbs wrote: >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. The exception prevents you from loosing data in conversion. >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 ? This procedere enshures a working program. It does not guarantee functionality. Moreover it introduces a wonderfully hidden error which can be live for years without causing trouble.