diff --git a/main/gbx/gbx_date.c b/main/gbx/gbx_date.c index 46a4290ed..d09f2e944 100644 --- a/main/gbx/gbx_date.c +++ b/main/gbx/gbx_date.c @@ -42,16 +42,6 @@ //#define DEBUG_DATE -#define buffer_init COMMON_buffer_init -#define get_char COMMON_get_char -#define last_char COMMON_last_char -#define look_char COMMON_look_char -#define put_char COMMON_put_char -#define jump_space COMMON_jump_space -#define get_current COMMON_get_current -#define buffer_pos COMMON_pos -#define get_size_left COMMON_get_size_left - static const char days_in_months[2][13] = { /* error, jan feb mar apr may jun jul aug sep oct nov dec */ { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, @@ -362,15 +352,15 @@ static bool read_integer(int *number, bool *zero) int c; bool minus = FALSE; - c = get_char(); + c = COMMON_get_char(); if (c == '-') { minus = TRUE; - c = get_char(); + c = COMMON_get_char(); } else if (c == '+') - c = get_char(); + c = COMMON_get_char(); if ((c < 0) || !isdigit(c)) return TRUE; @@ -385,11 +375,11 @@ static bool read_integer(int *number, bool *zero) return TRUE; nbr = nbr2; - c = look_char(); + c = COMMON_look_char(); if ((c < 0) || !isdigit(c)) break; - buffer_pos++; + COMMON_pos++; } if (minus) @@ -407,7 +397,7 @@ static bool read_msec(int *number) int c; int i; - c = get_char(); + c = COMMON_get_char(); if ((c < 0) || !isdigit(c)) return TRUE; @@ -424,11 +414,11 @@ static bool read_msec(int *number) if (i == 3) break; - c = look_char(); + c = COMMON_look_char(); if ((c < 0) || !isdigit(c)) break; - buffer_pos++; + COMMON_pos++; } for (; i < 3; i++) @@ -488,8 +478,8 @@ bool DATE_from_string(const char *str, int len, VALUE *val, bool local) CLEAR(&date); - buffer_init(str, len); - jump_space(); + COMMON_buffer_init(str, len); + COMMON_jump_space(); if (read_integer(&nbr, &zero)) return TRUE; @@ -540,9 +530,9 @@ bool DATE_from_string(const char *str, int len, VALUE *val, bool local) set_date(&date, info->date_order[i], nbr2, zero2); } - jump_space(); + COMMON_jump_space(); - c = look_char(); + c = COMMON_look_char(); if (c < 0) goto _OK; @@ -574,9 +564,10 @@ bool DATE_from_string(const char *str, int len, VALUE *val, bool local) set_time(&date, info->time_order[2], nbr); - c = get_char(); + c = COMMON_look_char(); if (c == '.') // msec separator { + COMMON_pos++; if (read_msec(&nbr)) return TRUE; date.msec = nbr; @@ -601,7 +592,7 @@ bool DATE_from_string(const char *str, int len, VALUE *val, bool local) set_time(&date, info->time_order[i], nbr2); } - c = get_char(); + c = COMMON_get_char(); if ((c < 0) || isspace(c)) goto _OK; } diff --git a/main/gbx/gbx_local.c b/main/gbx/gbx_local.c index b7f05b4f8..5f91aab0c 100644 --- a/main/gbx/gbx_local.c +++ b/main/gbx/gbx_local.c @@ -162,14 +162,14 @@ static void end(char **str, int *len) *len = COMMON_pos; } - -#define stradd_sep(_dst, _src, _sep) \ -{ \ - if (LOCAL_local._dst) \ - LOCAL_local._dst = STRING_add_char(LOCAL_local._dst, _sep); \ - LOCAL_local._dst = STRING_add(LOCAL_local._dst, _src, strlen(_src)); \ +static void stradd_sep_real(char **dst, const char *src, char sep) +{ + if (*dst) + *dst = STRING_add_char(*dst, sep); + *dst = STRING_add(*dst, src, strlen(src)); } +#define stradd_sep(_dst, _src, _sep) stradd_sep_real(&LOCAL_local._dst, _src, _sep) static void add_thousand_sep(int *before) { @@ -472,11 +472,15 @@ static void fill_local_info(void) p += len - 1; } LOCAL_local.date_tail_sep = TRUE; - LOCAL_local.short_date = STRING_add_char(LOCAL_local.short_date, '/'); - LOCAL_local.general_date = STRING_add_char(LOCAL_local.general_date, '/'); } } + if (LOCAL_local.date_tail_sep) + { + LOCAL_local.short_date = STRING_add_char(LOCAL_local.short_date, '/'); + LOCAL_local.general_date = STRING_add_char(LOCAL_local.general_date, '/'); + } + LOCAL_local.date_many_sep = LOCAL_local.date_sep[LOCAL_local.date_order[0]] != LOCAL_local.date_sep[LOCAL_local.date_order[1]]; //fprintf(stderr, "date_tail_sep = %d date_many_sep = %d\n", LOCAL_local.date_tail_sep, LOCAL_local.date_many_sep); @@ -543,10 +547,12 @@ static void fill_local_info(void) p += len - 1; } LOCAL_local.time_tail_sep = TRUE; - LOCAL_local.long_time = STRING_add_char(LOCAL_local.long_time, ':'); } } + if (LOCAL_local.time_tail_sep) + LOCAL_local.long_time = STRING_add_char(LOCAL_local.long_time, ':'); + LOCAL_local.time_many_sep = LOCAL_local.time_sep[LOCAL_local.time_order[0]] != LOCAL_local.time_sep[LOCAL_local.time_order[1]]; // Fix missing seconds