Mercurial > repos > rhope
view countstring.rhope @ 121:1af91ceaaf49
Fixed memory leak when an output is only attached to a single null input
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 Oct 2010 21:04:12 -0400 |
parents | 73e978d590c7 |
children | 0a4682be2db2 |
line wrap: on
line source
Blueprint Count String { Text Line Column } Count String[text:out] { out <- Count String At Pos[text, 0, 0] } Count String At Pos[text,line,col:out] { out <- [[[Build["Count String"]]Text <<[text]]Line <<[line]]Column <<[col] } Slice@Count String[string,index:left,right] { If[[index] = [0]] { left <- [string]Text <<[""] right <- Val[string] }{ ltext,rtext <- [[string]Text >>]Slice[index] left <- [string]Text <<[ltext] parts <- [ltext]Split["\n"] last line <- [[parts]Length] - [1] rline <- [[string]Line >>] + [last line] prercol <- [[parts]Index[last line]]Length If[[last line] > [0]] { rcol <- Val[prercol] }{ rcol <- [prercol] + [[string]Column >>] } right <- Count String At Pos[rtext, rline, rcol] } } Length@Count String[string:out] { out <- Length[[string]Text >>] } Append@Count String[left,right:out] { If[[[left]Length] > [0]] { out <- [left]Text << [ [To String[left]]Append[To String[right]] ] }{ out <- right } } =@Count String[left,right:out] { out <- [To String[left]] = [To String[right]] } Get DString@Count String[string, delims:after,before,delim,nomatch] { ,,delim,nomatch <- [[string]Text >>]Get DString[delims] { If[[dlines] > [0]] { cols <- Val[dcols] }{ If[[blines] > [0]] { cols <- [bcols] + [dcols] }{ cols <- [[bcols] + [dcols]] + [[string]Column >>] } } after <- Count String At Pos[~, [[blines]+[dlines]] + [[string]Line >>], cols] }{ before <- [string]Text <<[~] bparts <- [~]Split["\n"] preblines <- [[bparts]Length] - [1] If[[preblines] > [-1]] { blines <- Val[preblines] bcols <- Length[[bparts]Index[blines]] }{ bcols <- 0 blines <- 0 } }{ dparts <- [~]Split["\n"] dlines <- [[dparts]Length] - [1] dcols <- Length[[dparts]Index[dlines]] } } To String@Count String[string:out] { out <- [string]Text >> } Empty@Count String[string:out] { out <- Count String[""] }