[ramsan] This code tries to convert an old pre-ANSI C file to an ANSI C file. It will try to change things like: int ParseGLFunc (interp, argc, argv, nArg) Tcl_Interp *interp; int argc; char *argv []; int *nArg; { .... } to something like: int ParseGLFunc( Tcl_Interp *interp, int objc,Tcl_Obj *CONST objv[], int *nArg) Of course, without guarantees. Please, do correct it if you can improve. ---- Your example is incorrect, it shows the difference between the old (pre 8.x) string based tcl command interface and the new Tcl_Obj based (8.x) style commands. If i remember correct it's the 8.4 version with CONST. This has nothing to do with ANSI C and not ANSI C. Didn't look at your code below, to see if it does something else... [Michael Schlenker] ---- set filein {C:\path\to\file.c.old} set fileout {C:\path\to\file.c} set fin [open $filein r] set contents [read $fin] close $fin set funcname {\s*(\w+)\s*} set varname {\s*(\w+)\s*} set typename {\s*\w+[\s*&]*} for { set i 1 } { $i < 10 } { incr i } { set rex "$funcname\\(" for { set j 1 } { $j <= $i } { incr j } { if { $j > 1 } { append rex "," } append rex $varname } append rex "\\)" for { set j 1 } { $j <= $i } { incr j } { append rex "($typename\\[expr {$j+1}]\[]\[\\s]*)\\s*;" } while 1 { set idxs [regexp -inline -indices $rex $contents] if { $idxs == "" } { break } set contents_new [string range $contents 0 [expr [lindex [lindex $idxs 0] 0]-1]] append contents_new " [eval string range [list $contents] [lindex $idxs 1]](" for { set j 1 } { $j <= $i } { incr j } { set ipos [expr {$j+$i+1}] regsub -all {\s+} [eval string range [list $contents] [lindex $idxs $ipos]] { } arg if { $j > 1 } { append contents_new "," } append contents_new $arg } append contents_new ")[string range $contents [expr [lindex [lindex $idxs 0] 1]+1] end]" set contents $contents_new } } set fout [open $fileout w] puts $fout $contents close $fout