From cca3d5907ce77f4fd7e3e88f785a07bec7116d03 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 3 Apr 2009 15:26:27 -0700 Subject: [PATCH] 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 e987162cb94e2fa16a824a44d00f4db2c62d91fa) --- vpi/sys_scanf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index 0dd3c9549..f500aa585 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -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';