mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 19:30:29 +00:00
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:
parent
c8e941bb79
commit
ec2b2720f5
1 changed files with 21 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue