aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-01-14 03:27:24 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-01-14 03:27:24 +0530
commite6580c38bf2a87b47e3c41dcbd9e150e53a85629 (patch)
tree2845144d2ed9536f8505e0d42a6de58fd7c374db
parenta40d29ba9f5673523dfdf28e17d448a3cb8da1f8 (diff)
downloadnnn-e6580c38bf2a87b47e3c41dcbd9e150e53a85629.tar.gz
Replace snprintf() with xstrlcpy()
-rw-r--r--nnn.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/nnn.c b/nnn.c
index d6a1927..0dc9ec3 100644
--- a/nnn.c
+++ b/nnn.c
@@ -342,8 +342,7 @@ crc8fast(uchar const message[], size_t n)
}
/* The final remainder is the CRC */
- return (remainder);
-
+ return remainder;
}
/* Messages show up at the bottom */
@@ -1230,23 +1229,26 @@ readinput(void)
/*
* Updates out with "dir/name or "/name"
- * Returns the number of bytes in out including the terminating NULL byte
+ * Returns the number of bytes copied including the terminating NULL byte
*/
size_t
mkpath(char *dir, char *name, char *out, size_t n)
{
+ static size_t len;
+
/* Handle absolute path */
if (name[0] == '/')
return xstrlcpy(out, name, n);
else {
/* Handle root case */
if (istopdir(dir))
- return (snprintf(out, n, "/%s", name) + 1);
+ len = 1;
else
- return (snprintf(out, n, "%s/%s", dir, name) + 1);
+ len = xstrlcpy(out, dir, n);
}
- return 0;
+ out[len - 1] = '/';
+ return (xstrlcpy(out + len, name, n - len) + len);
}
static void