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. Change comment to:
    Dear Sean,

    thank you for great C-VFS. I am trying to get it working by little steps.
    There might be a wiki recipe on success for the medium programmer of this wizard program.

    Just a note. TCL and Metakit is normally C89 clean. The output of dir2c.tcl is not, as it uses this style of initialization:

    <verbatim>
    static struct cvfs_data cvfs_tcl_data[] = {
        {
            /* Index 0 cannot be used because we use the value 0 to represent failure */
            .name  = NULL,
            .index = 0,
            .type  = 0,
            .size  = 0,
            .data  = NULL,
            .free  = 0,
        },
    </verbatim>

    Unfortunately, C89 does not allow to name the structure items.
    The patch below transforms this output into:

    <verbatim>
    static struct cvfs_data cvfs_tcl_data[] = {
        {
            /* Index 0 cannot be used because we use the value 0 to represent failure */
            /* name  */ NULL,
            /* index */ 0,
            /* type  */ 0,
            /* size  */ 0,
            /* data  */ NULL,
            /* free  */ 0,
        },
    </verbatim>

    Here is the patch:

    <verbatim>
    --- C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c_ori.tcl    Wed Jan 22 20:53:52 2020
    +++ C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl    Fri Apr 17 10:20:20 2020
    @@ -306,20 +306,20 @@
     
     #  endif /* !LOADED_CVFS_COMMON */}
     puts ""
     
     puts "static struct cvfs_data ${code_tag}_data\[\] = {"
     puts "\t{"
     puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"
    -puts "\t\t.name  = NULL,"
    -puts "\t\t.index = 0,"
    -puts "\t\t.type  = 0,"
    -puts "\t\t.size  = 0,"
    -puts "\t\t.data  = NULL,"
    -puts "\t\t.free  = 0,"
    +puts "\t\t/* name  */ NULL,"
    +puts "\t\t/* index */ 0,"
    +puts "\t\t/* type  */ 0,"
    +puts "\t\t/* size  */ 0,"
    +puts "\t\t/* data  */ NULL,"
    +puts "\t\t/* free  */ 0,"
     puts "\t},"
     for {set idx 1} {$idx < [llength $files]} {incr idx} {
         set file [lindex $files $idx]
         set shortfile [shorten_file $startdir $file]
     
         unset -nocomplain finfo type
         file stat $file finfo
    @@ -345,20 +345,20 @@
                 set type "CVFS_FILETYPE_DIR"
                 set data "NULL"
                 set size 0
             }
         }
     
         puts "\t{"
    -    puts "\t\t.name  = \"$shortfile\","
    -    puts "\t\t.index = $idx,"
    -    puts "\t\t.type  = $type,"
    -    puts "\t\t.size  = $size,"
    -    puts "\t\t.data  = $data,"
    -    puts "\t\t.free  = 0,"
    +    puts "\t\t/* name  */ \"$shortfile\","
    +    puts "\t\t/* index */ $idx,"
    +    puts "\t\t/* type  */ $type,"
    +    puts "\t\t/* size  */ $size,"
    +    puts "\t\t/* data  */ $data,"
    +    puts "\t\t/* free  */ 0,"
         puts "\t},"
     }
     puts "};"
     puts ""
     
     puts "static unsigned long ${code_tag}_lookup_index(const char *path) {"
     puts "\tswitch (cvfs_hash((unsigned char *) path)) {"</verbatim>

    Thank you and best regards,
    Harald
  2. Change login to "anonymous"
  3. Change severity to "Critical"
  4. Change status to "Open"
  5. Change title to "Output C89 data from dir2c.tcl"
  6. Change type to "Code Defect"