Blame src/regression/scanf-bytes-consumed.c

Szabolcs Nagy cfa23c
// commit: 5efc6af4ebb9d50eb978d0338835544fdfea0396 2011-04-25
Szabolcs Nagy cfa23c
// scanf misreports bytes consumed when EOF is hit (or null for sscanf)
Szabolcs Nagy cfa23c
#include <stdio.h>
Szabolcs Nagy cfa23c
#include "test.h"
Szabolcs Nagy cfa23c
Szabolcs Nagy cfa23c
int main(void)
Szabolcs Nagy cfa23c
{
Szabolcs Nagy cfa23c
	char buf[] = { 'a', 'a', 0 };
Szabolcs Nagy cfa23c
	char dest[3];
Szabolcs Nagy cfa23c
	int read_count;
Szabolcs Nagy cfa23c
	int n;
Szabolcs Nagy cfa23c
Szabolcs Nagy cfa23c
	n = sscanf(buf, "%s%n", dest, &read_count);
Szabolcs Nagy cfa23c
	if(n != 1)
Szabolcs Nagy cfa23c
		t_error("sscanf matched 1 input items but returned %d\n", n);
Szabolcs Nagy cfa23c
	if(read_count != 2)
Szabolcs Nagy cfa23c
		t_error("sscanf consumed 2 bytes but reported %d\n", read_count);
Szabolcs Nagy cfa23c
	return t_status;
Szabolcs Nagy cfa23c
}