File: epl_inserter.tcl

package info (click to toggle)
graphviz 2.42.2-5%2Bdeb11u1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 95,776 kB
  • sloc: ansic: 1,051,543; cpp: 9,107; tcl: 4,897; makefile: 4,857; sh: 4,506; yacc: 4,190; xml: 2,970; cs: 1,921; objc: 1,157; lex: 625; java: 560; perl: 445; python: 255; awk: 241; javascript: 146; ruby: 64; php: 59; sed: 1
file content (70 lines) | stat: -rwxr-xr-x 1,895 bytes parent folder | download | duplicates (3)
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
}