Tcl Source Code

Artifact [d174b61ed4]
Login

Artifact d174b61ed45289ed43449853ad0c61db494bdebf:

Attachment "patch.txt" to ticket [219409ffff] added by davygrvy 2001-10-13 05:56:48.
*** tools/eolFix.tcl	Wed Dec 31 14:00:00 1969
--- tools/eolFix.tcl	Fri Oct 12 15:42:04 2001
***************
*** 0 ****
--- 1,78 ----
+ ## Super aggressive EOL-fixer!
+ ##
+ ##  Will even understand screwed up ones like CRCRLF.
+ ##  (found in bad CVS repositories, caused by spacey developers
+ ##   abusing CVS)
+ ##
+ ##  [email protected]    3:41 PM 10/12/2001
+ ##
+ 
+ package provide EOL-fix 1.1
+ 
+ namespace eval ::EOL {
+     variable outMode crlf
+ }
+ 
+ proc EOL::fix {filename {newfilename ""}} {
+     variable outMode
+ 
+     if {![file exist $filename]} { return }
+     puts "EOL Fixing: $filename"
+ 
+     file rename ${filename} ${filename}.o
+     set fhnd [open ${filename}.o r]
+ 
+     if {$newfilename != ""} {
+ 	set newfhnd [open ${newfilename} w]
+     } else {
+ 	set newfhnd [open ${filename} w]
+     }
+ 
+     fconfigure $newfhnd -translation [list auto $outMode]
+     seek $fhnd 0 end
+     set theEnd [tell $fhnd]
+     seek $fhnd 0 start
+ 
+     fconfigure $fhnd -translation binary -buffersize $theEnd
+     set rawFile [read $fhnd $theEnd]
+     close $fhnd
+ 
+     regsub -all {(\r)|(\r){1,2}(\n)} $rawFile "\n" rawFile
+ 
+     set lineList [split $rawFile \n]
+ 
+     foreach line $lineList {
+ 	puts $newfhnd $line
+     }
+ 
+     close $newfhnd
+     file delete ${filename}.o
+ }
+ 
+ proc EOL::fixall {args} {
+     if {[llength $args] == 0} {
+ 	puts stderr "no files to fix"
+ 	exit 1
+     } else {
+ 	set cmd [lreplace $args -1 -1 glob -nocomplain]
+     }
+ 
+     foreach f [eval $cmd] {
+ 	if {[file isfile $f]} {fix $f}
+     }
+ }
+ 
+ if {$tcl_interactive == 0 && $argc > 0} {
+     if {[string index [lindex $argv 0] 0] == "-"} {
+ 	switch -- [lindex $argv 0] {
+ 	    -cr   { set ::EOL::outMode cr }
+ 	    -crlf { set ::EOL::outMode crlf }
+ 	    -lf   { set ::EOL::outMode lf }
+ 	    default { puts stderr "improper mode switch" ; exit 1 }
+         }
+ 	set argv [lrange $argv 1 end]
+     }
+     eval EOL::fixall $argv
+ } else {
+     return
+ }


*** unix/Makefile.in	2001/09/10 00:33:09	1.83
--- unix/Makefile.in	2001/10/12 22:52:54
***************
*** 1203,1210 ****
--- 1203,1212 ----
  		$(TOP_DIR)/win/*.ico $(TOP_DIR)/win/*.rc \
  		$(DISTDIR)/win
  	cp -p $(TOP_DIR)/win/*.bat $(DISTDIR)/win
+ 	$(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/*.bat
  	cp -p $(TOP_DIR)/win/makefile.* $(DISTDIR)/win
  	cp -p $(TOP_DIR)/win/tcl.hpj.in $(DISTDIR)/win
+ 	$(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/tcl.hpj.in
  	cp -p $(TOP_DIR)/win/README $(DISTDIR)/win
  	cp -p $(TOP_DIR)/license.terms $(DISTDIR)/win
  	mkdir $(DISTDIR)/mac
***************
*** 1227,1232 ****
--- 1229,1236 ----
  		$(TOP_DIR)/tools/tcl.wse.in $(TOP_DIR)/tools/*.bmp \
  		$(TOP_DIR)/tools/tcl.hpj.in \
  		$(DISTDIR)/tools
+ 	$(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/tcl.hpj.in \
+ 		$(TOP_DIR)/tools/tcl.wse.in
  
  #
  # The following target can only be used for non-patch releases.  Use