summaryrefslogtreecommitdiffstats
path: root/commands/readline.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands/readline.c')
-rw-r--r--commands/readline.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/commands/readline.c b/commands/readline.c
index b6e0e3e091..57c8fbd7bc 100644
--- a/commands/readline.c
+++ b/commands/readline.c
@@ -1,44 +1,36 @@
-/*
- * (C) Copyright 2000-2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: © 2000-2003 Wolfgang Denk <wd@denx.de>, DENX Software Engineering
#include <common.h>
#include <command.h>
#include <malloc.h>
+#include <slice.h>
#include <xfuncs.h>
#include <environment.h>
static int do_readline(int argc, char *argv[])
{
- char *buf = xzalloc(CONFIG_CBSIZE);
+ char *buf;
if (argc < 3)
return COMMAND_ERROR_USAGE;
- if (readline(argv[1], buf, CONFIG_CBSIZE) < 0) {
+ buf = xzalloc(CONFIG_CBSIZE);
+
+ command_slice_release();
+
+ if (readline(argv[1], buf, CONFIG_CBSIZE - 1) < 0) {
+ command_slice_acquire();
free(buf);
- return 1;
+ return COMMAND_ERROR;
}
+ command_slice_acquire();
+
setenv(argv[2], buf);
free(buf);
- return 0;
+ return COMMAND_SUCCESS;
}
BAREBOX_CMD_HELP_START(readline)