Merge pull request #4127 from asandroq/fix-strcons
Fix tests for ASCII characters in RTS
commit9e1c9a35fb592a47df4564d639241a4866f859d5
authorNiklas Larsson <metaniklas@gmail.com>
dateMon 16 Oct 2017, 13:32 (9 years ago)
parent172924ca3d0a3a
rts/idris_rts.c+1−1
@@ -714,7 +714,7 @@ VAL idris_strCons(VM* vm, VAL x, VAL xs) {
714714 int xval = GETINT(x);
715715 int xlen = GETSTRLEN(xs);
716716
717− if ((xval & 0x80) == 0) { // ASCII char
717+ if (xval < 0x80) { // ASCII char
718718 Closure* cl = allocate(sizeof(Closure) +
719719 xlen + 2, 0);
720720 SETTY(cl, CT_STRING);
rts/idris_utf8.c+1−1
@@ -119,7 +119,7 @@ char* idris_utf8_fromChar(int x) {
119119 char* str;
120120 int bytes = 0, top = 0;
121121
122− if ((x & 0x80) == 0) {
122+ if (x < 0x80) {
123123 str = malloc(2);
124124 str[0] = (char)x;
125125 str[1] = '\0';
test/basic013/basic013.idr+2
@@ -20,6 +20,8 @@ main = do putStrLn foo
2020 putStrLn (reverse (foo ++ bar))
2121 printLn (length foo)
2222 printLn baz
23+ printLn (strCons '\x141' "")
24+ printLn (singleton (chr 0x141))
2325 let x = 4
2426 let newstr = appMany (toNat x)
2527 putStrLn newstr
test/basic013/expected+2
@@ -3,6 +3,8 @@
33x→xλx→xλ
444
55'\955'
6+"\321"
7+"\321"
68λx→xλx→xλx→xλx→xλx→x
79'\955'
81020