PERFORCE change 147645 for review
Marko Zec
zec at freebsd.org
Sun Aug 17 13:48:03 UTC 2008
On Sunday 17 August 2008 15:44:27 Marko Zec wrote:
> http://perforce.freebsd.org/chv.cgi?CH=147645
>
> Change 147645 by zec at zec_tpx32 on 2008/08/17 13:44:00
>
> A placeholder for writing down things to resolve before
> proceeding on further commit steps.
Oops, another change also leaked in here, aimed at allowing the variable
renaming TCL script to be used in a hint-only mode -> the description
how this is supposed to work is embedded in the var_rename.tcl file
Marko
> Affected files ...
>
> .. //depot/projects/vimage-commit2/TODO#1 add
> .. //depot/projects/vimage/var_rename.tcl#2 edit
>
> Differences ...
>
> ==== //depot/projects/vimage/var_rename.tcl#2 (text+ko) ====
>
> @@ -37,6 +37,10 @@
> # containing macros which resolve V_ instances back to their
> original # counterparts (e.g. V_rt_tables -> rt_tables).
> #
> +# Alternatively, the script may be invoked in a hint-only mode, so
> that +# instead of actually modifying files it prints out lines where
> candidates +# for the V_-transformation might be found.
> +#
> # Best effort is made not to change any variable declarations nor
> field # names in structure declarations and / or C-style comments.
> The script # attempts to avoid changing structure names if they
> happen to have the @@ -44,7 +48,7 @@
> #
> # Typically this script should be invoked as follows:
> #
> -# cat vimage_globals | xargs var_rename.tcl sys
> +# cat vimage_globals | xargs var_rename.tcl change sys
> #
> # Note that running the script over the entire sys tree can take a
> # significant amount of time to complete (longer than make
> buildworld). @@ -52,18 +56,25 @@
>
> set vimage_h "vimage.h"
>
> -if { [llength $argv] < 2 } {
> - puts "usage: var_rename.tcl srcdir varname ..."
> +if { [llength $argv] < 3 || ([lindex $argv 0] != "hint" &&
> + [lindex $argv 1] != "change")} {
> + puts "usage: var_rename.tcl hint|change srcdir varname ..."
> exit 1
> }
>
> -set srcdir [lindex $argv 0]
> +if { [lindex $argv 0] == "change" } {
> + set change_mode 1
> +} else {
> + set change_mode 0
> +}
> +
> +set srcdir [lindex $argv 1]
> if { [catch { exec find $srcdir -type f } filelist] != 0 } {
> puts "Error: $filelist"
> exit 1
> }
>
> -set items [lrange $argv 1 end]
> +set items [lrange $argv 2 end]
> set xitems "/* */ LIST_HEAD( TAILQ_HEAD( SYSCTL_ ) [lsort
> -decreasing [lrange $argv 1 end]]"
>
> # read the contents of the $vimage_h file
> @@ -73,13 +84,15 @@
> close $f
>
> # reopen for writing and append missing #defines
> +if { $change_mode } {
> set f [open $vimage_h a]
> -foreach item $items {
> - if { [string first "#define V_$item $item" $data] == -1 } {
> - puts $f "#define V_$item $item"
> + foreach item $items {
> + if { [string first "#define V_$item $item" $data] == -1 } {
> + puts $f "#define V_$item $item"
> + }
> }
> + close $f
> }
> -close $f
>
> # walk the file list parsing each file and update it if necessary
> foreach fname $filelist {
> @@ -104,13 +117,15 @@
> puts "Processing $fname"
> }
>
> - set f [open $fname w]
> - set first_line true
> + if { $change_mode } {
> + set f [open $fname w]
> + }
> +
> set changed false
> -
> set in_comment false
> set in_struct false
> set in_forbidden_macro false
> + set line_number 0
>
> foreach line [split $data \n] {
> set pos 0
> @@ -239,14 +254,23 @@
> }
> }
>
> - if { $first_line == true } {
> - set first_line false
> + if { $change_mode } {
> + if { $line_number > 0 } {
> + puts $f ""
> + }
> + puts -nonewline $f "$line"
> } else {
> - puts $f ""
> + # hint only mode
> + if { $changed == true } {
> + puts "$line_number:$line"
> + set changed false
> + }
> }
> - puts -nonewline $f "$line"
> + incr line_number
> + }
> + if { $change_mode } {
> + close $f
> }
> - close $f
>
> # insert a #include <sys/vimage.h> line if the file was
> modified. if { $changed == true && $fextn == ".c" } {
More information about the p4-projects
mailing list