comp.lang.ada
 help / color / mirror / Atom feed
From: Anton Gibbs <agibbs@dera.gov.uk>
Subject: Re: Use of C.Strings.Value Function Considered Harmful
Date: 1999/12/06
Date: 1999-12-06T00:00:00+00:00	[thread overview]
Message-ID: <384B907C.6583@dera.gov.uk> (raw)
In-Reply-To: 829115$b6h$1@hobbes2.crc.com

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."




  reply	other threads:[~1999-12-06  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-03  0:00 Use of C.Strings.Value Function Considered Harmful Anton Gibbs
1999-12-03  0:00 ` David C. Hoos, Sr.
1999-12-06  0:00   ` Anton Gibbs [this message]
1999-12-06  0:00     ` Lutz Donnerhacke
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox