diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-11-06 13:22:21 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-11-06 13:22:21 -0600 |
commit | 9a97d4d6459252f84a0c3a8b6833ba58ae92a175 (patch) | |
tree | 60c1a38cb2ff07aa3d0752072cfef79054361870 /apps | |
parent | 4a1150d2cb2721cc2e7facd02294932d8683f721 (diff) | |
download | nuttx-9a97d4d6459252f84a0c3a8b6833ba58ae92a175.tar.gz nuttx-9a97d4d6459252f84a0c3a8b6833ba58ae92a175.tar.bz2 nuttx-9a97d4d6459252f84a0c3a8b6833ba58ae92a175.zip |
BAS: Conditional compile out use of ftruncate()
Diffstat (limited to 'apps')
-rw-r--r-- | apps/interpreters/bas/fs.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/apps/interpreters/bas/fs.c b/apps/interpreters/bas/fs.c index df4258d1f..790774543 100644 --- a/apps/interpreters/bas/fs.c +++ b/apps/interpreters/bas/fs.c @@ -285,43 +285,24 @@ static int edit(int chn, int onl) #else if ((f->inCapacity + 1) < sizeof(f->inBuf)) { - /* Ignore carriage returns that may accompnay a CRLF sequence. - * REVISIT: Some environments may have other line termination rules - */ - - if (ch != '\r') + if (ch != '\n') { - /* Is this a new line character */ - - if (ch != '\n') + if (ch >= '\0' && ch < ' ') { - /* 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); - } + FS_putChar(chn, '^'); + FS_putChar(chn, ch ? (ch + 'a' - 1) : '@'); } - - /* Echo the newline (or not) */ - - else if (onl) + else { - FS_putChar(chn, '\n'); + FS_putChar(chn, ch); } - - f->inBuf[f->inCapacity++] = ch; } + else if (onl) + { + FS_putChar(chn, '\n'); + } + + f->inBuf[f->inCapacity++] = ch; } #endif } @@ -832,6 +813,7 @@ int FS_lock(int chn, off_t offset, off_t length, int mode, int w) int FS_truncate(int chn) { +#ifdef CONFIG_INTERPRETER_BAS_HAVE_FTRUNCATE int fd; off_t o; @@ -862,6 +844,10 @@ int FS_truncate(int chn) } return 0; +#else + FS_errmsg = strerror(ENOSYS); + return -1; +#endif } void FS_shellmode(int dev) @@ -1683,6 +1669,12 @@ 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; } } |