[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] bad or missing line breaks in class library



It could be a cross-platform issue re line-break-style.
Psycollider+win, for example, changes line-breaks from \n to \r (I
think), which is really annoying when you're trying to do windows dev
work. Possibly other editors do this too.

I may have committed some weirdo linebreaks thanks to being currently
in windowsland (although not to the specific files you mention, jh).
My apologies, it's hard to detect and avoid.

Dan

2008/12/25 James Harkins <jamshark70@xxxxxxxxx>:
> I've seen many files with weird formatting because of line breaks that are
> either missing or incorrectly coded. So I just wrote a little code snippet
> to find them. Results are attached.
> Specifically I was looking for lines with non-whitespace, followed by
> anything, followed by tab and close-brace, to match things like this:
> Pdfsm : ListPattern {
> var >startState;
> *new { arg list, startState=0, repeats=1;
> ^super.new( list, repeats ).startState_(startState) }
> ... huh? Where'd the closing brace for *new go? Oh, it's tacked onto the end
> of the previous line.
> But it ended up finding a lot of files where dozens of lines are read in as
> one line. Why a problem? It makes grep really nasty to use on some parts of
> the classlib.
> If there are no objections, I'll try to figure out a way to fix them
> automatically. Thought I would ask because some of the most-affected files
> are in JITLib and crucial.
> Thanks.
> hjh
>
>
> ~top = "./SCClassLibrary/";
> ~regexp = "[^ \n\r\t].*\t}";
> ~threaded = true;
> (
> // depth-first, why not?
> ~searchDirectory = { |path|
> var dirs = (path ++ "*/").pathMatch,
> files = (path ++ "*.sc").pathMatch;
> dirs.do({ |dir|
> ~searchDirectory.(dir);
> });
> files.do({ |file|
> ~searchFile.(file);
> if(~threaded and: { thisThread.isKindOf(Routine) }) { 0.01.wait };
> });
> };
> ~searchFile = { |path|
> var file = File(path, "r"),
> line, lineCount = 0, needToPostPath = true;
> if(file.isOpen) {
> protect {
> while { (line = file.getLine(4096)).notNil } {
> if("^//".matchRegexp(line).not and: { ~regexp.matchRegexp(line) }) {
> if(needToPostPath) {
> "\n%:\n".postf(path);
> needToPostPath = false;
> };
> "%: %\n".postf(lineCount, line);
> };
> lineCount = lineCount + 1;
> };
> } {
> file.close
> };
> } {
> "Failed to open %. Continuing.".format(path).warn;
> };
> };
> )
> // test
> ~searchFile.(SCView.filenameSymbol.asString);
> // run for real
> { ~searchDirectory.(~top); }.fork(AppClock);
>
>
> : H. James Harkins
> : jamshark70@xxxxxxxxxxxxxxxxx
> : http://www.dewdrop-world.net
> .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
> "Come said the Muse,
> Sing me a song no poet has yet chanted,
> Sing me the universal."  -- Whitman
>
>



-- 
http://www.mcld.co.uk

_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/