Fix.
[yaz-moved-to-github.git] / util / cvs-date.tcl
1 #!/bin/sh
2 #  the next line restarts using tclsh \
3 exec tclsh "$0" "$@"
4 #
5 # $Id: cvs-date.tcl,v 1.4 2001-09-11 12:44:22 adam Exp $
6 set sec 0
7
8 proc cvslog {} {
9         global sec
10
11         set f [open {|cvs log} r]
12         while {[gets $f line] >= 0} {
13                 if {[regexp {^date: ([0-9]+)[ /]+([0-9]+)[ /]+([0-9]+)[ /]} $line dummy year month day]} {
14                         set this $year$month$day
15                         if {$this > $sec} {
16                                 set sec $this
17                         }
18                 }
19         }
20 }
21
22 cvslog 
23
24 if {$sec} {
25         set fname [lindex $argv 0]
26         if {[string length $fname]} {
27                 set f [open [lindex $argv 0] w]
28                 puts $f  "#define YAZ_DATE ${sec}L"
29                 puts $f  "#define YAZ_DATE_STR \"$sec\""
30                 puts $f  ""
31                 close $f
32         } else {
33                 puts $sec
34         }
35 }