From e0ee49d2961ca8480d79f3d34b8c6a67f987f7bd Mon Sep 17 00:00:00 2001 From: gambas Date: Tue, 15 Dec 2020 17:19:38 +0100 Subject: [PATCH] Fix the standard date format, to ensure that 'IsDate(Str(Now))' is always TRUE. [INTERPRETER] * BUG: Fix the standard date format, to ensure that 'IsDate(Str(Now))' is always TRUE. --- main/gbx/gbx_local.c | 4 ++-- main/gbx/gbx_string.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/main/gbx/gbx_local.c b/main/gbx/gbx_local.c index a539d026b..0e5905bbb 100644 --- a/main/gbx/gbx_local.c +++ b/main/gbx/gbx_local.c @@ -852,9 +852,9 @@ static void fill_local_info(void) STRING_free(&fmt); - LOCAL_local.standard_date = STRING_new(LOCAL_local.medium_date, STRING_length(LOCAL_local.medium_date)); + LOCAL_local.standard_date = STRING_copy(LOCAL_local.medium_date); LOCAL_local.standard_date = STRING_add_char(LOCAL_local.standard_date, ' '); - LOCAL_local.standard_date = STRING_add(LOCAL_local.standard_date, LOCAL_local.medium_time, STRING_length(LOCAL_local.medium_time)); + LOCAL_local.standard_date = STRING_add_string(LOCAL_local.standard_date, LOCAL_local.long_time); #ifdef DEBUG_DATE fprintf(stderr, "date_tail_sep = %d\n", LOCAL_local.date_tail_sep); diff --git a/main/gbx/gbx_string.h b/main/gbx/gbx_string.h index f6aaf827d..9f77a105c 100644 --- a/main/gbx/gbx_string.h +++ b/main/gbx/gbx_string.h @@ -62,6 +62,9 @@ typedef #define SC_UNICODE ((char *)-1) #define SC_UTF8 ((char *)-2) +#define STRING_from_ptr(_ptr) ((STRING *)((_ptr) - offsetof(STRING, data))) +#define STRING_length(_ptr) ((_ptr) == NULL ? 0 : STRING_from_ptr(_ptr)->len) + #ifndef __STRING_C extern STRING_MAKE STRING_make_buffer; extern const char STRING_char_table[]; @@ -84,6 +87,7 @@ int STRING_get_free_index(void); #define STRING_new_temp(_src, _len) STRING_free_later(STRING_new(_src, _len)) #define STRING_new_temp_zero(_src) STRING_free_later(STRING_new_zero(_src)) +#define STRING_copy(_src) STRING_new((_src), STRING_length(_src)) char *STRING_extend(char *str, int new_len); bool STRING_extend_will_realloc(char *str, int new_len); @@ -92,6 +96,7 @@ bool STRING_extend_will_realloc(char *str, int new_len); char *STRING_add(char *str, const char *src, int len); #define STRING_add_zero(_str, _src) STRING_add((_str), (_src), -1) char *STRING_add_char(char *str, char c); +#define STRING_add_string(_str, _add) STRING_add((_str), (_add), STRING_length(_add)) #define STRING_extend_end(_str) \ do { \ @@ -147,9 +152,6 @@ int STRING_conv(char **result, const char *str, int len, const char *src, const char *STRING_conv_file_name(const char *name, int len); char *STRING_conv_to_UTF8(const char *name, int len); -#define STRING_from_ptr(_ptr) ((STRING *)((_ptr) - offsetof(STRING, data))) -#define STRING_length(_ptr) ((_ptr) == NULL ? 0 : STRING_from_ptr(_ptr)->len) - #if DEBUG_STRING #ifndef __STRING_C @@ -206,7 +208,6 @@ void STRING_unref_real(char **ptr); void STRING_unref_keep(char **ptr); int STRING_search(const char *ps, int ls, const char *pp, int lp, int is, bool right, bool nocase); -int STRING_search2(const char *ps, int ls, const char *pp, int lp, int is, bool right, bool nocase); void STRING_start_len(int len); #define STRING_start() STRING_start_len(0)