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=-0.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4ea0c01838520df4,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-24 15:15:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!deine.net!freenix!enst!enst.fr!not-for-mail From: Erik Sigra Newsgroups: comp.lang.ada Subject: Read booleans from streams Date: Mon, 25 Mar 2002 00:18:35 +0100 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Trace: avanie.enst.fr 1017011702 30508 137.194.161.2 (24 Mar 2002 23:15:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sun, 24 Mar 2002 23:15:02 +0000 (UTC) Return-Path: X-Mailer: KMail [version 1.3.2] Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk X-Reply-To: sigra@home.se List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:21626 Date: 2002-03-25T00:18:35+01:00 I tried to read bytes from a stream and interpret each bit as a Boolean. But it did not work as expected. It reads 1 byte for each bit. How should I do instead? streamtest.adb ============== with Ada.Text_IO; use Ada.Text_IO; with Ada.Streams; use Ada.Streams; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; procedure Streamtest is type Boolean_Aggregate is array (0 .. 7) of Boolean; for Boolean_Aggregate'Component_Size use 1; Current_Byte : Boolean_Aggregate; The_File : Stream_IO.File_Type; The_Stream : Stream_Access; begin Open (The_File, In_File, "data"); The_Stream := Stream (The_File); loop Boolean_Aggregate'Read (The_Stream, Current_Byte); for I in Boolean_Aggregate'Range loop Put(Current_Byte (I)'Img & ' '); end loop; New_Line; end loop; end Streamtest; data ==== 02027203 user > ./streamtest FALSE FALSE FALSE FALSE TRUE FALSE FALSE TRUE raised ADA.IO_EXCEPTIONS.END_ERROR : s-stratt.adb:170 I have checked that the size of Boolean_Aggregate is 8 and not 64.