Skip leading space for some codes in scanf routines.
Most conversion codes in the scanf routines are supposed to
skip leading space. This patch adds that functionality.
(cherry picked from commit e987162cb9)
This commit is contained in:
parent
ec809c9137
commit
cca3d5907c
|
|
@ -76,6 +76,8 @@ static double float_string(struct byte_source*src)
|
|||
double sign_flag = 1.0;
|
||||
|
||||
ch = byte_getc(src);
|
||||
/* Skip leading space. */
|
||||
while (isspace(ch)) ch = byte_getc(src);
|
||||
|
||||
if (ch == '+') {
|
||||
sign_flag = 1.0;
|
||||
|
|
@ -186,6 +188,9 @@ static int scan_format_string(struct byte_source*src, vpiHandle arg)
|
|||
*tmp = 0;
|
||||
|
||||
ch = byte_getc(src);
|
||||
/* Skip leading space. */
|
||||
while (isspace(ch)) ch = byte_getc(src);
|
||||
|
||||
while (!isspace(ch)) {
|
||||
if (ch == EOF) break;
|
||||
|
||||
|
|
@ -316,6 +321,9 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
|
|||
match_fail = 1;
|
||||
|
||||
ch = byte_getc(src);
|
||||
/* Skip leading space. */
|
||||
while (isspace(ch)) ch = byte_getc(src);
|
||||
|
||||
while (strchr("01xXzZ?_", ch)) {
|
||||
match_fail = 0;
|
||||
if (ch == '?') ch = 'x';
|
||||
|
|
@ -365,6 +373,9 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
|
|||
match_fail = 1;
|
||||
|
||||
ch = byte_getc(src);
|
||||
/* Skip leading space. */
|
||||
while (isspace(ch)) ch = byte_getc(src);
|
||||
|
||||
while (isdigit(ch) || ch == '_' || (value == 0 && ch == '-')) {
|
||||
match_fail = 0;
|
||||
if (ch != '_') {
|
||||
|
|
@ -411,6 +422,9 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
|
|||
tmp[0] = 0;
|
||||
|
||||
ch = byte_getc(src);
|
||||
/* Skip leading space. */
|
||||
while (isspace(ch)) ch = byte_getc(src);
|
||||
|
||||
while (strchr("0123456789abcdefABCDEFxXzZ?_", ch)) {
|
||||
match_fail = 0;
|
||||
if (ch == '?') ch = 'x';
|
||||
|
|
@ -447,6 +461,9 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
|
|||
tmp[0] = 0;
|
||||
|
||||
ch = byte_getc(src);
|
||||
/* Skip leading space. */
|
||||
while (isspace(ch)) ch = byte_getc(src);
|
||||
|
||||
while (strchr("01234567xXzZ?_", ch)) {
|
||||
match_fail = 0;
|
||||
if (ch == '?') ch = 'x';
|
||||
|
|
|
|||
Loading…
Reference in New Issue