Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  IPC::Locker
  Parallel::Forker
  Voneline
General Info
  Papers

0001-Fix-for-issue-1444.patch

Kanad Kanhere, 05/29/2019 04:00 PM

Download (8.6 KB)

View differences:

src/V3EmitXml.cpp
59 59
	// Don't use to quote a filename for #include - #include doesn't \ escape.
60 60
	// Duplicate in V3File - here so we can print to string
61 61
	putsNoTracking("\"");
62
	putsNoTracking(V3OutFormatter::quoteNameControls(str));
62
	putsNoTracking(V3OutFormatter::quoteNameControls(str, V3OutFormatter::LA_XML));
63 63
	putsNoTracking("\"");
64 64
    }
65 65

  
src/V3File.cpp
843 843
    putcOutput(chr);
844 844
}
845 845

  
846
string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::Language) {
847
    // Encode control chars into C style escapes
846
string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::Language lang) {
848 847
    // Reverse is V3Parse::deQuote
849 848
    string out;
850
    for (string::const_iterator pos=namein.begin(); pos!=namein.end(); ++pos) {
851
	if (pos[0]=='\\' || pos[0]=='"') {
852
	    out += string("\\")+pos[0];
853
	} else if (pos[0]=='\n') {
854
	    out += "\\n";
855
	} else if (pos[0]=='\r') {
856
	    out += "\\r";
857
	} else if (pos[0]=='\t') {
858
	    out += "\\t";
859
	} else if (isprint(pos[0])) {
860
	    out += pos[0];
861
	} else {
862
	    // This will also cover \a etc
863
	    // Can't use %03o as messes up when signed
864
	    char octal[10]; sprintf(octal,"\\%o%o%o",(pos[0]>>6)&3, (pos[0]>>3)&7, pos[0]&7);
865
	    out += octal;
866
	}
849
    if (lang==LA_XML) {
850
        // Encode chars into XML string
851
        for (string::const_iterator pos=namein.begin(); pos!=namein.end(); ++pos) {
852
        if (pos[0]=='"') {
853
            out += string(""");
854
        } else if (pos[0]=='\'') {
855
            out += string("'");
856
        } else if (pos[0]=='<') {
857
            out += string("&lt;");
858
        } else if (pos[0]=='>') {
859
            out += string("&gt;");
860
        } else if (pos[0]=='&') {
861
            out += string("&amp;");
862
        } else if (isprint(pos[0])) {
863
            out += pos[0];
864
        } else {
865
            char decimal[10]; sprintf(decimal,"&#%u;",(unsigned char)pos[0]);
866
            out += decimal;
867
        }
868
        }
869
    } else {
870
        // Encode control chars into C style escapes
871
        for (string::const_iterator pos=namein.begin(); pos!=namein.end(); ++pos) {
872
        if (pos[0]=='\\' || pos[0]=='"') {
873
            out += string("\\")+pos[0];
874
        } else if (pos[0]=='\n') {
875
            out += "\\n";
876
        } else if (pos[0]=='\r') {
877
            out += "\\r";
878
        } else if (pos[0]=='\t') {
879
            out += "\\t";
880
        } else if (isprint(pos[0])) {
881
            out += pos[0];
882
        } else {
883
            // This will also cover \a etc
884
            // Can't use %03o as messes up when signed
885
            char octal[10]; sprintf(octal,"\\%o%o%o",(pos[0]>>6)&3, (pos[0]>>3)&7, pos[0]&7);
886
            out += octal;
887
        }
888
        }
867 889
    }
868 890
    return out;
869 891
}
test_regress/t/t_xml_tag.out
31 31
        <varxref fl="f32" name="value" dtype_id="6" dotted="itop"/>
32 32
        <varref fl="f32" name="dotted" dtype_id="5"/>
33 33
      </contassign>
34
      <func fl="f34" name="f" dtype_id="1">
35
        <var fl="f34" name="f" dtype_id="1" dir="output" vartype="logic" origName="f"/>
36
        <var fl="f34" name="m" dtype_id="7" dir="input" vartype="string" origName="m"/>
37
        <display fl="f35" displaytype="$display">
38
          <sformatf fl="f35" name="%@" dtype_id="7">
39
            <varref fl="f35" name="m" dtype_id="7"/>
40
          </sformatf>
41
        </display>
42
      </func>
43
      <initial fl="f38">
44
        <taskref fl="f39" name="f">
45
          <arg fl="f39">
46
            <const fl="f39" name="&quot;&#1;&#2;&#3;&#4;&#5;&#6;&#7;&#8;&#9;&#10;&#11;&#12;&#13;&#14;&#15;&#16;&#17;&#18;&#19;&#20;&#21;&#22;&#23;&#24;&#25;&#26;&#27;&#28;&#29;&#30;&#31; !&quot;#$%&amp;&apos;()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~&#127;&#128;&#129;&#130;&#131;&#132;&#133;&#134;&#135;&#136;&#137;&#138;&#139;&#140;&#141;&#142;&#143;&#144;&#145;&#146;&#147;&#148;&#149;&#150;&#151;&#152;&#153;&#154;&#155;&#156;&#157;&#158;&#159;&#160;&#161;&#162;&#163;&#164;&#165;&#166;&#167;&#168;&#169;&#170;&#171;&#172;&#173;&#174;&#175;&#176;&#177;&#178;&#179;&#180;&#181;&#182;&#183;&#184;&#185;&#186;&#187;&#188;&#189;&#190;&#191;&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#215;&#216;&#217;&#218;&#219;&#220;&#221;&#222;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#240;&#241;&#242;&#243;&#244;&#245;&#246;&#247;&#248;&#249;&#250;&#251;&#252;&#253;&#254;&#255;&quot;" dtype_id="7"/>
47
          </arg>
48
        </taskref>
49
      </initial>
34 50
    </module>
35 51
    <iface fl="f6" name="ifc" origName="ifc">
36 52
      <var fl="f7" name="value" dtype_id="6" vartype="integer" origName="value"/>
......
43 59
      <basicdtype  fl="f7" id="6" name="integer" left="31" right="0"/>
44 60
      <basicdtype  fl="f13" id="1" name="logic"/>
45 61
      <structdtype fl="f19" id="2" name="m.my_struct">
46
        <memberdtype fl="f20" id="7" name="clk" tag="this is clk" sub_dtype_id="8"/>
47
        <memberdtype fl="f21" id="9" name="k" sub_dtype_id="10"/>
48
        <memberdtype fl="f22" id="11" name="enable" tag="enable" sub_dtype_id="12"/>
49
        <memberdtype fl="f23" id="13" name="data" tag="data" sub_dtype_id="14"/>
62
        <memberdtype fl="f20" id="8" name="clk" tag="this is clk" sub_dtype_id="9"/>
63
        <memberdtype fl="f21" id="10" name="k" sub_dtype_id="11"/>
64
        <memberdtype fl="f22" id="12" name="enable" tag="enable" sub_dtype_id="13"/>
65
        <memberdtype fl="f23" id="14" name="data" tag="data" sub_dtype_id="15"/>
50 66
      </structdtype>
51
      <basicdtype  fl="f20" id="8" name="logic"/>
52
      <basicdtype  fl="f21" id="10" name="logic"/>
53
      <basicdtype  fl="f22" id="12" name="logic"/>
54
      <basicdtype  fl="f23" id="14" name="logic"/>
67
      <basicdtype  fl="f20" id="9" name="logic"/>
68
      <basicdtype  fl="f21" id="11" name="logic"/>
69
      <basicdtype  fl="f22" id="13" name="logic"/>
70
      <basicdtype  fl="f23" id="15" name="logic"/>
55 71
      <ifacerefdtype fl="f28" id="3" modportname=""/>
56 72
      <unpackarraydtype fl="f30" id="4" sub_dtype_id="2">
57 73
        <range fl="f30">
58
          <const fl="f30" name="32'h1" dtype_id="5"/>
59
          <const fl="f30" name="32'h0" dtype_id="5"/>
74
          <const fl="f30" name="32&apos;h1" dtype_id="5"/>
75
          <const fl="f30" name="32&apos;h0" dtype_id="5"/>
60 76
        </range>
61 77
      </unpackarraydtype>
62
      <refdtype fl="f30" id="15" name="my_struct" sub_dtype_id="2"/>
78
      <refdtype fl="f30" id="16" name="my_struct" sub_dtype_id="2"/>
79
      <basicdtype  fl="f34" id="7" name="string"/>
63 80
    </typetable>
64 81
  </netlist>
65 82
</verilator_xml>
test_regress/t/t_xml_tag.v
31 31

  
32 32
   wire [31:0] dotted = itop.value;
33 33

  
34
   function f(input string m);
35
       $display("%s", m);
36
   endfunction
37

  
38
   initial
39
       f("\x01\x02\x03\x04\x05\x06\a\x08\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"); // contains all 256 characters except 0 (null character)
40

  
34 41
endmodule
35
-