From owner-p4-projects@FreeBSD.ORG Sun Aug 17 13:48:03 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B3BC81065675; Sun, 17 Aug 2008 13:48:03 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77FC81065672 for ; Sun, 17 Aug 2008 13:48:03 +0000 (UTC) (envelope-from zec@freebsd.org) Received: from xaqua.tel.fer.hr (xaqua.tel.fer.hr [161.53.19.25]) by mx1.freebsd.org (Postfix) with ESMTP id 0050C8FC19 for ; Sun, 17 Aug 2008 13:48:02 +0000 (UTC) (envelope-from zec@freebsd.org) Received: by xaqua.tel.fer.hr (Postfix, from userid 20006) id 5A1379B651; Sun, 17 Aug 2008 15:48:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on xaqua.tel.fer.hr X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.7 Received: from localhost (imunes.tel.fer.hr [161.53.19.8]) by xaqua.tel.fer.hr (Postfix) with ESMTP id E6B7D9B64F for ; Sun, 17 Aug 2008 15:47:59 +0200 (CEST) From: Marko Zec To: Perforce Change Reviews Date: Sun, 17 Aug 2008 14:47:51 +0200 User-Agent: KMail/1.9.7 References: <200808171344.m7HDiR0Z024586@repoman.freebsd.org> In-Reply-To: <200808171344.m7HDiR0Z024586@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200808171447.51397.zec@freebsd.org> Cc: Subject: Re: PERFORCE change 147645 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2008 13:48:03 -0000 On Sunday 17 August 2008 15:44:27 Marko Zec wrote: > http://perforce.freebsd.org/chv.cgi?CH=147645 > > Change 147645 by zec@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 line if the file was > modified. if { $changed == true && $fextn == ".c" } {