From 95213afeb50ff5efebffba782ec22d60ae9052db Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Nov 2014 13:35:15 -0600 Subject: [PATCH] Recovering from GIT chaos --- interpreters/bas/fs.c | 59 ++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/interpreters/bas/fs.c b/interpreters/bas/fs.c index 790774543..cea05db56 100644 --- a/interpreters/bas/fs.c +++ b/interpreters/bas/fs.c @@ -285,24 +285,43 @@ static int edit(int chn, int onl) #else if ((f->inCapacity + 1) < sizeof(f->inBuf)) { - if (ch != '\n') - { - if (ch >= '\0' && ch < ' ') - { - FS_putChar(chn, '^'); - FS_putChar(chn, ch ? (ch + 'a' - 1) : '@'); - } - else - { - FS_putChar(chn, ch); - } - } - else if (onl) - { - FS_putChar(chn, '\n'); - } + /* Ignore carriage returns that may accompany a CRLF sequence. + * REVISIT: Some environments may have other line termination rules + */ - f->inBuf[f->inCapacity++] = ch; + if (ch != '\r') + { + /* Is this a new line character */ + + if (ch != '\n') + { + /* No.. escape control characters other than newline and + * carriage return + */ + + if (ch >= '\0' && ch < ' ') + { + FS_putChar(chn, '^'); + FS_putChar(chn, ch ? (ch + 'a' - 1) : '@'); + } + + /* Output normal, printable characters */ + + else + { + FS_putChar(chn, ch); + } + } + + /* Echo the newline (or not) */ + + else if (onl) + { + FS_putChar(chn, '\n'); + } + + f->inBuf[f->inCapacity++] = ch; + } } #endif } @@ -1669,12 +1688,6 @@ int FS_appendToString(int chn, struct String *s, int onl) f->inSize = f->inCapacity = 0; } - if (s->length >= 2 && s->character[s->length - 2] == '\r') - { - s->character[s->length - 2] = '\n'; - --s->length; - } - return 0; } }