comp.lang.ada
 help / color / mirror / Atom feed
From: lutz@iks-jena.de (Lutz Donnerhacke)
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: <slrn84neml.im.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: 384B907C.6583@dera.gov.uk

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




      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
1999-12-06  0:00     ` Lutz Donnerhacke [this message]
replies disabled

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