Forgot to commit common header files.

[INTERPRETER]
* BUG: Forgot to commit common header files.
This commit is contained in:
gambas 2019-10-07 22:04:56 +02:00
parent 719f7967ad
commit e8ae38e098
4 changed files with 31 additions and 60 deletions

View File

@ -1,3 +1,3 @@
[Component]
Key=gb.db
Version=3.13.90
Version=3.14.90

View File

@ -1,7 +1,7 @@
# Gambas Project File 3.0
Title=gb.db
Startup=Main
Version=3.13.90
Version=3.14.90
VersionFile=1
Component=gb.db
TabSize=2

View File

@ -30,17 +30,35 @@
EXTERN int COMMON_pos;
EXTERN int COMMON_len;
EXTERN char COMMON_buffer[];
EXTERN char *COMMON_start;
EXTERN int COMMON_last;
#endif
void COMMON_init(void);
void COMMON_buffer_init(const char *str, int len);
int COMMON_get_char(void);
int COMMON_last_char(void);
int COMMON_look_char(void);
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);
#define COMMON_get_char(void) (COMMON_last = (COMMON_pos >= COMMON_len) ? (int)-1 : (int)(unsigned char)(COMMON_start[COMMON_pos++]))
#define COMMON_look_char() ((COMMON_pos >= COMMON_len) ? (int)-1 : (int)(unsigned char)(COMMON_start[COMMON_pos]))
#define COMMON_put_char(_c) \
({ \
if (COMMON_pos >= COMMON_len) \
(-1); \
else \
{ \
COMMON_start[COMMON_pos++] = (_c); \
0; \
} \
})
#define COMMON_last_char() (COMMON_last)
#define COMMON_get_current() (&COMMON_start[COMMON_pos])
#define COMMON_get_size_left(void) (COMMON_len - COMMON_pos)
#endif

View File

@ -30,51 +30,15 @@ char COMMON_buffer[COMMON_BUF_MAX];
int COMMON_pos;
int COMMON_len;
static char *common_buffer;
static int common_last;
char *COMMON_start;
int COMMON_last;
void COMMON_buffer_init(const char *str, int len)
{
common_buffer = (char *)str;
COMMON_start = (char *)str;
COMMON_len = len;
COMMON_pos = 0;
common_last = (-1);
}
int COMMON_look_char(void)
{
if (COMMON_pos >= COMMON_len)
return (-1);
return (unsigned char)(common_buffer[COMMON_pos]);
}
int COMMON_get_char(void)
{
if (COMMON_pos >= COMMON_len)
common_last = (-1);
else
common_last = (unsigned char)(common_buffer[COMMON_pos++]);
return common_last;
}
int COMMON_last_char(void)
{
return common_last;
}
int COMMON_put_char(char c)
{
if (COMMON_pos >= COMMON_len)
return (-1);
common_buffer[COMMON_pos++] = c;
return 0;
COMMON_last = (-1);
}
@ -92,22 +56,11 @@ void COMMON_jump_space(void)
}
char *COMMON_get_current(void)
{
return &common_buffer[COMMON_pos];
}
int COMMON_get_size_left(void)
{
return COMMON_len - COMMON_pos;
}
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;
return memcmp(&COMMON_start[COMMON_pos], str, len) == 0;
}