Skip to content
Snippets Groups Projects
Commit 80595fe5 authored by gambas's avatar gambas
Browse files

Finish fixing thousand separator bug.

[INTERPRETER]
* BUG: Finish fixing thousand separator bug.
parent 6f6224a9
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,7 @@
#define get_current COMMON_get_current
#define buffer_pos COMMON_pos
#define get_size_left COMMON_get_size_left
#define has_string COMMON_has_string
#define IS_PURE_INTEGER(_int64_val) ((_int64_val) == ((int)(_int64_val)))
......@@ -54,11 +55,13 @@ static bool read_integer(int base, bool minus, int64_t *result, bool local)
{
uint64_t nbr2, nbr;
int d, n, c, nmax;
char thsep;
const char *thsep;
int lthsep;
int ndigit_thsep;
bool first_thsep;
thsep = LOCAL_get(local)->thousand_sep;
lthsep = LOCAL_get(local)->len_thousand_sep;
ndigit_thsep = 0;
first_thsep = FALSE;
......@@ -81,8 +84,9 @@ static bool read_integer(int base, bool minus, int64_t *result, bool local)
{
if (local)
{
if (c == thsep && (ndigit_thsep == 3 || (!first_thsep && ndigit_thsep >= 1 && ndigit_thsep <= 3)))
if (has_string(thsep, lthsep) && (ndigit_thsep == 3 || (!first_thsep && ndigit_thsep >= 1 && ndigit_thsep <= 3)))
{
COMMON_pos += lthsep;
c = get_char();
first_thsep = TRUE;
ndigit_thsep = 0;
......@@ -184,7 +188,8 @@ static bool read_float(double *result, bool local)
{
LOCAL_INFO *local_info;
char point;
char thsep;
const char *thsep;
int lthsep;
int ndigit_thsep;
bool first_thsep;
int c, n;
......@@ -201,6 +206,7 @@ static bool read_float(double *result, bool local)
local_info = LOCAL_get(local);
point = local_info->decimal_point;
thsep = local_info->thousand_sep;
lthsep = local_info->len_thousand_sep;
ndigit_thsep = 0;
first_thsep = FALSE;
......@@ -231,11 +237,12 @@ static bool read_float(double *result, bool local)
if (local && !frac)
{
if (c == thsep && (ndigit_thsep == 3 || (!first_thsep && ndigit_thsep >= 1 && ndigit_thsep <= 3)))
if (has_string(thsep, lthsep) && (ndigit_thsep == 3 || (!first_thsep && ndigit_thsep >= 1 && ndigit_thsep <= 3)))
{
c = get_char();
COMMON_pos += lthsep;
first_thsep = TRUE;
ndigit_thsep = 0;
c = get_char();
}
}
......
......@@ -24,7 +24,7 @@
#ifndef __GB_COMMON_BUFFER_H
#define __GB_COMMON_BUFFER_H
#define COMMON_BUF_MAX 256
#define COMMON_BUF_MAX 512
#ifndef __COMMON_BUFFER_C
EXTERN int COMMON_pos;
......@@ -42,4 +42,5 @@ int COMMON_put_char(char c);
void COMMON_jump_space(void);
char *COMMON_get_current(void);
int COMMON_get_size_left(void);
bool COMMON_has_string(const char *str, int len);
#endif
......@@ -24,17 +24,18 @@
#define __COMMON_BUFFER_C
#include "gb_common.h"
#include "gb_common_buffer.h"
char COMMON_buffer[256];
char COMMON_buffer[COMMON_BUF_MAX];
int COMMON_pos;
int COMMON_len;
static char *common_buffer;
static int common_last;
void COMMON_buffer_init(char *str, int len)
void COMMON_buffer_init(const char *str, int len)
{
common_buffer = str;
common_buffer = (char *)str;
COMMON_len = len;
COMMON_pos = 0;
common_last = (-1);
......@@ -103,3 +104,10 @@ int COMMON_get_size_left(void)
}
bool COMMON_has_string(const char *str, int len)
{
if (COMMON_get_size_left() > len)
return FALSE;
return memcmp(&common_buffer[COMMON_pos], str, len) == 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment