From c71e930ffa3ca7741d43654f8b20dcff57299236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20W=C3=A4chtler?= Date: Mon, 28 Jul 2008 20:50:00 +0200 Subject: [PATCH] $fscanf("%s"): accept '-' and '_' chars. --- vpi/sys_scanf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index fb58ff919..aff54193f 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -379,12 +379,14 @@ static int scan_format(vpiHandle sys, struct byte_source*src, vpiHandle argv) match_fail = 1; ch = byte_getc(src); - while (isdigit(ch)) { + while (isdigit(ch) || ch == '_' || (value == 0 && ch == '-')) { match_fail = 0; - tmp[value++] = ch; - tmp = realloc(tmp, value+1); - tmp[value] = 0; - ch = byte_getc(src); + if (ch != '_') { + tmp[value++] = ch; + tmp = realloc(tmp, value+1); + tmp[value] = 0; + ch = byte_getc(src); + } } byte_ungetc(src, ch);