From 4bd0a6d4419bcc4b345f174ad494810085f7d24c Mon Sep 17 00:00:00 2001 From: Ali Riza KESKIN Date: Tue, 21 May 2024 10:54:35 +0000 Subject: [PATCH] print_fn fix parallel job write issue --- src/ccode/logger.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ccode/logger.c b/src/ccode/logger.c index beab6c4..e5257d5 100755 --- a/src/ccode/logger.c +++ b/src/ccode/logger.c @@ -10,6 +10,10 @@ void error_add(char* msg); int get_bool(char* val); void colorize_init(); +/* string add function*/ +char* str_add(char* s1, char* s2); + + /* headers of functions */ void cprint(char* msg); void cprint_stderr(char* msg); @@ -35,26 +39,19 @@ fn_logger debug_ptr = cprint_dummy; /* print functions area */ void print_fn(char* message, int new_line, int err){ - if(strcmp(message,"")==0){ - return; - } - int fd=1; - if(err){ - fd=2; - } - write(fd, message, strlen(message)); if(new_line){ - write(fd, "\n", 1); + message = str_add(message, "\n"); } + write(err+1, message, strlen(message)); } void cprint(char* message){ + message = str_add(message, "\n"); write(1, message, strlen(message)); - write(1, "\n", 1); } void cprint_stderr(char* message){ + message = str_add(message, "\n"); write(2, message, strlen(message)); - write(2, "\n", 1); } void cprint_dummy(char* message){