aboutsummaryrefslogtreecommitdiff
path: root/common/readline.c
diff options
context:
space:
mode:
authorZandr Martin <zandrmartin@users.noreply.github.com>2016-06-11 09:33:24 -0500
committerGitHub <noreply@github.com>2016-06-11 09:33:24 -0500
commit66caee645cc276bf747ae492df02c08d978ee90d (patch)
tree034b3d95fd283d934462df8740430cc53786f105 /common/readline.c
parentbeaa03344eda931274b75275bfc2d622e6875956 (diff)
parentcb0cc32265136522f7bfbb768f55f35718248d71 (diff)
Merge branch 'master' into assign-command
Diffstat (limited to 'common/readline.c')
-rw-r--r--common/readline.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/readline.c b/common/readline.c
index 76ed6926..5106172c 100644
--- a/common/readline.c
+++ b/common/readline.c
@@ -5,17 +5,24 @@
char *read_line(FILE *file) {
size_t length = 0, size = 128;
char *string = malloc(size);
+ char lastChar = '\0';
if (!string) {
return NULL;
}
while (1) {
int c = getc(file);
+ if (c == '\n' && lastChar == '\\'){
+ --length; // Ignore last character.
+ lastChar = '\0';
+ continue;
+ }
if (c == EOF || c == '\n' || c == '\0') {
break;
}
if (c == '\r') {
continue;
}
+ lastChar = c;
if (length == size) {
char *new_string = realloc(string, size *= 2);
if (!new_string) {