diff options
Diffstat (limited to 'deps/v8/src/string.js')
-rw-r--r-- | deps/v8/src/string.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/deps/v8/src/string.js b/deps/v8/src/string.js index 02f5c98cd3..84dde3dc27 100644 --- a/deps/v8/src/string.js +++ b/deps/v8/src/string.js @@ -1,4 +1,4 @@ -// Copyright 2006-2009 the V8 project authors. All rights reserved. +// Copyright 2012 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -554,14 +554,14 @@ function StringSlice(start, end) { } } else { if (start_i > s_len) { - start_i = s_len; + return ''; } } if (end_i < 0) { end_i += s_len; if (end_i < 0) { - end_i = 0; + return ''; } } else { if (end_i > s_len) { @@ -569,12 +569,11 @@ function StringSlice(start, end) { } } - var num_c = end_i - start_i; - if (num_c < 0) { - num_c = 0; + if (end_i <= start_i) { + return ''; } - return SubString(s, start_i, start_i + num_c); + return SubString(s, start_i, end_i); } @@ -611,6 +610,12 @@ function StringSplit(separator, limit) { if (limit === 0) return []; + // Separator is a regular expression. + return StringSplitOnRegExp(subject, separator, limit, length); +} + + +function StringSplitOnRegExp(subject, separator, limit, length) { %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]); if (length === 0) { |