public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] manual: clarify that scanf %n supports type modifiers
@ 2021-03-29 11:45 Alyssa Ross
  2021-03-30 18:36 ` Arjun Shankar
  0 siblings, 1 reply; 2+ messages in thread
From: Alyssa Ross @ 2021-03-29 11:45 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alyssa Ross

My initial reading of the %n documentation was that it didn't support
type conversions, because it only mentioned int*.

Corresponding man-pages patch:
https://lore.kernel.org/linux-man/20210328215509.31666-1-hi@alyssa.is/
---

I'm in the process of sorting out my copyright paperwork, but I think
this change is probably small enough to be exempt?

 manual/stdio.texi | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/manual/stdio.texi b/manual/stdio.texi
index c48e3e692f..6ff1806281 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -3620,10 +3620,10 @@ function (@pxref{Parsing of Integers}) with the appropriate value
 The @samp{%X} conversion is identical to the @samp{%x} conversion.  They
 both permit either uppercase or lowercase letters to be used as digits.
 
-The default type of the corresponding argument for the @code{%d} and
-@code{%i} conversions is @code{int *}, and @code{unsigned int *} for the
-other integer conversions.  You can use the following type modifiers to
-specify other sizes of integer:
+The default type of the corresponding argument for the @code{%d},
+@code{%i}, and @code{%n} conversions is @code{int *}, and
+@code{unsigned int *} for the other integer conversions.  You can use
+the following type modifiers to specify other sizes of integer:
 
 @table @samp
 @item hh
@@ -3888,7 +3888,8 @@ The resulting pointer value is not guaranteed to be valid if it was not
 originally written during the same program execution that reads it in.
 
 The @samp{%n} conversion produces the number of characters read so far
-by this call.  The corresponding argument should be of type @code{int *}.
+by this call.  The corresponding argument should be of type @code{int *},
+unless a type modifier is in effect (@pxref{Numeric Input Conversions}).
 This conversion works in the same way as the @samp{%n} conversion for
 @code{printf}; see @ref{Other Output Conversions}, for an example.
 
-- 
2.30.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] manual: clarify that scanf %n supports type modifiers
  2021-03-29 11:45 [PATCH] manual: clarify that scanf %n supports type modifiers Alyssa Ross
@ 2021-03-30 18:36 ` Arjun Shankar
  0 siblings, 0 replies; 2+ messages in thread
From: Arjun Shankar @ 2021-03-30 18:36 UTC (permalink / raw)
  To: Alyssa Ross; +Cc: libc-alpha

Hi Alyssa,

> Subject: [PATCH] manual: clarify that scanf %n supports type modifiers
> 
> My initial reading of the %n documentation was that it didn't support
> type conversions, because it only mentioned int*.
> 
> Corresponding man-pages patch:
> https://lore.kernel.org/linux-man/20210328215509.31666-1-hi@alyssa.is/

Thanks for the patch!

I verified that %n in formatted input does indeed support type modifiers.

>  manual/stdio.texi | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/manual/stdio.texi b/manual/stdio.texi
> index c48e3e692f..6ff1806281 100644
> --- a/manual/stdio.texi
> +++ b/manual/stdio.texi
> @@ -3620,10 +3620,10 @@ function (@pxref{Parsing of Integers}) with the
> appropriate value
>  The @samp{%X} conversion is identical to the @samp{%x} conversion.  They
>  both permit either uppercase or lowercase letters to be used as digits.
>  
> -The default type of the corresponding argument for the @code{%d} and
> -@code{%i} conversions is @code{int *}, and @code{unsigned int *} for the
> -other integer conversions.  You can use the following type modifiers to
> -specify other sizes of integer:
> +The default type of the corresponding argument for the @code{%d},
> +@code{%i}, and @code{%n} conversions is @code{int *}, and
> +@code{unsigned int *} for the other integer conversions.  You can use
> +the following type modifiers to specify other sizes of integer:

OK.
 
>  @table @samp
>  @item hh
> @@ -3888,7 +3888,8 @@ The resulting pointer value is not guaranteed to be
> valid if it was not
>  originally written during the same program execution that reads it in.
>  
>  The @samp{%n} conversion produces the number of characters read so far
> -by this call.  The corresponding argument should be of type @code{int *}.
> +by this call.  The corresponding argument should be of type @code{int *},
> +unless a type modifier is in effect (@pxref{Numeric Input Conversions}).
>  This conversion works in the same way as the @samp{%n} conversion for
>  @code{printf}; see @ref{Other Output Conversions}, for an example.

OK. Links back to the numeric input conversions change above.

The generated info seems to render fine as well. This looks good to me.

Reviewed-by: Arjun Shankar <arjun@redhat.com>

I think this is small enough to qualify for an exemption from the
copyright assignment requirement. I'll push this to master in a bit.

Cheers,
Arjun


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-30 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 11:45 [PATCH] manual: clarify that scanf %n supports type modifiers Alyssa Ross
2021-03-30 18:36 ` Arjun Shankar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).