'From Cuis 1.0 of 6 April 2009 [latest update: #169] on 14 April 2009 at 9:12:52 am'!

!SystemDictionary methodsFor: 'housekeeping' stamp: 'jmv 4/14/2009 09:12'!
removeAllLineFeeds    "Smalltalk removeAllLineFeeds"
	"Scan all methods for source code with lineFeeds.
	Replaces all occurrences of <CR><LF> by <CR>, noted by beep.
	Halts with a message if any other LFs are found."
	 | oldCodeString n crlf cr newCodeString oldStamp oldCategory m lf |
	crlf _ String crlf.
	cr _ String cr.
	lf _ String lf.
	Smalltalk forgetDoIts.
'Scanning sources for LineFeeds.
This will take a few minutes...'
displayProgressAt: Sensor cursorPoint
from: 0 to: CompiledMethod instanceCount
during: [:bar | n _ 0. m _ 0.
	Smalltalk allBehaviorsDo:
		[:cls | 
		cls selectors do:
			[:selector | (n _ n+1) \\ 100 = 0 ifTrue: [bar value: n].
			oldCodeString _ (cls sourceCodeAt: selector) asString.
			(oldCodeString indexOf: Character lf startingAt: 1) > 0 ifTrue: [
				newCodeString _ oldCodeString copyReplaceAll: crlf with: cr.
				newCodeString _ oldCodeString copyReplaceAll: lf with: cr.
				oldStamp _ Utilities timeStampForMethod: (cls compiledMethodAt: selector).
				oldCategory _ cls whichCategoryIncludesSelector: selector.
				cls compile: newCodeString classified: oldCategory withStamp: oldStamp notifying: nil.
				m _ m + 1]]].
].
	Transcript cr; show: m printString , ' methods stripped of LFs.'.
! !

