File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -33,12 +33,15 @@ function slash(prog) {
33
33
if ( state == 1 && print != "" ) { logPrint ( ) ; res += print ; print = "" ; }
34
34
if ( state == 3 ) {
35
35
var isVerbose = false ;
36
+ var iters = 0 ; const MAX_ITERS = 1280 ;
36
37
while ( prog . includes ( pattern ) ) {
37
- prog = prog ? prog . replace ( pattern , replacement ) : prog ;
38
- // Just `prog = prog.replace(pat, rep);` might be good enough
39
- // Was trying to get rid of the null character that was printing
40
- // Thought maybe the replacement with an empty string pattern was undefined
41
- if ( isVerbose ) { logApply ( ) ; }
38
+ if ( iters > MAX_ITERS ) { print += '...' ; break ; }
39
+ iters ++ ;
40
+ prog = prog ? prog . replace ( pattern , replacement ) : prog ;
41
+ // Just `prog = prog.replace(pat, rep);` might be good enough
42
+ // Was trying to get rid of the null character that was printing
43
+ // Thought maybe the replacement with an empty string pattern was undefined
44
+ if ( isVerbose ) { logApply ( ) ; }
42
45
}
43
46
if ( ! isVerbose ) { logApply ( ) ; }
44
47
pattern = "" ; replacement = "" ;
You can’t perform that action at this time.
0 commit comments