summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-07-24 19:49:50 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-07-24 19:49:50 -0400
commit6f9747dbea34c09ae40f9859f63ad77abc1bd950 (patch)
treedec970c386478d5f45db5ef7601ea0699f4665b8
parent8a2b82151a52f3c2e99d60b76026b22b088b9e56 (diff)
Fix JavaScript implementation of strcspn()
-rw-r--r--lib/js/urweb.js2
-rw-r--r--tests/strcspn.ur6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 4435bffa..56066d26 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -1104,7 +1104,7 @@ function sspn(s, chs) {
if (chs.indexOf(s.charAt(i)) != -1)
return i;
- return null;
+ return s.length;
}
function schr(s, ch) {
var r = s.indexOf(ch);
diff --git a/tests/strcspn.ur b/tests/strcspn.ur
new file mode 100644
index 00000000..8066010b
--- /dev/null
+++ b/tests/strcspn.ur
@@ -0,0 +1,6 @@
+fun main () : transaction page =
+ s <- source "";
+ return <xml><body>
+ <ctextbox source={s}/>
+ <button onclick={fn _ => v <- get s; alert (show (strcspn v "0123456789"))}/>
+ </body></xml>