Ticket Change Details
Overview

Artifact ID: 7d5d92c98e9680b19b4f7c0730fe7e6469ffc4a3
Ticket: 127ac40147407d703ee7ccd70c865c6a87c53c56
Output C89 data from dir2c.tcl
User & Date: anonymous on 2020-04-17 13:33:49
Changes

  1. comment changed to:
    <div>Dear Sean,</div><div><br /></div><div>thank you for great C-VFS. I am trying to get it working by little steps.</div><div>There might be a wiki recipe on success for the medium programmer of this wizard program.<br /></div><div><br /></div><div>Just a note. TCL and Metakit is normally C89 clean. The output of dir2c.tcl is not, as it uses this style of initialization:</div><div><br /></div><div>&lt;verbatim&gt;</div><div>static struct cvfs_data cvfs_tcl_data[] = {<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Index 0 cannot be used because we use the value 0 to represent failure */<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .name&nbsp; = NULL,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .index = 0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .type&nbsp; = 0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .size&nbsp; = 0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .data&nbsp; = NULL,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .free&nbsp; = 0,<br />&nbsp;&nbsp;&nbsp; },</div><div>&lt;/verbatim&gt;<br /></div><div><br /></div><div>Unfortunately, C89 does not allow to name the structure items.</div><div>The patch below transforms this output into:</div><div><br /></div><div>&lt;verbatim&gt;</div><div>static struct cvfs_data cvfs_tcl_data[] = {<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Index 0 cannot be used because we use the value 0 to represent failure */<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* name&nbsp; */ NULL,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* index */ 0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* type&nbsp; */ 0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* size&nbsp; */ 0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* data&nbsp; */ NULL,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* free&nbsp; */ 0,<br />&nbsp;&nbsp;&nbsp; },<br /></div><div>&lt;/verbatim&gt;</div><div><br /></div><div>Here is the patch:</div><div><br /></div><div>&lt;verbatim&gt;</div><div>--- C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c_ori.tcl&nbsp;&nbsp;&nbsp; Wed Jan 22 20:53:52 2020<br />+++ C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl&nbsp;&nbsp;&nbsp; Fri Apr 17 10:20:20 2020<br />@@ -306,20 +306,20 @@<br />&nbsp;<br />&nbsp;#&nbsp; endif /* !LOADED_CVFS_COMMON */}<br />&nbsp;puts ""<br />&nbsp;<br />&nbsp;puts "static struct cvfs_data ${code_tag}_data\[\] = {"<br />&nbsp;puts "\t{"<br />&nbsp;puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"<br />-puts "\t\t.name&nbsp; = NULL,"<br />-puts "\t\t.index = 0,"<br />-puts "\t\t.type&nbsp; = 0,"<br />-puts "\t\t.size&nbsp; = 0,"<br />-puts "\t\t.data&nbsp; = NULL,"<br />-puts "\t\t.free&nbsp; = 0,"<br />+puts "\t\t/* name&nbsp; */ NULL,"<br />+puts "\t\t/* index */ 0,"<br />+puts "\t\t/* type&nbsp; */ 0,"<br />+puts "\t\t/* size&nbsp; */ 0,"<br />+puts "\t\t/* data&nbsp; */ NULL,"<br />+puts "\t\t/* free&nbsp; */ 0,"<br />&nbsp;puts "\t},"<br />&nbsp;for {set idx 1} {$idx &lt; [llength $files]} {incr idx} {<br />&nbsp;&nbsp;&nbsp;&nbsp; set file [lindex $files $idx]<br />&nbsp;&nbsp;&nbsp;&nbsp; set shortfile [shorten_file $startdir $file]<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; unset -nocomplain finfo type<br />&nbsp;&nbsp;&nbsp;&nbsp; file stat $file finfo<br />@@ -345,20 +345,20 @@<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set type "CVFS_FILETYPE_DIR"<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data "NULL"<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set size 0<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; puts "\t{"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t.name&nbsp; = \"$shortfile\","<br />-&nbsp;&nbsp;&nbsp; puts "\t\t.index = $idx,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t.type&nbsp; = $type,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t.size&nbsp; = $size,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t.data&nbsp; = $data,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t.free&nbsp; = 0,"<br />+&nbsp;&nbsp;&nbsp; puts "\t\t/* name&nbsp; */ \"$shortfile\","<br />+&nbsp;&nbsp;&nbsp; puts "\t\t/* index */ $idx,"<br />+&nbsp;&nbsp;&nbsp; puts "\t\t/* type&nbsp; */ $type,"<br />+&nbsp;&nbsp;&nbsp; puts "\t\t/* size&nbsp; */ $size,"<br />+&nbsp;&nbsp;&nbsp; puts "\t\t/* data&nbsp; */ $data,"<br />+&nbsp;&nbsp;&nbsp; puts "\t\t/* free&nbsp; */ 0,"<br />&nbsp;&nbsp;&nbsp;&nbsp; puts "\t},"<br />&nbsp;}<br />&nbsp;puts "};"<br />&nbsp;puts ""<br />&nbsp;<br />&nbsp;puts "static unsigned long ${code_tag}_lookup_index(const char *path) {"<br />&nbsp;puts "\tswitch (cvfs_hash((unsigned char *) path)) {"&lt;/verbatim&gt;<br /></div><div><br /></div><div>Thank you and best regards,</div><div>Harald<br /></div>
    
  2. login: "anonymous"
  3. severity changed to: "Critical"
  4. status changed to: "Open"
  5. title changed to: "Output C89 data from dir2c.tcl"
  6. type changed to: "Code Defect"