aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-01-20 17:50:49 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-01-20 17:50:49 +0530
commitc92715a01d0c60439bbe90c1b7b8eb16063a6df0 (patch)
tree52913586f048c6f4e68903e921dfc44fea4aa4c6
parent231be5ec36e4f7c8b071e8a5f8130d05b77098ff (diff)
downloadnnn-c92715a01d0c60439bbe90c1b7b8eb16063a6df0.tar.gz
Simplify writing selection
-rw-r--r--src/nnn.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nnn.c b/src/nnn.c
index bcd143f..f959220 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -738,10 +738,8 @@ static ssize_t selectiontofd(int fd)
ssize_t pos = 0, len, r, lastpos = copybufpos - 1;
while (pos < copybufpos) {
- while(pcopybuf[pos])
- ++pos;
-
len = strlen(pbuf);
+ pos += len;
r = write(fd, pbuf, len);
if (r != len)
@@ -750,7 +748,7 @@ static ssize_t selectiontofd(int fd)
if (pos != lastpos) {
if (write(fd, "\n", 1) != 1)
return pos;
- pbuf = pbuf + len + 1;
+ pbuf += pos + 1;
}
++pos;
}
@@ -1501,7 +1499,10 @@ static size_t mkpath(char *dir, char *name, char *out, size_t n)
return (xstrlcpy(out + len, name, n - len) + len);
}
-/* Create symbolic/hard link(s) to file(s) in selection list */
+/*
+ * Create symbolic/hard link(s) to file(s) in selection list
+ * Returns the number of links created
+ */
static int xlink(char *suffix, char *path, char *buf, int type)
{
int count = 0;