manual: Fixed typo in manual/stdio.texi [BZ #24638]

Message ID CALkY8p8-MKPYh+z5XLOrfXdh5rr7U=tahEMO5Qp1vT0_=_G3Pw@mail.gmail.com
State Committed
Headers

Commit Message

Girish Joshi March 2, 2020, 6:57 p.m. UTC
  From 7f69eae716feb76474975fbf23d48e975019a424 Mon Sep 17 00:00:00 2001
From: Girish Joshi <girish946@gmail.com>
Date: Tue, 3 Mar 2020 00:24:28 +0530
Subject: [PATCH] [PATCH] Fixed typo in the example for parse_printf_format()
 in manual/stdio.texi [BZ #24638]

---
 manual/stdio.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Florian Weimer March 4, 2020, 12:22 p.m. UTC | #1
* Girish Joshi:

> From 7f69eae716feb76474975fbf23d48e975019a424 Mon Sep 17 00:00:00 2001
> From: Girish Joshi <girish946@gmail.com>
> Date: Tue, 3 Mar 2020 00:24:28 +0530
> Subject: [PATCH] [PATCH] Fixed typo in the example for parse_printf_format()
>  in manual/stdio.texi [BZ #24638]
>
> ---
>  manual/stdio.texi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/manual/stdio.texi b/manual/stdio.texi
> index 8051603321..c48e3e692f 100644
> --- a/manual/stdio.texi
> +++ b/manual/stdio.texi
> @@ -2880,7 +2880,7 @@ validate_args (char *format, int nargs, OBJECT *args)
>       @r{length of the string.}  */
>
>    argtypes = (int *) alloca (strlen (format) / 2 * sizeof (int));
> -  nwanted = parse_printf_format (string, nelts, argtypes);
> +  nwanted = parse_printf_format (format, nargs, argtypes);
>
>    /* @r{Check the number of arguments.}  */
>    if (nwanted > nargs)

Thanks.  I've shortened the commit message a bit and pushed this for
you.

Do you want to fix the other issue as well?  The missing declaration of
the variable i, and the incorrect argument list for the error function?

Florian
  
Girish Joshi March 4, 2020, 2:45 p.m. UTC | #2
Thanks Florian,

> Do you want to fix the other issue as well?  The missing declaration of
> the variable i, and the incorrect argument list for the error function?

Sure. I'll be happy to do that.
Could you please provide some pointers?

Girish Joshi.
  
Florian Weimer March 6, 2020, 10:02 p.m. UTC | #3
* Girish Joshi:

> Thanks Florian,
>
>> Do you want to fix the other issue as well?  The missing declaration of
>> the variable i, and the incorrect argument list for the error function?
>
> Sure. I'll be happy to do that.
> Could you please provide some pointers?

I would suggest to try to get the example to compile.  You will have to
supply a fake OBJECT type and the other stubbed-out things, but after
that, some compilation errors remain, and we should fix those.

Thanks,
Florian
  
Girish Joshi March 9, 2020, 12:22 p.m. UTC | #4
Thanks Florian,

>> Do you want to fix the other issue as well?  The missing declaration of
>> the variable i, and the incorrect argument list for the error function?

Following is the patch for this.

>From c6035dc2cadee6088a8697b4263657dc350d4e36 Mon Sep 17 00:00:00 2001
From: Girish Joshi <girish946@gmail.com>
Date: Mon, 9 Mar 2020 17:04:27 +0530
Subject: [PATCH] manual: Fix example for parse_printf_format in stdio.texi.

Added the missing declaration of variable i and argument list
for error () function corrected.
---
 manual/stdio.texi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/manual/stdio.texi b/manual/stdio.texi
index c48e3e692f..7d0e51c504 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2885,12 +2885,13 @@ validate_args (char *format, int nargs, OBJECT *args)
   /* @r{Check the number of arguments.}  */
   if (nwanted > nargs)
     @{
-      error ("too few arguments (at least %d required)", nwanted);
+      error (0, 0, "too few arguments (at least %d required)", nwanted);
       return 0;
     @}

   /* @r{Check the C type wanted for each argument}
      @r{and see if the object given is suitable.}  */
+  int i;
   for (i = 0; i < nwanted; i++)
     @{
       int wanted;
@@ -2917,7 +2918,7 @@ validate_args (char *format, int nargs, OBJECT *args)
       @}
       if (TYPE (args[i]) != wanted)
     @{
-      error ("type mismatch for arg number %d", i);
+      error (0, 0, "type mismatch for arg number %d", i);
       return 0;
     @}
     @}
  
Florian Weimer March 9, 2020, 12:27 p.m. UTC | #5
* Girish Joshi:

>    /* @r{Check the C type wanted for each argument}
>       @r{and see if the object given is suitable.}  */
> +  int i;
>    for (i = 0; i < nwanted; i++)

Please move the declaration of i into the for statement or to the
start of the function.
  
Girish Joshi March 9, 2020, 12:35 p.m. UTC | #6
On Mon, Mar 9, 2020 at 5:58 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * Girish Joshi:
>
> >    /* @r{Check the C type wanted for each argument}
> >       @r{and see if the object given is suitable.}  */
> > +  int i;
> >    for (i = 0; i < nwanted; i++)
>
> Please move the declaration of i into the for statement or to the
> start of the function.

My bad. Corrected that.

>From b1b57db94504879d5249bace204a03917869b50e Mon Sep 17 00:00:00 2001
From: Girish Joshi <girish946@gmail.com>
Date: Mon, 9 Mar 2020 17:04:27 +0530
Subject: [PATCH] manual: Fix example for parse_printf_format in stdio.texi.

Added the missing declaration of variable i and argument list
for error () function corrected.
---
 manual/stdio.texi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/manual/stdio.texi b/manual/stdio.texi
index c48e3e692f..ada425c3c1 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2873,6 +2873,7 @@ validate_args (char *format, int nargs, OBJECT *args)
 @{
   int *argtypes;
   int nwanted;
+  int i;

   /* @r{Get the information about the arguments.}
      @r{Each conversion specification must be at least two characters}
@@ -2885,7 +2886,7 @@ validate_args (char *format, int nargs, OBJECT *args)
   /* @r{Check the number of arguments.}  */
   if (nwanted > nargs)
     @{
-      error ("too few arguments (at least %d required)", nwanted);
+      error (0, 0, "too few arguments (at least %d required)", nwanted);
       return 0;
     @}

@@ -2917,7 +2918,7 @@ validate_args (char *format, int nargs, OBJECT *args)
       @}
       if (TYPE (args[i]) != wanted)
     @{
-      error ("type mismatch for arg number %d", i);
+      error (0, 0, "type mismatch for arg number %d", i);
       return 0;
     @}
     @}
  

Patch

diff --git a/manual/stdio.texi b/manual/stdio.texi
index 8051603321..c48e3e692f 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2880,7 +2880,7 @@  validate_args (char *format, int nargs, OBJECT *args)
      @r{length of the string.}  */

   argtypes = (int *) alloca (strlen (format) / 2 * sizeof (int));
-  nwanted = parse_printf_format (string, nelts, argtypes);
+  nwanted = parse_printf_format (format, nargs, argtypes);

   /* @r{Check the number of arguments.}  */
   if (nwanted > nargs)