stdio: Remove CONFIG_EOL_IS_XXX
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
parent
69cad3c287
commit
db22e07d07
@ -294,21 +294,9 @@ static int edit(int chn, int nl)
|
|||||||
}
|
}
|
||||||
else if ((f->inCapacity + 1) < sizeof(f->inBuf))
|
else if ((f->inCapacity + 1) < sizeof(f->inBuf))
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_EOL_IS_BOTH_CRLF
|
|
||||||
/* Ignore carriage returns that may accompany a CRLF sequence. */
|
|
||||||
|
|
||||||
if (ch != '\r')
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* Is this a new line character */
|
/* Is this a new line character */
|
||||||
|
|
||||||
#ifdef CONFIG_EOL_IS_CR
|
|
||||||
if (ch != '\r')
|
|
||||||
#elif defined(CONFIG_EOL_IS_LF)
|
|
||||||
if (ch != '\n')
|
if (ch != '\n')
|
||||||
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
|
|
||||||
if (ch != '\n' && ch != '\r')
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* No.. escape control characters other than newline and
|
/* No.. escape control characters other than newline and
|
||||||
* carriage return
|
* carriage return
|
||||||
@ -340,20 +328,11 @@ static int edit(int chn, int nl)
|
|||||||
{
|
{
|
||||||
FS_putChar(chn, '\n');
|
FS_putChar(chn, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
#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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ch = '\n';
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f->inBuf[f->inCapacity++] = ch;
|
f->inBuf[f->inCapacity++] = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
while (ch != '\n');
|
while (ch != '\n');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -45,34 +45,6 @@
|
|||||||
* Pre-processor Definitions
|
* 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 */
|
/* Control characters */
|
||||||
|
|
||||||
#undef CTRL
|
#undef CTRL
|
||||||
@ -1077,14 +1049,7 @@ static int cle_editloop(FAR struct cle_s *priv)
|
|||||||
|
|
||||||
/* Newline terminates editing. But what is a newline? */
|
/* 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 */
|
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 */
|
/* Add the newline to the buffer at the end of the line */
|
||||||
|
|
||||||
@ -1095,11 +1060,6 @@ static int cle_editloop(FAR struct cle_s *priv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\r': /* Wait for the LF */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Text to insert or unimplemented/invalid keypresses */
|
/* Text to insert or unimplemented/invalid keypresses */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -31,34 +31,6 @@
|
|||||||
* Pre-processor Definitions
|
* 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 */
|
/* Helper macros */
|
||||||
|
|
||||||
#define RL_GETC(v) ((v)->rl_getc(v))
|
#define RL_GETC(v) ((v)->rl_getc(v))
|
||||||
|
@ -667,13 +667,7 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf,
|
|||||||
* others both.
|
* others both.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
else if (ch == '\n')
|
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
|
#ifdef CONFIG_READLINE_CMD_HISTORY
|
||||||
/* Save history of command, only if there was something
|
/* Save history of command, only if there was something
|
||||||
|
169
system/vi/vi.c
169
system/vi/vi.c
@ -57,34 +57,6 @@
|
|||||||
# define CONFIG_SYSTEM_VI_COLS 64
|
# define CONFIG_SYSTEM_VI_COLS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
#ifndef CONFIG_SYSTEM_VI_YANK_THRESHOLD
|
#ifndef CONFIG_SYSTEM_VI_YANK_THRESHOLD
|
||||||
#define CONFIG_SYSTEM_VI_YANK_THRESHOLD 128
|
#define CONFIG_SYSTEM_VI_YANK_THRESHOLD 128
|
||||||
#endif
|
#endif
|
||||||
@ -4099,21 +4071,6 @@ static void vi_cmd_mode(FAR struct vi_s *vi)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_CR)
|
|
||||||
case KEY_CMDMODE_NEXTLINE:
|
|
||||||
case '\r': /* CR terminates line */
|
|
||||||
{
|
|
||||||
vi->curpos = vi_nextline(vi, vi->curpos);
|
|
||||||
vi_gotofirstnonwhite(vi);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#elif defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\r': /* Wait for the LF */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case KEY_CMDMODE_NEXTLINE:
|
case KEY_CMDMODE_NEXTLINE:
|
||||||
case '\n': /* LF terminates line */
|
case '\n': /* LF terminates line */
|
||||||
{
|
{
|
||||||
@ -4121,18 +4078,6 @@ static void vi_cmd_mode(FAR struct vi_s *vi)
|
|||||||
vi_gotofirstnonwhite(vi);
|
vi_gotofirstnonwhite(vi);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_EOL_IS_EITHER_CRLF
|
|
||||||
case KEY_CMDMODE_NEXTLINE:
|
|
||||||
case '\r': /* Either CR or LF terminates line */
|
|
||||||
case '\n':
|
|
||||||
{
|
|
||||||
vi->curpos = vi_nextline(vi, vi->curpos);
|
|
||||||
vi_gotofirstnonwhite(vi);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case KEY_CMDMODE_PREVLINE:
|
case KEY_CMDMODE_PREVLINE:
|
||||||
{
|
{
|
||||||
@ -4639,34 +4584,11 @@ static void vi_cmd_submode(FAR struct vi_s *vi)
|
|||||||
|
|
||||||
/* What do we do with carriage returns? line feeds? */
|
/* What do we do with carriage returns? line feeds? */
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_CR)
|
|
||||||
case '\r': /* CR terminates line */
|
|
||||||
{
|
|
||||||
vi_parsecolon(vi);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#elif defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\r': /* Wait for the LF */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\n': /* LF terminates line */
|
case '\n': /* LF terminates line */
|
||||||
{
|
{
|
||||||
vi_parsecolon(vi);
|
vi_parsecolon(vi);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_EOL_IS_EITHER_CRLF
|
|
||||||
case '\r': /* Either CR or LF terminates line */
|
|
||||||
case '\n':
|
|
||||||
{
|
|
||||||
vi_parsecolon(vi);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -4941,34 +4863,11 @@ static void vi_find_submode(FAR struct vi_s *vi, bool revfind)
|
|||||||
|
|
||||||
/* What do we do with carriage returns? line feeds? */
|
/* What do we do with carriage returns? line feeds? */
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_CR)
|
|
||||||
case '\r': /* CR terminates line */
|
|
||||||
{
|
|
||||||
vi_parsefind(vi, revfind);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#elif defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\r': /* Wait for the LF */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\n': /* LF terminates line */
|
case '\n': /* LF terminates line */
|
||||||
{
|
{
|
||||||
vi_parsefind(vi, revfind);
|
vi_parsefind(vi, revfind);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_EOL_IS_EITHER_CRLF
|
|
||||||
case '\r': /* Either CR or LF terminates line */
|
|
||||||
case '\n':
|
|
||||||
{
|
|
||||||
vi_parsefind(vi, revfind);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -5089,36 +4988,11 @@ static void vi_replacech_submode(FAR struct vi_s *vi)
|
|||||||
|
|
||||||
/* What do we do with carriage returns? line feeds? */
|
/* What do we do with carriage returns? line feeds? */
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_CR)
|
|
||||||
case '\r': /* CR terminates line */
|
|
||||||
{
|
|
||||||
ch = '\n';
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#elif defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\r': /* Wait for the LF */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\n': /* LF terminates line */
|
case '\n': /* LF terminates line */
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_EOL_IS_EITHER_CRLF
|
|
||||||
case '\r': /* Either CR or LF terminates line */
|
|
||||||
case '\n':
|
|
||||||
{
|
|
||||||
ch = '\n';
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -5487,28 +5361,6 @@ static void vi_insert_mode(FAR struct vi_s *vi)
|
|||||||
|
|
||||||
/* What do we do with carriage returns? */
|
/* What do we do with carriage returns? */
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_CR)
|
|
||||||
case '\r': /* CR terminates line */
|
|
||||||
{
|
|
||||||
if (vi->mode == MODE_INSERT)
|
|
||||||
{
|
|
||||||
vi_insertch(vi, '\n');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vi_replacech(vi, '\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
vi->drawtoeos = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#elif defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\r': /* Wait for the LF */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF)
|
|
||||||
case '\n': /* LF terminates line */
|
case '\n': /* LF terminates line */
|
||||||
{
|
{
|
||||||
if (vi->mode == MODE_INSERT)
|
if (vi->mode == MODE_INSERT)
|
||||||
@ -5523,27 +5375,6 @@ static void vi_insert_mode(FAR struct vi_s *vi)
|
|||||||
vi->drawtoeos = true;
|
vi->drawtoeos = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_EOL_IS_EITHER_CRLF
|
|
||||||
case '\r': /* Either CR or LF terminates line */
|
|
||||||
case '\n':
|
|
||||||
{
|
|
||||||
if (vi->mode == MODE_INSERT)
|
|
||||||
{
|
|
||||||
vi_insertch(vi, '\n');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vi_replacech(vi, '\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
vi_putch(vi, ' ');
|
|
||||||
vi_clrtoeol(vi);
|
|
||||||
vi->drawtoeos = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case KEY_UP: /* Move the cursor up one line */
|
case KEY_UP: /* Move the cursor up one line */
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user