Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 44 additions & 54 deletions interpreters/bas/bas_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,64 +294,43 @@ static int edit(int chn, int nl)
}
else if ((f->inCapacity + 1) < sizeof(f->inBuf))
{
#ifdef CONFIG_EOL_IS_BOTH_CRLF
/* Ignore carriage returns that may accompany a CRLF sequence. */
/* Is this a new line character */

if (ch != '\r')
#endif
if (ch != '\n')
{
/* Is this a new line character */

#ifdef CONFIG_EOL_IS_CR
if (ch != '\r')
#elif defined(CONFIG_EOL_IS_LF)
if (ch != '\n')
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
if (ch != '\n' && ch != '\r')
#endif
/* No.. escape control characters other than newline and
* carriage return
*/

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) : '@');
}

/* It is a newline */
/* Output normal, printable characters */

else
{
/* Echo the newline (or not). We always use newline
* termination when talking to the host.
*/
FS_putChar(chn, ch);
}
}

if (nl)
{
FS_putChar(chn, '\n');
}
/* It is a newline */

#if defined(CONFIG_EOL_IS_CR) || defined(CONFIG_EOL_IS_EITHER_CRLF)
/* If the host is talking to us with CR line terminations,
* switch to use LF internally.
*/
else
{
/* Echo the newline (or not). We always use newline
* termination when talking to the host.
*/

ch = '\n';
#endif
if (nl)
{
FS_putChar(chn, '\n');
}

f->inBuf[f->inCapacity++] = ch;
}

f->inBuf[f->inCapacity++] = ch;
}
}
while (ch != '\n');
Expand Down Expand Up @@ -456,9 +435,12 @@ int FS_opendev(int chn, int infd, int outfd)

int FS_openin(const char *name)
{
int chn, fd;
int chn;
int fd;

if ((fd = open(name, O_RDONLY)) == -1)
fd = open(name, O_RDONLY);

if (fd < 0)
{
FS_errmsg = strerror(errno);
return -1;
Expand Down Expand Up @@ -547,9 +529,12 @@ int FS_openinChn(int chn, const char *name, int mode)

int FS_openout(const char *name)
{
int chn, fd;
int chn;
int fd;

fd = open(name, O_WRONLY | O_TRUNC | O_CREAT, 0666);

if ((fd = open(name, O_WRONLY | O_TRUNC | O_CREAT, 0666)) == -1)
if (fd < 0)
{
FS_errmsg = strerror(errno);
return -1;
Expand Down Expand Up @@ -932,7 +917,8 @@ void FS_xonxoff(int chn, int on)

int FS_put(int chn)
{
ssize_t offset, written;
ssize_t offset;
size_t written;

if (opened(chn, 2) == -1)
{
Expand Down Expand Up @@ -1418,7 +1404,8 @@ int FS_getChar(int dev)

int FS_get(int chn)
{
ssize_t offset, rd;
ssize_t offset;
size_t rd;

if (opened(chn, 2) == -1)
{
Expand Down Expand Up @@ -1544,7 +1531,8 @@ int FS_eof(int chn)
long int FS_loc(int chn)
{
int fd;
off_t cur, offset = 0;
off_t cur;
off_t offset = 0;

if (opened(chn, -1) == -1)
{
Expand Down Expand Up @@ -1794,9 +1782,11 @@ int FS_charpos(int chn)

int FS_copy(const char *from, const char *to)
{
int infd, outfd;
int infd;
int outfd;
char buf[4096];
ssize_t inlen, outlen = -1;
ssize_t inlen;
ssize_t outlen = -1;

if ((infd = open(from, O_RDONLY)) == -1)
{
Expand Down
40 changes: 0 additions & 40 deletions system/cle/cle.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,6 @@
* Pre-processor Definitions
****************************************************************************/

/* Some environments may return CR as end-of-line, others LF, and others
* both. If not specified, the logic here assumes either (but not both) as
* the default.
*/

#if defined(CONFIG_EOL_IS_CR)
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_BOTH_CRLF
# undef CONFIG_EOL_IS_EITHER_CRLF
#elif defined(CONFIG_EOL_IS_LF)
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_BOTH_CRLF
# undef CONFIG_EOL_IS_EITHER_CRLF
#elif defined(CONFIG_EOL_IS_BOTH_CRLF)
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_EITHER_CRLF
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_BOTH_CRLF
#else
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_BOTH_CRLF
# define CONFIG_EOL_IS_EITHER_CRLF 1
#endif

/* Control characters */

#undef CTRL
Expand Down Expand Up @@ -1077,14 +1049,7 @@ static int cle_editloop(FAR struct cle_s *priv)

/* Newline terminates editing. But what is a newline? */

#if defined(CONFIG_EOL_IS_EITHER_CRLF)
case '\r': /* CR terminates line */
case '\n': /* LF terminates line */
#elif defined(CONFIG_EOL_IS_CR)
case '\r': /* CR terminates line */
#elif defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
case '\n': /* LF terminates line */
#endif
{
/* Add the newline to the buffer at the end of the line */

Expand All @@ -1095,11 +1060,6 @@ static int cle_editloop(FAR struct cle_s *priv)
}
break;

#if defined(CONFIG_EOL_IS_BOTH_CRLF)
case '\r': /* Wait for the LF */
break;
#endif

/* Text to insert or unimplemented/invalid keypresses */

default:
Expand Down
28 changes: 0 additions & 28 deletions system/readline/readline.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,6 @@
* Pre-processor Definitions
****************************************************************************/

/* Some environments may return CR as end-of-line, others LF, and others
* both. If not specified, the logic here assumes either (but not both) as
* the default.
*/

#if defined(CONFIG_EOL_IS_CR)
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_BOTH_CRLF
# undef CONFIG_EOL_IS_EITHER_CRLF
#elif defined(CONFIG_EOL_IS_LF)
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_BOTH_CRLF
# undef CONFIG_EOL_IS_EITHER_CRLF
#elif defined(CONFIG_EOL_IS_BOTH_CRLF)
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_EITHER_CRLF
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_BOTH_CRLF
#else
# undef CONFIG_EOL_IS_CR
# undef CONFIG_EOL_IS_LF
# undef CONFIG_EOL_IS_BOTH_CRLF
# define CONFIG_EOL_IS_EITHER_CRLF 1
#endif

/* Helper macros */

#define RL_GETC(v) ((v)->rl_getc(v))
Expand Down
6 changes: 0 additions & 6 deletions system/readline/readline_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,7 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf,
* others both.
*/

#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
else if (ch == '\n')
#elif defined(CONFIG_EOL_IS_CR)
else if (ch == '\r')
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
else if (ch == '\n' || ch == '\r')
#endif
{
#ifdef CONFIG_READLINE_CMD_HISTORY
/* Save history of command, only if there was something
Expand Down
Loading