escaping the escape character on input (thanks for reporting, @Lucki!)
This commit is contained in:
parent
e3388d5fc7
commit
e97cf5296b
|
@ -3268,8 +3268,12 @@ ReturnObject *interpretInputStmtNode(StmtNode *node,
|
|||
* but do not store it.
|
||||
*/
|
||||
if (c == EOF || c == (int)'\r' || c == (int)'\n') break;
|
||||
/* Reserve space to escape colon in input */
|
||||
if (c == ':') {
|
||||
cur++;
|
||||
}
|
||||
if (cur > size - 1) {
|
||||
/* Increasing buffer size. */
|
||||
/* Increase buffer size */
|
||||
size *= 2;
|
||||
mem = realloc(temp, sizeof(char) * size);
|
||||
if (!mem) {
|
||||
|
@ -3279,6 +3283,10 @@ ReturnObject *interpretInputStmtNode(StmtNode *node,
|
|||
}
|
||||
temp = mem;
|
||||
}
|
||||
/* Escape colon in input */
|
||||
if (c == ':') {
|
||||
temp[cur - 1] = ':';
|
||||
}
|
||||
temp[cur] = (char)c;
|
||||
cur++;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
INCLUDE(AddLolTest)
|
||||
ADD_LOL_TEST(3-EscapeCharacter OUTPUT test.out INPUT test.in)
|
|
@ -0,0 +1,2 @@
|
|||
:[ ] x [ ] y
|
||||
:
|
|
@ -0,0 +1,15 @@
|
|||
HAI 1.3
|
||||
I HAS A var1
|
||||
GIMMEH var1
|
||||
VISIBLE var1
|
||||
|
||||
I HAS A var2
|
||||
GIMMEH var2
|
||||
VISIBLE var2 AN " - " AN "::"
|
||||
BOTH SAEM var2 AN "::", O RLY?
|
||||
YA RLY
|
||||
VISIBLE "success"
|
||||
NO WAI
|
||||
VISIBLE "fail"
|
||||
OIC
|
||||
KTHXBYE
|
|
@ -0,0 +1,3 @@
|
|||
:[ ] x [ ] y
|
||||
: - :
|
||||
success
|
|
@ -0,0 +1,3 @@
|
|||
This test checks that when the escape character (:) is input it is correctly
|
||||
escaped. It provides two strings of text that check whether escaping occurs on
|
||||
output and on comparison.
|
|
@ -1,2 +1,3 @@
|
|||
add_subdirectory(1-ShortString)
|
||||
add_subdirectory(2-LongString)
|
||||
add_subdirectory(3-EscapeCharacter)
|
||||
|
|
Loading…
Reference in New Issue