mirror of
https://sourceware.org/git/glibc.git
synced 2025-10-26 00:57:39 +03:00
Reject invalid formatted scanf character data with the 'c' conversion where there is not enough input available to satisfy the field width requested. It is required by ISO C that this conversion matches a sequence of characters of exactly the number specified by the field width and it is also already documented as such in our own manual: "It reads precisely the next N characters, and fails if it cannot get that many." Currently a matching success is instead incorrectly produced where the EOF condition is encountered before the required number of characters has been retrieved, and the characters actually obtained are stored in the buffer provided. Add test cases accordingly and remove placeholders from 'c' conversion input data for the existing scanf tests. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
43 lines
1.0 KiB
Plaintext
43 lines
1.0 KiB
Plaintext
%c:The:1:1:T:
|
|
%*c:The:0:1:
|
|
%c:quick:1:1:q:
|
|
%*c:quick:0:1:
|
|
%c:brown fox:1:1:b:
|
|
%*c:brown fox:0:1:
|
|
%c:jumps over the lazy dog:1:1:j:
|
|
%*c:jumps over the lazy dog:0:1:
|
|
%1c:The:1:1:T:
|
|
%*1c:The:0:1:
|
|
%1c:quick:1:1:q:
|
|
%*1c:quick:0:1:
|
|
%1c:brown fox:1:1:b:
|
|
%*1c:brown fox:0:1:
|
|
%1c:jumps over the lazy dog:1:1:j:
|
|
%*1c:jumps over the lazy dog:0:1:
|
|
%2c:The:1:2:Th:
|
|
%*2c:The:0:2:
|
|
%2c:quick:1:2:qu:
|
|
%*2c:quick:0:2:
|
|
%2c:brown fox:1:2:br:
|
|
%*2c:brown fox:0:2:
|
|
%2c:jumps over the lazy dog:1:2:ju:
|
|
%*2c:jumps over the lazy dog:0:2:
|
|
%5c:quick:1:5:quick:
|
|
%*5c:quick:0:5:
|
|
%5c:brown fox:1:5:brown:
|
|
%*5c:brown fox:0:5:
|
|
%5c:jumps over the lazy dog:1:5:jumps:
|
|
%*5c:jumps over the lazy dog:0:5:
|
|
%10c:jumps over the lazy dog:1:10:jumps over:
|
|
%*10c:jumps over the lazy dog:0:10:
|
|
%5c: The :1:5: The :
|
|
%*5c: The :0:5:
|
|
%5c: quick :1:5: quic:
|
|
%*5c: quick :0:5:
|
|
%5c: brown fox :1:5: brow:
|
|
%*5c: brown fox :0:5:
|
|
%5c: jumps over the lazy dog :1:5: jump:
|
|
%*5c: jumps over the lazy dog :0:5:
|
|
%25c: jumps over the lazy dog :1:25: jumps over the lazy dog :
|
|
%*25c: jumps over the lazy dog :0:25:
|