D 2020-04-17T13:33:49.924 J comment
Dear\sSean,
thank\syou\sfor\sgreat\sC-VFS.\sI\sam\strying\sto\sget\sit\sworking\sby\slittle\ssteps.
There\smight\sbe\sa\swiki\srecipe\son\ssuccess\sfor\sthe\smedium\sprogrammer\sof\sthis\swizard\sprogram.
Just\sa\snote.\sTCL\sand\sMetakit\sis\snormally\sC89\sclean.\sThe\soutput\sof\sdir2c.tcl\sis\snot,\sas\sit\suses\sthis\sstyle\sof\sinitialization:
<verbatim>
static\sstruct\scvfs_data\scvfs_tcl_data[]\s=\s{   \s{       \s/*\sIndex\s0\scannot\sbe\sused\sbecause\swe\suse\sthe\svalue\s0\sto\srepresent\sfailure\s*/       \s.name \s=\sNULL,       \s.index\s=\s0,       \s.type \s=\s0,       \s.size \s=\s0,       \s.data \s=\sNULL,       \s.free \s=\s0,   \s},
</verbatim>
Unfortunately,\sC89\sdoes\snot\sallow\sto\sname\sthe\sstructure\sitems.
The\spatch\sbelow\stransforms\sthis\soutput\sinto:
<verbatim>
static\sstruct\scvfs_data\scvfs_tcl_data[]\s=\s{   \s{       \s/*\sIndex\s0\scannot\sbe\sused\sbecause\swe\suse\sthe\svalue\s0\sto\srepresent\sfailure\s*/       \s/*\sname \s*/\sNULL,       \s/*\sindex\s*/\s0,       \s/*\stype \s*/\s0,       \s/*\ssize \s*/\s0,       \s/*\sdata \s*/\sNULL,       \s/*\sfree \s*/\s0,   \s},
</verbatim>
Here\sis\sthe\spatch:
<verbatim>
---\sC:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c_ori.tcl   \sWed\sJan\s22\s20:53:52\s2020+++\sC:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl   \sFri\sApr\s17\s10:20:20\s2020@@\s-306,20\s+306,20\s@@  # \sendif\s/*\s!LOADED_CVFS_COMMON\s*/} puts\s""  puts\s"static\sstruct\scvfs_data\s${code_tag}_data\\[\\]\s=\s{" puts\s"\\t{" puts\s"\\t\\t/*\sIndex\s0\scannot\sbe\sused\sbecause\swe\suse\sthe\svalue\s0\sto\srepresent\sfailure\s*/"-puts\s"\\t\\t.name \s=\sNULL,"-puts\s"\\t\\t.index\s=\s0,"-puts\s"\\t\\t.type \s=\s0,"-puts\s"\\t\\t.size \s=\s0,"-puts\s"\\t\\t.data \s=\sNULL,"-puts\s"\\t\\t.free \s=\s0,"+puts\s"\\t\\t/*\sname \s*/\sNULL,"+puts\s"\\t\\t/*\sindex\s*/\s0,"+puts\s"\\t\\t/*\stype \s*/\s0,"+puts\s"\\t\\t/*\ssize \s*/\s0,"+puts\s"\\t\\t/*\sdata \s*/\sNULL,"+puts\s"\\t\\t/*\sfree \s*/\s0," puts\s"\\t}," for\s{set\sidx\s1}\s{$idx\s<\s[llength\s$files]}\s{incr\sidx}\s{    \sset\sfile\s[lindex\s$files\s$idx]    \sset\sshortfile\s[shorten_file\s$startdir\s$file]     \sunset\s-nocomplain\sfinfo\stype    \sfile\sstat\s$file\sfinfo@@\s-345,20\s+345,20\s@@    \s   \s   \sset\stype\s"CVFS_FILETYPE_DIR"    \s   \s   \sset\sdata\s"NULL"    \s   \s   \sset\ssize\s0    \s   \s}    \s}     \sputs\s"\\t{"-   \sputs\s"\\t\\t.name \s=\s\\"$shortfile\\","-   \sputs\s"\\t\\t.index\s=\s$idx,"-   \sputs\s"\\t\\t.type \s=\s$type,"-   \sputs\s"\\t\\t.size \s=\s$size,"-   \sputs\s"\\t\\t.data \s=\s$data,"-   \sputs\s"\\t\\t.free \s=\s0,"+   \sputs\s"\\t\\t/*\sname \s*/\s\\"$shortfile\\","+   \sputs\s"\\t\\t/*\sindex\s*/\s$idx,"+   \sputs\s"\\t\\t/*\stype \s*/\s$type,"+   \sputs\s"\\t\\t/*\ssize \s*/\s$size,"+   \sputs\s"\\t\\t/*\sdata \s*/\s$data,"+   \sputs\s"\\t\\t/*\sfree \s*/\s0,"    \sputs\s"\\t}," } puts\s"};" puts\s""  puts\s"static\sunsigned\slong\s${code_tag}_lookup_index(const\schar\s*path)\s{" puts\s"\\tswitch\s(cvfs_hash((unsigned\schar\s*)\spath))\s{"</verbatim>
Thank\syou\sand\sbest\sregards,
Harald
J login anonymous J severity Critical J status Open J title Output\sC89\sdata\sfrom\sdir2c.tcl J type Code\sDefect K 127ac40147407d703ee7ccd70c865c6a87c53c56 U anonymous Z 6127e5322bd86531aa3d86d47cf7d3bd