From 7aff1adf99e93f90beee9710cc696bc16dc4c8c6 Mon Sep 17 00:00:00 2001 From: "Frederick C. Kurz" Date: Fri, 10 Jul 2015 12:50:39 -0400 Subject: [PATCH] Changes to vpi/sys_display.c First and second areas were changed for "Microsoft Visual Studio Express 2015 RC Web" so that gold files would match. For the third area of change, "Microsoft Visual Studio Express 2015 RC Web" wanted to print 6 zeros after the decimals for the values of 0.0 and -0.0, and then the gold files wouldn't match. --- vpi/sys_display.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 98446b8a1..c6b04df67 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -539,7 +539,14 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus, if (size < 320) size = 320; size += prec; if (size > ini_size) result = realloc(result, size*sizeof(char)); +#if !defined(__GNUC__) + if (isnan(value.value.real)) + sprintf(result, "%s", "nan"); + else + sprintf(result, fmtb+1, value.value.real); +#else sprintf(result, fmtb+1, value.value.real); +#endif size = strlen(result) + 1; } } @@ -947,7 +954,18 @@ static char *get_display(unsigned int *rtnsz, const struct strobe_cb_info *info) } else if (vpi_get(vpiConstType, item) == vpiRealConst) { value.format = vpiRealVal; vpi_get_value(item, &value); +#if !defined(__GNUC__) + if(compatible_flag) + sprintf(buf, "%g", value.value.real); + else { + if(value.value.real == 0.0 || value.value.real == -0.0) + sprintf(buf, "%.05f", value.value.real); + else + sprintf(buf, "%#g", value.value.real); + } +#else sprintf(buf, compatible_flag ? "%g" : "%#g", value.value.real); +#endif result = strdup(buf); width = strlen(result); } else { @@ -992,7 +1010,18 @@ static char *get_display(unsigned int *rtnsz, const struct strobe_cb_info *info) case vpiRealVar: value.format = vpiRealVal; vpi_get_value(item, &value); +#if !defined(__GNUC__) + if (compatible_flag) + sprintf(buf, "%g", value.value.real); + else { + if (value.value.real == 0.0 || value.value.real == -0.0) + sprintf(buf, "%.05f", value.value.real); + else + sprintf(buf, "%#g", value.value.real); + } +#else sprintf(buf, compatible_flag ? "%g" : "%#g", value.value.real); +#endif width = strlen(buf); rtn = realloc(rtn, (size+width)*sizeof(char)); memcpy(rtn+size-1, buf, width);