This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] manual: Document %m instead of %a for formatted input.
- From: ams at gnu dot org (Alfred M. Szmidt)
- To: Ondřej Bílka <neleai at seznam dot cz>
- Cc: joseph at codesourcery dot com, roland at hack dot frob dot com, ville dot skytta at iki dot fi, libc-alpha at sourceware dot org
- Date: Wed, 19 Feb 2014 20:23:29 -0500
- Subject: Re: [PATCH] manual: Document %m instead of %a for formatted input.
- Authentication-results: sourceware.org; auth=none
- References: <20140211140022 dot GB22794 at domone dot podge> <20140211173249 dot 9BA1174451 at topped-with-meat dot com> <20140219135720 dot GD29125 at domone dot podge> <Pine dot LNX dot 4 dot 64 dot 1402191436110 dot 3311 at digraph dot polyomino dot org dot uk> <20140219150033 dot GA30329 at domone dot podge>
- Reply-to: ams at gnu dot org
> > @@ -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]