aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLibravatar Zandr Martin <zandrmartin@users.noreply.github.com>2016-06-11 09:33:24 -0500
committerLibravatar GitHub <noreply@github.com>2016-06-11 09:33:24 -0500
commit66caee645cc276bf747ae492df02c08d978ee90d (patch)
tree034b3d95fd283d934462df8740430cc53786f105 /common
parentclean up pid/workspace stuff (diff)
parentMany improvements to man pages (diff)
downloadsway-66caee645cc276bf747ae492df02c08d978ee90d.tar.gz
sway-66caee645cc276bf747ae492df02c08d978ee90d.tar.zst
sway-66caee645cc276bf747ae492df02c08d978ee90d.zip
Merge branch 'master' into assign-command
Diffstat (limited to 'common')
-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 @@
5char *read_line(FILE *file) { 5char *read_line(FILE *file) {
6 size_t length = 0, size = 128; 6 size_t length = 0, size = 128;
7 char *string = malloc(size); 7 char *string = malloc(size);
8 char lastChar = '\0';
8 if (!string) { 9 if (!string) {
9 return NULL; 10 return NULL;
10 } 11 }
11 while (1) { 12 while (1) {
12 int c = getc(file); 13 int c = getc(file);
14 if (c == '\n' && lastChar == '\\'){
15 --length; // Ignore last character.
16 lastChar = '\0';
17 continue;
18 }
13 if (c == EOF || c == '\n' || c == '\0') { 19 if (c == EOF || c == '\n' || c == '\0') {
14 break; 20 break;
15 } 21 }
16 if (c == '\r') { 22 if (c == '\r') {
17 continue; 23 continue;
18 } 24 }
25 lastChar = c;
19 if (length == size) { 26 if (length == size) {
20 char *new_string = realloc(string, size *= 2); 27 char *new_string = realloc(string, size *= 2);
21 if (!new_string) { 28 if (!new_string) {