[sv-bc] $fread

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Sun Feb 24 2008 - 06:26:32 PST
Hi,

20.3.4.4 has the following:

$fread can be used to read binary data from a file. For example:

integer code ;
code = $fread( integral_var, fd);
code = $fread( mem, fd);
code = $fread( mem, fd, start);
code = $fread( mem, fd, start, count);
code = $fread( mem, fd, , count);

reads a binary data from the file specified by fd into the variable
myreg or the memory mem.

The register integral variable variant,
$fread(myreg integral_var, fd);
is defined to be the one applied for all packed data.

First, I think "reads a binary data" should be "read binary data".

In 1364-2005, the second line of code used 'myreg' and the editor
changed it to 'integral_var'.
But the sentence still refers to 'myreg'.
The following sentence says 'register integral variable'. I think
'register' should be deleted.
And the code says "myreg integral_var". I think "myreg" should be
deleted.

Up to here, I think the editor does not need special authorization.
However, dealing with the following might require a Mantis item. Please
comment.

The sentence says, corrected,

The integral variable variant, $fread(integral_var, fd);, is defined to
be the one applied for all packed data.

and later appear

For unpacked struct data, $fread is defined to apply as though the
operation were performed on each member in declaration order.
For unpacked union data, $fread is defined to apply as though the
operation were performed on the first member in declaration order.

I find the sentence ambiguous. After studying both 1364-2005 and
1800-2005, I wonder, what is the item being 'packed' or 'unpacked'? Is
it the data in the file or is it the variable being loaded? On the one
hand, the term 'data' fits the file. On the other hand, 'packed' and
'unpacked' seem more appropriate for the variables being loaded. $fread
is used to load data from a binary file. What is the relevance of
'packed' and 'unpacked'?

I tend to think that the terms were intended to apply to the variable
being loaded, and the first sentence meant that in order to load a
packed variable, you have to use the 'integral variable variant'. That
is, you can't load a packed array using the memory form.

But I still have a problem with that. Both forms already existed in
1364. The LRM also says, "start and count are ignored if $fread is
loading an integral variable." That means that if you want to load an
integral variable, you can also use the memory form, but then the last
two arguments are ignored. That is a contradiction.

I also don't understand about the unpacked struct case. Which form is
used, the variable form or the memory form? If the memory form, do
'start' and 'count' have meaning?

And this is all without getting into more complicated forms, such as
multidimensional arrays.

What a headache!

Anyone understand this?

Thanks,
Shalom

Shalom Bresticker
Intel Jerusalem LAD DA
+972 2 589-6582
+972 54 721-1033
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Sun Feb 24 06:28:15 2008

This archive was generated by hypermail 2.1.8 : Sun Feb 24 2008 - 06:28:58 PST