about summary refs log tree commit diff
path: root/stdio-common/vfscanf-internal.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/vfscanf-internal.c')
-rw-r--r--stdio-common/vfscanf-internal.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c
index a3ebf63554..bfb9baa21a 100644
--- a/stdio-common/vfscanf-internal.c
+++ b/stdio-common/vfscanf-internal.c
@@ -1381,6 +1381,10 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
 	  base = 8;
 	  goto number;
 
+	case L_('b'):	/* Binary integer.  */
+	  base = 2;
+	  goto number;
+
 	case L_('u'):	/* Unsigned decimal integer.  */
 	  base = 10;
 	  goto number;
@@ -1428,10 +1432,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
 		      c = inchar ();
 		    }
 		}
-	      else if ((mode_flags & SCANF_ISOC23_BIN_CST) != 0
-		       && base == 0
-		       && width != 0
-		       && TOLOWER (c) == L_('b'))
+	      else if (width != 0
+		       && TOLOWER (c) == L_('b')
+		       && (base == 2
+			   || ((mode_flags & SCANF_ISOC23_BIN_CST) != 0
+			       && base == 0)))
 		{
 		  base = 2;
 		  if (width > 0)