This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] manual: Document %m instead of %a for formatted input.


   > > @@ -3929,18 +3933,21 @@ input with a comprehensible error message, not with a crash.
   > >  @node Dynamic String Input
   > >  @subsection Dynamically Allocating String Conversions
   > >  
   > > -A GNU extension to formatted input lets you safely read a string with no
   > > -maximum size.  Using this feature, you don't supply a buffer; instead,
   > > -@code{scanf} allocates a buffer big enough to hold the data and gives
   > > -you its address.  To use this feature, write @samp{a} as a flag
   > > -character, as in @samp{%as} or @samp{%a[0-9a-z]}.
   > > +Since ISO C-1990 there is feature to safely read a string with no maximum 
   > > +size.  Using this feature, you don't supply a buffer; instead, @code{scanf}
   > > +allocates a buffer big enough to hold the data and gives you its address.
   > > +To use this feature, write @samp{m} as a flag character, as in 
   > > +@samp{%ms}, @samp{%m10c} or @samp{%m[0-9a-z]}.
   > 
   > It's not C90, or C99, or C11.  It's a POSIX (new in the 2008
   > edition) feature, also present in the C TR 24731-2:2010 which was
   > not (unlike 24731-1) integrated in C11.

   The original version had POSIX in it. Roland said that its part of
   C standard. So what should be there not keep changing that back and
   forth?

Roland is wrong (I've seen it once -- but I don't remeber when).

The following ERN got added to IEEE 1.1003-2008 (see
http://www.opengroup.org/austin/aardvark/latest/xshbug2.txt for
details):

 _____________________________________________________________________________
 COMMENT                                          Enhancement Request Number 132
 ajosey:opengroup.org                          Defect in XSH fscanf (rdvk#  2)
 {lsb-ottawa-3}                                  Wed, 22 Feb 2006 16:28:44 GMT
 _____________________________________________________________________________
 Accept_____    Accept as marked below_X___     Duplicate_____     Reject_____
 Rationale for rejected or partial changes:

In fscanf DESCRIPTION

In XSH p444 add after 14628
   * An optional assignment-allocation character 'm'

Insert after line 14664 before the text "The length modifiers
and their meanings are:"

[CX] (bullet list item)An optional assignment-allocation character `m`.

The %s, %S and %[ conversion specifiers shall accept an optional
assignment-allocation character 'm', which shall cause a memory buffer to
be allocated to hold the string converted including a terminating null
character. In such a case, the argument corresponding to the conversion
specifier should be a reference to a pointer variable that will receive
a pointer to the  allocated buffer.  The system shall allocate a buffer
as if malloc had been called.  The application shall be responsible
for freeing the memory after usage.  If there is insufficient memory
to allocate a buffer, the function shall set errno to [ENOMEM] and a
conversion error shall result.  In that case any memory successfully
allocated for other parameters using assignment-allocation character
'm' by this call shall be freed.  [/CX]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]