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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,816ea6d659f8e184,start X-Google-Attributes: gid103376,public From: Adam Beneschan Subject: Terminator_Error Date: 2000/04/12 Message-ID: <8d0haf$v4p$1@nnrp1.deja.com>#1/1 X-Deja-AN: 609887400 X-Http-Proxy: 1.0 x30.deja.com:80 (Squid/1.1.22) for client 207.213.113.50 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Apr 12 00:51:32 2000 GMT X-MyDeja-Info: XMYDJUIDabeneschan Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.05 [en] (X11; I; Linux 2.0.34 i686) Date: 2000-04-12T00:00:00+00:00 List-Id: True or false: The following code should always raise a Terminator_Error exception, where S is an Interfaces.C.String.Chars_Ptr that points to any nul-terminated C string. I think the answer is true. Here, Do_Something_With_String is a procedure that takes a String parameter. Length := Interfaces.C.Strings.Strlen (S); Do_Something_With_String (Interfaces.C.Strings.Value (S, Length)); The reason I think Value raises an exception is: B.3.1(40) says the call to Value is equivalent to To_Ada (Value (S, Length), Trim_Nul => True) where the Value call here is the one that returns a Char_Array. B.3.1(36) says that this last Value call returns "the shorter of two arrays: the first Length chars pointed to by Item, and Value(Item)." Value(Item) will always return Length+1 chars, since it returns all the characters pointed to by Item, plus the nul terminator (B.3.1(34)). Thus, the first Length chars pointed to by Item is always the shorter array, and the result of Value (S, Length) is therefore the characters of S, *without* the nul terminator. This causes To_Ada to raise an exception, since B.3(51) says that To_Ada propagates Terminator_Error if Trim_Nul is true and its parameter does not contain a nul. Am I right, or am I misunderstanding something? Sorry if this has been covered before. -- thanks, Adam Sent via Deja.com http://www.deja.com/ Before you buy.