Re: json ouput is striping the last character of the year on Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/19/2016 03:40 PM, Chris Taylor wrote:
On Windows the year is not correct when using JSON output.

  "time" : "Mon Sep 19 17:21:45 201",

diff --git a/stat.c b/stat.c
index c9148ad..0c64333 100644
--- a/stat.c
+++ b/stat.c
@@ -1650,7 +1650,9 @@ void __show_run_stats(void)

                os_ctime_r((const time_t *) &now.tv_sec, time_buf,
                                sizeof(time_buf));
-               time_buf[strlen(time_buf) - 1] = '\0';
+               #if !defined(WIN32)
+                    time_buf[strlen(time_buf) - 1] = '\0';
+                #endif

It's meant to strip the \n from the buffer, looks like the windows
version doesn't do that. The below should be a better fix, does it work
for you?


diff --git a/os/windows/posix.c b/os/windows/posix.c
index 5830e4c4edab..3388127821ac 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -250,7 +250,7 @@ char* ctime_r(const time_t *t, char *buf)

     Time_tToSystemTime(*t, &systime);
/* We don't know how long `buf` is, but assume it's rounded up from the minimum of 25 to 32 */ - StringCchPrintfA(buf, 31, "%s %s %d %02d:%02d:%02d %04d", dayOfWeek[systime.wDayOfWeek % 7], monthOfYear[(systime.wMonth - 1) % 12], + StringCchPrintfA(buf, 31, "%s %s %d %02d:%02d:%02d %04d\n", dayOfWeek[systime.wDayOfWeek % 7], monthOfYear[(systime.wMonth - 1) % 12], systime.wDay, systime.wHour, systime.wMinute, systime.wSecond, systime.wYear);
     return buf;
 }

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux