vcscanf: add floating point number scanner case

Handle all the documented format specifiers.
Exit with error if given a length modifier other than "l".
Skip spaces, initialize the buffer and then begin parsing.

References:

https://en.cppreference.com/w/c/io/fscanfî1;129A
This commit is contained in:
Matheus Afonso Martins Moreira 2023-11-02 06:20:20 -03:00
parent c8e941bb79
commit ec2b2720f5

View file

@ -225,6 +225,27 @@ int __vcscanf(int callback(void *), //
base = 10;
}
goto DecodeNumber;
case 'a':
case 'A':
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G': // floating point number
if (!(charbytes == sizeof(char) || charbytes == sizeof(wchar_t))) {
items = -1;
goto Done;
}
while (isspace(c)) {
c = READ;
}
bufsize = BUFFER_GROW;
buf = malloc(bufsize);
bufcur = 0;
buf[bufcur++] = c;
buf[bufcur] = '\0';
goto ConsumeFloatingPointNumber;
default:
items = einval();
goto Done;