escaping the escape character on input (thanks for reporting, @Lucki!)

This commit is contained in:
Justin Meza 2015-07-26 21:39:37 -07:00
parent e3388d5fc7
commit e97cf5296b
7 changed files with 35 additions and 1 deletions

View File

@ -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++;
}

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(3-EscapeCharacter OUTPUT test.out INPUT test.in)

View File

@ -0,0 +1,2 @@
:[ ] x [ ] y
:

View File

@ -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

View File

@ -0,0 +1,3 @@
:[ ] x [ ] y
: - :
success

View File

@ -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.

View File

@ -1,2 +1,3 @@
add_subdirectory(1-ShortString)
add_subdirectory(2-LongString)
add_subdirectory(3-EscapeCharacter)