forked from ellson/MOTHBALLED-graphviz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
epl_inserter.tcl
executable file
·70 lines (55 loc) · 1.85 KB
/
epl_inserter.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/tclsh
proc find_initial fn {
set author unknown
set date 2011
set rxp {revision 1.1[^.0-9]*date: ([0-9]+).*?author: ([A-Za-z0-9]+);}
if {! [catch "exec cvs log $fn" res]} {
regexp $rxp $res . date author
}
return [list $date $author]
}
proc dofile fn {
set rxp {/\*\*\*\*.*?Copyright[^-0-9]*?([-0-9]+).*?Common Public License.*?\*\*\*\*/}
set epl_header {/*************************************************************************
* Copyright (c) $epl_date $epl_initial_copyright_owner $epl_other_copyright_owners
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************/}
set epl_date "2011"
set epl_initial_copyright_owner "AT&T Intellectual Property"
set epl_other_copyright_owners {}
set epl_initial_author {unknown}
set f [open $fn r]
set t [read $f [file size $fn]]
close $f
if {[regexp -indices $rxp $t cpl cpl_date]} {
# puts "$fn $cpl $cpl_date [string length $t]"
foreach {cpl_first cpl_last} $cpl {break}
# puts [string range $t $cpl_first $cpl_last]
# foreach {cpl_date_first cpl_date_last} $cpl_date {break}
# puts [string range $t $cpl_date_first $cpl_date_last]
# puts [find_initial $fn]
# set epl_date [string range $t $cpl_date_first $cpl_date_last]
set f [open $fn w]
puts -nonewline $f [string range $t 0 $cpl_first-1]
puts -nonewline $f [subst $epl_header]
puts -nonewline $f [string range $t $cpl_last+1 end]
close $f
}
}
proc doname n {
if [file isdirectory $n] {
foreach gn [glob -nocomplain $n/*] {
doname $gn
}
} {
dofile $n
}
}
foreach n $argv {
doname $n
}