projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove bogus assembler options.
[bertos.git]
/
bertos
/
mware
/
readline.c
diff --git
a/bertos/mware/readline.c
b/bertos/mware/readline.c
index 83af2077a4200c9bbd47738fded826c130292ffa..35afe50bf46f448468ec7cc505c3c49913aee676 100644
(file)
--- a/
bertos/mware/readline.c
+++ b/
bertos/mware/readline.c
@@
-42,7
+42,7
@@
* aim at fast performances (line editing does not require to be blazingly fast).
*
* \li The first character in the history is always \c \\0, and it is used as a guard. By 'wasting' it
* aim at fast performances (line editing does not require to be blazingly fast).
*
* \li The first character in the history is always \c \\0, and it is used as a guard. By 'wasting' it
- * in this way, the code actually gets much simpler in that we remove many checks when moving
+ * in this way, the code actually gets much simpler in that we remove many checks when moving
* backward (\c i>0 and similar).
*
* \li While editing, the current index points to the position of the buffer which contains the
* backward (\c i>0 and similar).
*
* \li While editing, the current index points to the position of the buffer which contains the
@@
-366,13
+366,6
@@
void rl_refresh(struct RLContext* ctx)
const char* rl_readline(struct RLContext* ctx)
{
const char* rl_readline(struct RLContext* ctx)
{
- size_t i = ctx->history_pos;
-
- if (ctx->prompt)
- rl_puts(ctx, ctx->prompt);
-
- insert_chars(ctx, &i, NULL, 0);
-
while (1)
{
char ch;
while (1)
{
char ch;
@@
-391,23
+384,12
@@
const char* rl_readline(struct RLContext* ctx)
{
// Ask the match hook if available
if (!ctx->match)
{
// Ask the match hook if available
if (!ctx->match)
- return
false
;
+ return
NULL
;
complete_word(ctx, &ctx->line_pos);
continue;
}
complete_word(ctx, &ctx->line_pos);
continue;
}
- if (c == '\r' || c == '\n')
- {
- if (ctx->prompt)
- rl_puts(ctx, ctx->prompt);
-
- // Terminate line
- insert_chars(ctx, &ctx->line_pos, NULL, 0);
- rl_puts(ctx, "\r\n");
- break;
- }
-
// Backspace cancels a character, or it is ignored if at
// the start of the line
if (c == '\b')
// Backspace cancels a character, or it is ignored if at
// the start of the line
if (c == '\b')
@@
-420,17
+402,20
@@
const char* rl_readline(struct RLContext* ctx)
continue;
}
continue;
}
+ if (c == '\r' || c == '\n')
+ {
+ rl_puts(ctx, "\r\n");
+ break;
+ }
+
+
// Add a character to the buffer, if possible
ch = (char)c;
ASSERT2(ch == c, "a special key was not properly handled");
if (insert_chars(ctx, &ctx->line_pos, &ch, 1))
// Add a character to the buffer, if possible
ch = (char)c;
ASSERT2(ch == c, "a special key was not properly handled");
if (insert_chars(ctx, &ctx->line_pos, &ch, 1))
- {
rl_putc(ctx, ch);
rl_putc(ctx, ch);
- }
else
else
- {
beep(ctx);
beep(ctx);
- }
}
ctx->history_pos = ctx->line_pos + 1;
}
ctx->history_pos = ctx->line_pos + 1;
@@
-445,9
+430,18
@@
const char* rl_readline(struct RLContext* ctx)
dump_history(ctx);
#endif
dump_history(ctx);
#endif
+ const char *buf = &ctx->history[ctx->line_pos + 1];
+
+ ctx->line_pos = ctx->history_pos;
+
+ if (ctx->prompt)
+ rl_puts(ctx, ctx->prompt);
+
+ insert_chars(ctx, &ctx->line_pos, NULL, 0);
+
// Since the current pointer now points to the separator, we need
// to return the first character
// Since the current pointer now points to the separator, we need
// to return the first character
- return
&ctx->history[ctx->line_pos + 1]
;
+ return
buf
;
}
}