Save the time format suffix string.
In case of a vhdlpp-specific () call, the timeformat suffix string was overridden, therefore it has to be restored to the previous value after the call.
This commit is contained in:
parent
139c4154c3
commit
71084109f6
|
|
@ -642,7 +642,7 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus,
|
||||||
vpi_printf("WARNING: %s:%d: incompatible value for %s%s.\n",
|
vpi_printf("WARNING: %s:%d: incompatible value for %s%s.\n",
|
||||||
info->filename, info->lineno, info->name, fmtb);
|
info->filename, info->lineno, info->name, fmtb);
|
||||||
} else {
|
} else {
|
||||||
char *tbuf;
|
char *tbuf, *prev_suff;
|
||||||
PLI_INT32 time_units = vpi_get(vpiTimeUnit, info->scope);
|
PLI_INT32 time_units = vpi_get(vpiTimeUnit, info->scope);
|
||||||
|
|
||||||
if (plus != 0) {
|
if (plus != 0) {
|
||||||
|
|
@ -650,7 +650,10 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus,
|
||||||
* It is needed by vhdlpp to correctly implement time'image(). */
|
* It is needed by vhdlpp to correctly implement time'image(). */
|
||||||
PLI_INT32 time_prec = vpi_get(vpiTimePrecision, info->scope);
|
PLI_INT32 time_prec = vpi_get(vpiTimePrecision, info->scope);
|
||||||
|
|
||||||
free(timeformat_info.suff);
|
/* We are about to override the suffix string set with $timeformat(),
|
||||||
|
* therefore we need to restore it after the call. */
|
||||||
|
prev_suff = timeformat_info.suff;
|
||||||
|
|
||||||
if(time_units < -12)
|
if(time_units < -12)
|
||||||
timeformat_info.suff = strdup(" fs");
|
timeformat_info.suff = strdup(" fs");
|
||||||
else if(time_units < -9)
|
else if(time_units < -9)
|
||||||
|
|
@ -688,6 +691,13 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus,
|
||||||
cp = tbuf;
|
cp = tbuf;
|
||||||
swidth = strlen(tbuf);
|
swidth = strlen(tbuf);
|
||||||
|
|
||||||
|
if(plus != 0) {
|
||||||
|
/* Restore the previous suffix string, overridden by
|
||||||
|
* a vhdlpp-specific $sformatf() call. */
|
||||||
|
free(timeformat_info.suff);
|
||||||
|
timeformat_info.suff = prev_suff;
|
||||||
|
}
|
||||||
|
|
||||||
if (ld_zero == 1) {
|
if (ld_zero == 1) {
|
||||||
/* No leading zeros are created by this conversion so just make
|
/* No leading zeros are created by this conversion so just make
|
||||||
* the width 0 for this case. */
|
* the width 0 for this case. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue