Refactor, DRY
[git-tools-moved-to-github.git] / fixup-headers / add-file-config.tcl
1 #!/usr/bin/tclsh
2 set have_config 0
3 while {[gets stdin line] >= 0} {
4         set must_make_config 0
5         if {[string match "\#if HAVE_CONFIG_H*" $line]} {
6                 set have_config 1
7         } elseif {[string match "\#*" $line]} {
8                 if {!$have_config} {
9                         puts "\#if HAVE_CONFIG_H"
10                         puts "\#include <config.h>"
11                         puts "\#endif"
12                 }
13                 set have_config 1
14         }
15         puts $line
16 }