Mercurial > repos > tabletprog
diff modules/string.tp @ 311:dfd204c82849
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 01 Aug 2014 18:56:50 -0700 |
parents | 8dbb2d2522a5 |
children | 74cab9b5f2a4 |
line wrap: on
line diff
--- a/modules/string.tp Fri Aug 01 18:56:39 2014 -0700 +++ b/modules/string.tp Fri Aug 01 18:56:50 2014 -0700 @@ -211,6 +211,12 @@ start <- bytes } clampedLen <- tocopy num + if: clampedLen < 0 { + clampedLen <- bytes - clampedLen + if: clampedLen < 0 { + clampedLen <- 0 + } + } if: start + clampedLen > bytes { clampedLen <- bytes - start } @@ -219,6 +225,7 @@ memcpy: (ret data) data + start clampedLen ret len!: clampedLen ret bytes!: clampedLen + (ret data) set: clampedLen 0 ret } @@ -292,16 +299,22 @@ } do: { start <- start + 1 } - end <- l + end <- l - 1 while: { - if: end > 0 { - b <- byte: end - 1 + if: end > start { + b <- byte: end b = space || b = tab || b = nl || b = cr } } do: { end <- end - 1 } - from: start withLength: (end - start) + from: start withLength: (end + 1 - start) + } + + startsWith? <- :prefix { + if: (prefix length) <= length { + 0 = (compareSub: prefix 0 0 (prefix length)) + } } endsWith? <- :suffix {