about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/printf-parsemb.c7
-rw-r--r--stdio-common/printf_fphex.c2
-rw-r--r--stdio-common/vfprintf.c7
-rw-r--r--stdio-common/vfscanf.c143
4 files changed, 68 insertions, 91 deletions
diff --git a/stdio-common/printf-parsemb.c b/stdio-common/printf-parsemb.c
index 24909b2b04..ac281b60fa 100644
--- a/stdio-common/printf-parsemb.c
+++ b/stdio-common/printf-parsemb.c
@@ -62,7 +62,6 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
 		    struct printf_spec *spec, size_t *max_ref_arg)
 #endif
 {
-  unsigned int n;
   size_t nargs = 0;
 
   /* Skip the '%'.  */
@@ -85,7 +84,7 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
     {
       const UCHAR_T *begin = format;
 
-      n = read_int (&format);
+      int n = read_int (&format);
 
       if (n != 0 && *format == L_('$'))
 	/* Is positional parameter.  */
@@ -161,7 +160,7 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
       if (ISDIGIT (*format))
 	{
 	  /* The width argument might be found in a positional parameter.  */
-	  n = read_int (&format);
+	  int n = read_int (&format);
 
 	  if (n != 0 && *format == L_('$'))
 	    {
@@ -204,7 +203,7 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
 
 	  if (ISDIGIT (*format))
 	    {
-	      n = read_int (&format);
+	      int n = read_int (&format);
 
 	      if (n != 0 && *format == L_('$'))
 		{
diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c
index 4599867b3f..78733a7778 100644
--- a/stdio-common/printf_fphex.c
+++ b/stdio-common/printf_fphex.c
@@ -240,8 +240,6 @@ __printf_fphex (FILE *fp,
 
   if (special)
     {
-      int width = info->width;
-
       if (negative || info->showsign || info->space)
 	--width;
       width -= 3;
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index c4ff8334b2..469c75616b 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1965,7 +1965,6 @@ do_positional:
 	while (1)
 	  {
 	    extern printf_function **__printf_function_table;
-	    int function_done;
 
 	    if (spec <= UCHAR_MAX
 		&& __printf_function_table != NULL
@@ -1980,7 +1979,7 @@ do_positional:
 		  ptr[i] = &args_value[specs[nspecs_done].data_arg + i];
 
 		/* Call the function.  */
-		function_done = __printf_function_table[(size_t) spec]
+		int function_done = __printf_function_table[(size_t) spec]
 		  (s, &specs[nspecs_done].info, ptr);
 
 		if (function_done != -2)
@@ -2017,8 +2016,8 @@ do_positional:
 		ptr[i] = &args_value[specs[nspecs_done].data_arg + i];
 
 	      /* Call the function.  */
-	      function_done = printf_unknown (s, &specs[nspecs_done].info,
-					      ptr);
+	      int function_done = printf_unknown (s, &specs[nspecs_done].info,
+                                                  ptr);
 
 	      /* If an error occurred we don't have information about #
 		 of chars.  */
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index e0d224530c..20b9aa8ace 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -82,7 +82,7 @@
 # define ungetc_not_eof(c, s)	((void) (--read_in,			      \
 					 _IO_sputbackwc (s, c)))
 # define inchar()	(c == WEOF ? ((errno = inchar_errno), WEOF)	      \
-			 : ((c = _IO_getwc_unlocked (s)),		      \
+			 : ((c = _IO_getwc_unlocked (stream)),		      \
 			    (void) (c != WEOF				      \
 				    ? ++read_in				      \
 				    : (size_t) (inchar_errno = errno)), c))
@@ -92,7 +92,7 @@
 # define ISDIGIT(Ch)	  iswdigit (Ch)
 # define ISXDIGIT(Ch)	  iswxdigit (Ch)
 # define TOLOWER(Ch)	  towlower (Ch)
-# define ORIENT	  if (_IO_fwide (s, 1) != 1) return WEOF
+# define ORIENT	  if (_IO_fwide (stream, 1) != 1) return WEOF
 # define __strtoll_internal	__wcstoll_internal
 # define __strtoull_internal	__wcstoull_internal
 # define __strtol_internal	__wcstol_internal
@@ -114,7 +114,7 @@
 # define ungetc_not_eof(c, s)	((void) (--read_in,			      \
 					 _IO_sputbackc (s, (unsigned char) c)))
 # define inchar()	(c == EOF ? ((errno = inchar_errno), EOF)	      \
-			 : ((c = _IO_getc_unlocked (s)),		      \
+			 : ((c = _IO_getc_unlocked (stream)),		      \
 			    (void) (c != EOF				      \
 				    ? ++read_in				      \
 				    : (size_t) (inchar_errno = errno)), c))
@@ -123,9 +123,9 @@
 # define ISDIGIT(Ch)	  __isdigit_l (Ch, loc)
 # define ISXDIGIT(Ch)	  __isxdigit_l (Ch, loc)
 # define TOLOWER(Ch)	  __tolower_l ((unsigned char) (Ch), loc)
-# define ORIENT	  if (_IO_vtable_offset (s) == 0			      \
-			      && _IO_fwide (s, -1) != -1)		      \
-			    return EOF
+# define ORIENT	  if (_IO_vtable_offset (stream) == 0			      \
+                      && _IO_fwide (stream, -1) != -1)			      \
+		    return EOF
 
 # define L_(Str)	Str
 # define CHAR_T		char
@@ -192,16 +192,20 @@ struct ptrs_to_free
   char **ptrs[32];
 };
 
+#ifndef __va_copy
+# define __va_copy(dst, src)	(dst) = (va_list) (src)
+#endif
+
 /* Read formatted input from S according to the format string
    FORMAT, using the argument list in ARG.
    Return the number of assignments made, or -1 for an input error.  */
 #ifdef COMPILE_WSCANF
 int
-_IO_vfwscanf (_IO_FILE *s, const wchar_t *format, _IO_va_list argptr,
+_IO_vfwscanf (_IO_FILE *stream, const wchar_t *format, _IO_va_list argptr,
 	      int *errp)
 #else
 int
-_IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
+_IO_vfscanf_internal (_IO_FILE *stream, const char *format, _IO_va_list argptr,
 		      int *errp)
 #endif
 {
@@ -303,17 +307,13 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
     }									    \
   while (0)
 
-#ifdef __va_copy
   __va_copy (arg, argptr);
-#else
-  arg = (va_list) argptr;
-#endif
 
 #ifdef ORIENT
   ORIENT;
 #endif
 
-  ARGCHECK (s, format);
+  ARGCHECK (stream, format);
 
  {
 #ifndef COMPILE_WSCANF
@@ -337,7 +337,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
  }
 
   /* Lock the stream.  */
-  LOCK_STREAM (s);
+  LOCK_STREAM (stream);
 
 
 #ifndef COMPILE_WSCANF
@@ -352,35 +352,14 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
       /* Extract the next argument, which is of type TYPE.
 	 For a %N$... spec, this is the Nth argument from the beginning;
 	 otherwise it is the next argument after the state now in ARG.  */
-#ifdef __va_copy
-# define ARG(type)	(argpos == 0 ? va_arg (arg, type) :		      \
+#define ARG(type)	(argpos == 0 ? va_arg (arg, type) :		      \
 			 ({ unsigned int pos = argpos;			      \
-			    va_list arg;				      \
-			    __va_copy (arg, argptr);			      \
+			    va_list argcopy;				      \
+			    __va_copy (argcopy, argptr);		      \
 			    while (--pos > 0)				      \
-			      (void) va_arg (arg, void *);		      \
-			    va_arg (arg, type);				      \
+			      (void) va_arg (argcopy, void *);		      \
+			    va_arg (argcopy, type);			      \
 			  }))
-#else
-# if 0
-      /* XXX Possible optimization.  */
-#  define ARG(type)	(argpos == 0 ? va_arg (arg, type) :		      \
-			 ({ va_list arg = (va_list) argptr;		      \
-			    arg = (va_list) ((char *) arg		      \
-					     + (argpos - 1)		      \
-					     * __va_rounded_size (void *));   \
-			    va_arg (arg, type);				      \
-			 }))
-# else
-#  define ARG(type)	(argpos == 0 ? va_arg (arg, type) :		      \
-			 ({ unsigned int pos = argpos;			      \
-			    va_list arg = (va_list) argptr;		      \
-			    while (--pos > 0)				      \
-			      (void) va_arg (arg, void *);		      \
-			    va_arg (arg, type);				      \
-			  }))
-# endif
-#endif
 
 #ifndef COMPILE_WSCANF
       if (!isascii ((unsigned char) *f))
@@ -396,7 +375,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		    input_error ();
 		  else if (c != (unsigned char) *f++)
 		    {
-		      ungetc_not_eof (c, s);
+		      ungetc_not_eof (c, stream);
 		      conv_error ();
 		    }
 		}
