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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1ea59bb198e88f9f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!cyclone1.gnilink.net!gnilink.net!wns13feed!worldnet.att.net!attbi_s54.POSTED!53ab2750!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: GNAT Ada.Streams Bug? References: X-Newsreader: Tom's custom newsreader Message-ID: <8xAqd.413508$wV.119785@attbi_s54> NNTP-Posting-Host: 67.161.24.234 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s54 1101714628 67.161.24.234 (Mon, 29 Nov 2004 07:50:28 GMT) NNTP-Posting-Date: Mon, 29 Nov 2004 07:50:28 GMT Organization: Comcast Online Date: Mon, 29 Nov 2004 07:50:28 GMT Xref: g2news1.google.com comp.lang.ada:6615 Date: 2004-11-29T07:50:28+00:00 List-Id: >All kinds of possibilities are available when _you_ control the format. Anytime you need a certain external form you should plan on writing your own 'Read et al. It may happen to work out that the default routines supplied by the compiler do what you want, but that shouldn't be your starting assumption. Things with odd sizes likely won't work, and composite objects will be inefficient. If you use a record rep clause to allow you to do IO on a multibyte object, you ought to write your own 'Read et al for that object. eg: for Partition_Type use record Flags at 0 range 0..7; CHS_Start at 1 range 0..23; Kind at 4 range 0..7; CHS_End at 5 range 0..23; LBA_Start at 8 range 0..31; LBA_Size at 12 range 0..31; end record; subtype External_Partition_Type is Ada.Streams.Stream_Element_Array(1 .. Partition_Type'size/8); function Internalize is new Ada.Unchecked_Conversion (Source=>External_Partition_Type, Target=>Partition_Type); function Externalize is new Ada.Unchecked_Conversion (Source=>Partition_Type, Target=>External_Partition_Type); procedure Partition_Type_Read (Stream : access Ada.Streams.Root_Stream_Type'class; Item : out Partition_Type) is External : External_Partition_Type; Last : Ada.Streams.Stream_Element_Offset; begin Read(Stream.all, External, Last); if Last /= External'last then raise ... end if; Item := Internalize(External); end Partition_Type_Read; for Partition_Type'Read use Partition_Type_Read; IMHO