Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: stat, system: minor fixes



---
 Src/Modules/stat.c   | 6 +++---
 Src/Modules/system.c | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c
index 5bf201dd30..f7ec06e9e7 100644
--- a/Src/Modules/stat.c
+++ b/Src/Modules/stat.c
@@ -191,14 +191,14 @@ static void
 stattimeprint(time_t tim, long nsecs, char *outbuf, int flags)
 {
     if (flags & STF_RAW) {
-	sprintf(outbuf, "%ld", (unsigned long)tim);
+	sprintf(outbuf, "%ld", (long)tim);
 	if (flags & STF_STRING)
 	    strcat(outbuf, " (");
     }
     if (flags & STF_STRING) {
 	char *oend = outbuf + strlen(outbuf);
-	/* Where the heck does "40" come from? */
-	ztrftime(oend, 40, timefmt, (flags & STF_GMT) ? gmtime(&tim) :
+	/* the buffer is PATH_MAX+9 long, but we already printed some stuff */
+	ztrftime(oend, PATH_MAX - DIGBUFSIZE - 10, timefmt, (flags & STF_GMT) ? gmtime(&tim) :
 			   localtime(&tim), nsecs);
 	if (flags & STF_RAW)
 	    strcat(oend, ")");
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index 1f3665dba5..3c0b8421ab 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -686,7 +686,8 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
     else
 	flags = O_RDWR | O_NOCTTY;
     if ((flock_fd = open(unmeta(args[0]), flags)) < 0) {
-	zwarnnam(nam, "failed to open %s for writing: %e", args[0], errno);
+	zwarnnam(nam, "failed to open %s for %sing: %e", args[0],
+		 readlock ? "read" : "writ", errno);
 	return 1;
     }
     flock_fd = movefd(flock_fd);
-- 
2.38.1





Messages sorted by: Reverse Date, Date, Thread, Author