[PATCH 3/6] Make fflush (NULL) flush input files (bug 32369)

Joseph Myers josmyers@redhat.com
Wed Jan 15 19:24:48 GMT 2025


On Wed, 15 Jan 2025, DJ Delorie wrote:

> I was surprised at the way fwprintf worked, perhaps a comment explaining
> that we expect the wide result to be the same as the narrow result
> because we expect the wide chars to be converted to multibyte chars?

That's simply how all the wide I/O functions work.

As remarked for patch 1, the file position indicator is unspecified after 
ungetwc (hence no tests using ungetwc - tests in this series only use wide 
wide I/O in cases where no pushback is involved - and no special checks 
needed in general for the combination of wide I/O and pushback).

> Shouldn't this be sizeof(wchar_t), not 1 ?  /me tests... no,
> fwprintf(L"abc") writes three narrow chars to the file!  Needs comment?
> Needs specific locale?  Are there any locales where we write this out as
> a wide char and not a multi-byte char?

This test is using the C locale; since it's only using ASCII characters, 
no specific locale is needed.  A null character can't be part of another 
multibyte character, which means that UTF-16 and UTF-32 are not possible 
locale multibyte encodings to write out to the file.

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-alpha mailing list