summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libfile.c17
-rw-r--r--lib/parameter.c5
-rw-r--r--lib/readline.c8
3 files changed, 24 insertions, 6 deletions
diff --git a/lib/libfile.c b/lib/libfile.c
index 02078dd..5a1817e 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -332,7 +332,7 @@ int copy_file(const char *src, const char *dst, int verbose)
{
char *rw_buf = NULL;
int srcfd = 0, dstfd = 0;
- int r;
+ int r, s;
int ret = 1, err1 = 0;
int mode;
int total = 0;
@@ -343,22 +343,27 @@ int copy_file(const char *src, const char *dst, int verbose)
srcfd = open(src, O_RDONLY);
if (srcfd < 0) {
printf("could not open %s: %s\n", src, errno_str());
+ ret = srcfd;
goto out;
}
mode = O_WRONLY | O_CREAT;
- ret = stat(dst, &dststat);
- if (ret && ret != -ENOENT)
+ s = stat(dst, &dststat);
+ if (s && s != -ENOENT) {
+ printf("could not stat %s: %s\n", dst, errno_str());
+ ret = s;
goto out;
+ }
/* Set O_TRUNC only if file exist and is a regular file */
- if (!ret && S_ISREG(dststat.st_mode))
+ if (!s && S_ISREG(dststat.st_mode))
mode |= O_TRUNC;
dstfd = open(dst, mode);
if (dstfd < 0) {
printf("could not open %s: %s\n", dst, errno_str());
+ ret = dstfd;
goto out;
}
@@ -373,12 +378,14 @@ int copy_file(const char *src, const char *dst, int verbose)
r = read(srcfd, rw_buf, RW_BUF_SIZE);
if (r < 0) {
perror("read");
+ ret = r;
goto out;
}
if (!r)
break;
- if (write_full(dstfd, rw_buf, r) < 0) {
+ ret = write_full(dstfd, rw_buf, r);
+ if (ret < 0) {
perror("write");
goto out;
}
diff --git a/lib/parameter.c b/lib/parameter.c
index 00e9a9f..fdbb2e7 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -253,11 +253,14 @@ static int param_string_set(struct device_d *dev, struct param_d *p, const char
struct param_string *ps = to_param_string(p);
int ret;
char *value_save = *ps->value;
+ char *value_new;
if (!val)
val = "";
- *ps->value = xstrdup(val);
+ value_new = xstrdup(val);
+ value_new = strim(value_new);
+ *ps->value = value_new;
if (!ps->set)
return 0;
diff --git a/lib/readline.c b/lib/readline.c
index d026af1..3d16c18 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -290,9 +290,17 @@ int readline(const char *prompt, char *buf, int len)
insert = !insert;
break;
case BB_KEY_ERASE_LINE:
+ BEGINNING_OF_LINE();
+ ERASE_TO_EOL();
+ break;
case CTL_CH('u'):
+ wlen = eol_num - num;
+ memmove(buf, buf+num, wlen);
BEGINNING_OF_LINE();
ERASE_TO_EOL();
+ eol_num = wlen;
+ REFRESH_TO_EOL();
+ BEGINNING_OF_LINE();
break;
case DEL:
case BB_KEY_DEL7: