From 8b1769146658f87a0cce3f7c1c8d9358400a1be6 Mon Sep 17 00:00:00 2001 From: "Stephen J. Kiernan" Date: Wed, 6 Dec 2017 21:12:24 +0000 Subject: [PATCH] The function fwscanf() return value is wrong when encountering an early matching failure. According to the Open Group documentation for fwscanf: "Upon successful completion, these functions shall return the number of successfully matched and assigned input items; this number can be zero in the event of an early matching failure." Without this change, fwscanf would return EOF in the case of an early matching failure, instead of the proper return value of 0. This change aligns fwscanf(3) with the implementation in fscanf(3). PR: 202240 Submitted by: rajendra.sy@gmail.com Reviewed by: jhb, cem Approved by: sjg (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D13288 --- lib/libc/stdio/vfwscanf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c index fb9c0a961fd7..fbd3a8ad747a 100644 --- a/lib/libc/stdio/vfwscanf.c +++ b/lib/libc/stdio/vfwscanf.c @@ -494,7 +494,7 @@ literal: goto input_failure; if (wi != c) { __ungetwc(wi, fp, locale); - goto input_failure; + goto match_failure; } nread++; continue;