@@ -435,7 +414,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 
 	  if (__glibc_unlikely (c != fc))
 	    {
-	      ungetc (c, s);
+	      ungetc (c, stream);
 	      conv_error ();
 	    }
 
@@ -539,7 +518,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	    }
 	  /* In __isoc99_*scanf %as, %aS and %a[ extension is not
 	     supported at all.  */
-	  if (s->_flags2 & _IO_FLAGS2_SCANF_STD)
+	  if (stream->_flags2 & _IO_FLAGS2_SCANF_STD)
 	    {
 	      --f;
 	      break;
@@ -602,7 +581,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      input_error ();
 	  while (ISSPACE (c));
 	  __set_errno (save_errno);
-	  ungetc (c, s);
+	  ungetc (c, stream);
 	  skip_space = 0;
 	}
 
@@ -614,7 +593,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	    input_error ();
 	  if (__glibc_unlikely (c != fc))
 	    {
-	      ungetc_not_eof (c, s);
+	      ungetc_not_eof (c, stream);
 	      conv_error ();
 	    }
 	  break;
@@ -1002,7 +981,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		{
 		  if (ISSPACE (c))
 		    {
-		      ungetc_not_eof (c, s);
+		      ungetc_not_eof (c, stream);
 		      break;
 		    }
 
@@ -1192,7 +1171,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      {
 		if (ISSPACE (c))
 		  {
-		    ungetc_not_eof (c, s);
+		    ungetc_not_eof (c, stream);
 		    break;
 		  }
 
@@ -1459,12 +1438,12 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		      wint_t extra_wcdigit = __towctrans (L'0' + n, map);
 
 		      /*  Convert it to multibyte representation.  */
-		      mbstate_t state;
-		      memset (&state, '\0', sizeof (state));
+		      mbstate_t dstate;
+		      memset (&dstate, '\0', sizeof (dstate));
 
 		      char extra_mbdigit[MB_LEN_MAX];
 		      size_t mblen
-			= __wcrtomb (extra_mbdigit, extra_wcdigit, &state);
+			= __wcrtomb (extra_mbdigit, extra_wcdigit, &dstate);
 
 		      if (mblen == (size_t) -1)
 			{
@@ -1554,9 +1533,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		      /* We are pushing all read characters back.  */
 		      if (cmpp > mbdigits[n])
 			{
-			  ungetc (c, s);
+			  ungetc (c, stream);
 			  while (--cmpp > mbdigits[n])
-			    ungetc_not_eof ((unsigned char) *cmpp, s);
+			    ungetc_not_eof ((unsigned char) *cmpp, stream);
 			  c = (unsigned char) *cmpp;
 			}
 
@@ -1606,9 +1585,10 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			      /* We are pushing all read characters back.  */
 			      if (cmpp > mbdigits[n])
 				{
-				  ungetc (c, s);
+				  ungetc (c, stream);
 				  while (--cmpp > mbdigits[n])
-				    ungetc_not_eof ((unsigned char) *cmpp, s);
+				    ungetc_not_eof ((unsigned char) *cmpp,
+                                                    stream);
 				  c = (unsigned char) *cmpp;
 				}
 
@@ -1658,9 +1638,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			  if (cmpp > thousands)
 			    {
 			      wpsize -= cmpp - thousands;
-			      ungetc (c, s);
+			      ungetc (c, stream);
 			      while (--cmpp > thousands)
-				ungetc_not_eof ((unsigned char) *cmpp, s);
+				ungetc_not_eof ((unsigned char) *cmpp, stream);
 			      c = (unsigned char) *cmpp;
 			    }
 			  break;
@@ -1724,9 +1704,10 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			    if (cmpp > thousands)
 			      {
 				wpsize -= cmpp - thousands;
-				ungetc (c, s);
+				ungetc (c, stream);
 				while (--cmpp > thousands)
-				  ungetc_not_eof ((unsigned char) *cmpp, s);
+				  ungetc_not_eof ((unsigned char) *cmpp,
+                                                  stream);
 				c = (unsigned char) *cmpp;
 			      }
 			    break;
@@ -1770,14 +1751,14 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		{
 		  /* The last read character is not part of the number
 		     anymore.  */
-		  ungetc (c, s);
+		  ungetc (c, stream);
 
 		  conv_error ();
 		}
 	    }
 	  else
 	    /* The just read character is not part of the number anymore.  */
-	    ungetc (c, s);
+	    ungetc (c, stream);
 
 	  /* Convert the number.  */
 	  ADDW (L_('\0'));
@@ -1940,7 +1921,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		    }
 		  else
 		    /* Never mind.  */
-		    ungetc (c, s);
+		    ungetc (c, stream);
 		}
 	      goto scan_float;
 	    }
