fixing: %0b format prints nothing for a 0 input
the following example returns ||. This patch fixes it to return |0|.
module t();
wire [3:0] b;
initial
$monitor("|%0b|", b);
assign b = 0;
endmodule
This commit is contained in:
parent
be158dd45f
commit
c9d2400dd0
|
|
@ -328,7 +328,7 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus,
|
|||
|
||||
if (ld_zero == 1) {
|
||||
/* Strip the leading zeros if a width is not given. */
|
||||
if (width == -1) while (*cp == '0') cp++;
|
||||
if (width == -1) while (*cp == '0' && *(cp+1) != '\0') cp++;
|
||||
/* Pad with leading zeros. */
|
||||
else if (ljust == 0 && (signed)swidth < width) {
|
||||
unsigned pad = (unsigned)width - swidth;
|
||||
|
|
@ -337,7 +337,7 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus,
|
|||
strcpy(cp+pad, value.value.str);
|
||||
free_flag = 1;
|
||||
/* For a left aligned value also strip the leading zeros. */
|
||||
} else if (ljust != 0) while (*cp == '0') cp++;
|
||||
} else if (ljust != 0) while (*cp == '0' && *(cp+1) != '\0') cp++;
|
||||
}
|
||||
|
||||
/* If a width was not given, use a width of zero. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue