Fix last change: percents must be literalized

git-svn-id: file://localhost/svn/verilator/trunk/verilator@938 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder 2007-06-14 18:34:08 +00:00
parent 4ba00bd256
commit d6a5c97f3a
5 changed files with 12 additions and 4 deletions

View File

@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Support V2K portlists with "input a,b,...". [Mark Nodine] **** Support V2K portlists with "input a,b,...". [Mark Nodine]
**** Optimize constant $display arguments.
**** Fix Preprocessor dropping some `line directives. [Mark Nodine] **** Fix Preprocessor dropping some `line directives. [Mark Nodine]
* Verilator 3.651 5/22/2007 * Verilator 3.651 5/22/2007

View File

@ -972,7 +972,13 @@ private:
if (argp && argp->castConst()) { // Convert it if (argp && argp->castConst()) { // Convert it
string out = argp->castConst()->num().displayed(fmt); string out = argp->castConst()->num().displayed(fmt);
UINFO(9," DispConst: "<<fmt<<" -> "<<out<<" for "<<argp<<endl); UINFO(9," DispConst: "<<fmt<<" -> "<<out<<" for "<<argp<<endl);
fmt = out; { // fmt = out w/ replace % with %% as it must be literal.
fmt = "";
for (string::iterator pos = out.begin(); pos != out.end(); pos++) {
if (*pos == '%') fmt += '%';
fmt += *pos;
}
}
argp->unlinkFrBack()->deleteTree(); argp->unlinkFrBack()->deleteTree();
} }
argp=nextp; argp=nextp;

View File

@ -24,7 +24,7 @@ execute (
[0] %x=00abc1234567812345678 %0x=abc1234567812345678 %o=012570110642547402215053170 %b=000001010101111000001001000110100010101100111100000010010001101000101011001111000 [0] %x=00abc1234567812345678 %0x=abc1234567812345678 %o=012570110642547402215053170 %b=000001010101111000001001000110100010101100111100000010010001101000101011001111000
[0] %s=! %s= what! %s= hmmm!1234 [0] %s=! %s= what! %s= hmmm!1234
[0] hello, from a very long string. This gets substituted in. [0] hello, from a very long string. Percent %s are literally substituted in.
*-* All Finished *-* *-* All Finished *-*
'), '),
); );

View File

@ -34,7 +34,7 @@ module t;
str2[7:0], str2, str3); str2[7:0], str2, str3);
$display("[%0t] %s%s%s", $time, $display("[%0t] %s%s%s", $time,
"hel", "lo, fr", "om a very long string. This gets substituted in."); "hel", "lo, fr", "om a very long string. Percent %s are literally substituted in.");
// Str check // Str check
`ifndef nc // NC-Verilog 5.3 chokes on this test `ifndef nc // NC-Verilog 5.3 chokes on this test

View File

@ -27,7 +27,7 @@ execute (
[0] %x=00abc1234567812345678 %0x=abc1234567812345678 %o=012570110642547402215053170 %b=000001010101111000001001000110100010101100111100000010010001101000101011001111000 [0] %x=00abc1234567812345678 %0x=abc1234567812345678 %o=012570110642547402215053170 %b=000001010101111000001001000110100010101100111100000010010001101000101011001111000
[0] %s=! %s= what! %s= hmmm!1234 [0] %s=! %s= what! %s= hmmm!1234
[0] hello, from a very long string. This gets substituted in. [0] hello, from a very long string. Percent %s are literally substituted in.
*-* All Finished *-* *-* All Finished *-*
'), '),
); );