@@ -2005,7 +1986,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		    {
 		      /* The last read character is not part of the number
 			 anymore.  */
-		      ungetc (c, s);
+		      ungetc (c, stream);
 		      break;
 		    }
 #else
@@ -2074,7 +2055,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			{
 			  /* The last read character is not part of the number
 			     anymore.  */
-			  ungetc (c, s);
+			  ungetc (c, stream);
 			  break;
 			}
 		    }
@@ -2117,11 +2098,11 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 #else
 	      char mbdigits[12][MB_LEN_MAX + 1];
 
-	      mbstate_t state;
-	      memset (&state, '\0', sizeof (state));
+	      mbstate_t dstate;
+	      memset (&dstate, '\0', sizeof (dstate));
 
 	      bool match_so_far = wpsize == 0;
-	      size_t mblen = __wcrtomb (mbdigits[11], wcdigits[11], &state);
+	      size_t mblen = __wcrtomb (mbdigits[11], wcdigits[11], &dstate);
 	      if (mblen != (size_t) -1)
 		{
 		  mbdigits[11][mblen] = '\0';
@@ -2161,8 +2142,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 #ifndef COMPILE_WSCANF
 		      memset (&state, '\0', sizeof (state));
 
-		      size_t mblen = __wcrtomb (mbdigits[n], wcdigits[n],
-						&state);
+                      mblen = __wcrtomb (mbdigits[n], wcdigits[n], &state);
 		      if (mblen == (size_t) -1)
 			{
 			  if (n == 10)
@@ -2274,9 +2254,10 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			      /* We are pushing all read characters back.  */
 			      if (cmpp > mbdigits[n])
 				{
-				  ungetc (c, s);
+				  ungetc (c, stream);
 				  while (--cmpp > mbdigits[n])
-				    ungetc_not_eof ((unsigned char) *cmpp, s);
+				    ungetc_not_eof ((unsigned char) *cmpp,
+                                                    stream);
 				  c = (unsigned char) *cmpp;
 				}
 #endif
@@ -2286,7 +2267,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			    {
 			      /* The last read character is not part
 				 of the number anymore.  */
-			      ungetc (c, s);
+			      ungetc (c, stream);
 			      break;
 			    }
 			}
@@ -2448,7 +2429,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			    {
 			      /* The current character is not in the
 				 scanset.  */
-			      ungetc (c, s);
+			      ungetc (c, stream);
 			      goto out;
 			    }
 
@@ -2460,7 +2441,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			    break;
 			  if ((wint_t) *runp == c && not_in)
 			    {
-			      ungetc (c, s);
+			      ungetc (c, stream);
 			      goto out;
 			    }
 
@@ -2470,7 +2451,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 
 		  if (runp == twend && !not_in)
 		    {
-		      ungetc (c, s);
+		      ungetc (c, stream);
 		      goto out;
 		    }
 
@@ -2539,7 +2520,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		{
 		  if (wp[c] == not_in)
 		    {
-		      ungetc_not_eof (c, s);
+		      ungetc_not_eof (c, stream);
 		      break;
 		    }
 
@@ -2680,7 +2661,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			    {
 			      /* The current character is not in the
 				 scanset.  */
-			      ungetc (c, s);
+			      ungetc (c, stream);
 			      goto out2;
 			    }
 
@@ -2692,7 +2673,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			    break;
 			  if ((wint_t) *runp == c && not_in)
 			    {
-			      ungetc (c, s);
+			      ungetc (c, stream);
 			      goto out2;
 			    }
 
@@ -2702,7 +2683,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 
 		  if (runp == twend && !not_in)
 		    {
-		      ungetc (c, s);
+		      ungetc (c, stream);
 		      goto out2;
 		    }
 
@@ -2767,7 +2748,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		{
 		  if (wp[c] == not_in)
 		    {
-		      ungetc_not_eof (c, s);
+		      ungetc_not_eof (c, stream);
 		      break;
 		    }
 
@@ -2898,12 +2879,12 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
       do
 	c = inchar ();
       while (ISSPACE (c));
-      ungetc (c, s);
+      ungetc (c, stream);
     }
 
  errout:
   /* Unlock stream.  */
-  UNLOCK_STREAM (s);
+  UNLOCK_STREAM (stream);
 
   if (use_malloc)
     free (wp);