projects
/
CForFun.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
48e7eff
)
locks: printing date, what a hell in C :(
author
Gustavo Martin Morcuende
<gu.martinm@gmail.com>
Sun, 29 May 2016 18:33:10 +0000
(20:33 +0200)
committer
Gustavo Martin Morcuende
<gu.martinm@gmail.com>
Sun, 29 May 2016 18:33:10 +0000
(20:33 +0200)
locks/locks.c
patch
|
blob
|
history
diff --git
a/locks/locks.c
b/locks/locks.c
index
13661cd
..
75b8e16
100644
(file)
--- a/
locks/locks.c
+++ b/
locks/locks.c
@@
-183,7
+183,8
@@
int print_with_date(FILE *stream, const char *format, ...)
va_list arg;
int done;
time_t rawtime;
- char buff[50];
+ char buff[100];
+ char msg[50];
char dateformatter[100] = "%s: ";
struct tm timeinfo;
@@
-192,8
+193,11
@@
int print_with_date(FILE *stream, const char *format, ...)
strftime(buff, 50, "%Y-%m-%d %H:%M:%S", &timeinfo);
va_start (arg, format);
- strcat(dateformatter, format);
- done = fprintf (stream, dateformatter, buff, arg);
+ vsnprintf (msg , 50, format, arg);
+
+ strcat(dateformatter, msg);
+ done = fprintf (stream, dateformatter, buff, msg);
+ va_end (arg);
if (done < 0) {
fflush (stream);