Re: iso_varying_string in f2003?



Richard E Maine wrote:
> In article <vjose1tc3ifaj21v2763nbgd9v23l3gbe3@xxxxxxx>,
> Steve Lionel <Steve.Lionel@xxxxxxxxxxxxxxxxx> wrote:
>
> You're proposing that the compiler reallocate (if
>> needed) variable line to the length of the input? I can't claim
>> to have studied this in depth, but a quick glance at the F2003
>> standard suggests that such behavior would violate this part of
>> the standard, "If a field width w is not specified with the A edit
>> descriptor, the number of characters in the field is the length of
>> the corresponding list item". Your proposal would change this
>> behavior ...
>
> Only if there is such a length (i.e. if the string is allocated).
> If the string isn't allocated, then the code is illegal, and thus
> one could consider things that would extend rather than violate the
> standard. Now crafting such extensions sensibly.... well that might
> be nontrivial, as mentioned in my other post.

Well what about this:

Add a new Format edit descriptorAL whose field width is all the
remaining characters of the present input record. If the corresponding
I/O list item is a conventional fixed length character variable, the
result is the same as if Aw had been specified for that very field
width w. If the corresponding list item is a deferred length string,
then the result is to allocate the string to the appropriate length
(deallocating, if it's already allocated) and place the data there.

I think that may cover all the bases.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


.



Relevant Pages

  • Re: Why crash ?
    ... Yes, but naively, I would assume that the optimal buffer size ... depended on a certain number of characters, ... small string optimization is that the std::string object has a certain ... If you allocate dynamic storage, the string object has to store ...
    (microsoft.public.vc.language)
  • Re: Why crash ?
    ... Yes, but naively, I would assume that the optimal buffer size ... depended on a certain number of characters, ... small string optimization is that the std::string object has a certain ... If you allocate dynamic storage, the string object has to store ...
    (microsoft.public.vc.language)
  • Re: Reading an Ascii string
    ... OK, but in C, I would only allocate the string once, and it would be ... a fixed-length string of 41 characters (max num characters is 40 plus ... allocating it and de-allocating it - I would use it repeatedly, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to take in a string of any size?
    ... #> You could write it to a file, counting the characters as you go, ... #> and then allocate the memory and read it back in. ... which leads to the original question of how do you read a string ...
    (comp.lang.c)
  • Re: Dynamic C String Problem
    ... Using the conio implementation i wanted to create a dynamic string, ... whereby its size would be determined after each keyboard hit; ... Of Course, I would prefer a standard portable code instead of conio, ... wouldn't be allocating 128 Bytes a waste to allocate such unnecessary ...
    (comp.lang.c)