From 4c86540cb142d34250e18e98f7dca0645772e3bd Mon Sep 17 00:00:00 2001 From: Constantin Papizh <p.const@bk.ru> Date: Sat, 9 Nov 2019 23:52:20 +0300 Subject: [PATCH] possible strptime-concerned fix --- include/dap_strfuncs.h | 10 +--------- src/dap_common.c | 2 +- src/dap_strfuncs.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/dap_strfuncs.h b/include/dap_strfuncs.h index 4ea6871f90..1786c84e0e 100755 --- a/include/dap_strfuncs.h +++ b/include/dap_strfuncs.h @@ -74,15 +74,7 @@ char* dap_strdown(const char *a_str, ssize_t a_len); char* dap_strreverse(char *a_string); #ifdef _WIN32 -inline char *strndup(char *str, unsigned long len) { - char *buf = memchr(str, '\0', len); - if (buf) - len = buf - str; - buf = malloc(len + 1); - memcpy(buf, str, len); - buf[len] = '\0'; - return buf; -} +char *strndup(char *str, unsigned long len); #endif #define DAP_USEC_PER_SEC 1000000 diff --git a/src/dap_common.c b/src/dap_common.c index d3c10bbd1c..56bc9fd162 100755 --- a/src/dap_common.c +++ b/src/dap_common.c @@ -204,7 +204,7 @@ int dap_common_init( const char *a_console_title, const char *a_log_filename ) { // init randomer srand( (unsigned int)time(NULL) ); - //SetupConsole( a_console_title, L"Lucida Console", 12, 20 ); // TODO: remove this useless crap completely + (void) a_console_title; strncpy( s_log_tag_fmt_str, "[%s]\t",sizeof (s_log_tag_fmt_str)); for (int i = 0; i < 16; ++i) s_ansi_seq_color_len[i] =(unsigned int) strlen(s_ansi_seq_color[i]); diff --git a/src/dap_strfuncs.c b/src/dap_strfuncs.c index fee3ecdbed..eb7b677239 100755 --- a/src/dap_strfuncs.c +++ b/src/dap_strfuncs.c @@ -682,13 +682,23 @@ char* dap_strreverse(char *a_string) return a_string; } -#ifndef DAP_OS_UNIX +#ifdef _WIN32 char *strptime( char *buff, const char *fmt, struct tm *tm ) { uint32_t len = strlen( buff ); dap_sscanf( buff,"%u.%u.%u_%u.%u.%u",&tm->tm_year, &tm->tm_mon, &tm->tm_mday, &tm->tm_hour, &tm->tm_min, &tm->tm_sec ); tm->tm_year += 2000; return buff + len; } + +char *strndup(char *str, unsigned long len) { + char *buf = (char*)memchr(str, '\0', len); + if (buf) + len = buf - str; + buf = (char*)malloc(len + 1); + memcpy(buf, str, len); + buf[len] = '\0'; + return buf; +} #endif /** -- GitLab