From e8ae38e098b928c430c1b99d17dcfd3000c762b0 Mon Sep 17 00:00:00 2001 From: gambas Date: Mon, 7 Oct 2019 22:04:56 +0200 Subject: [PATCH] Forgot to commit common header files. [INTERPRETER] * BUG: Forgot to commit common header files. --- main/lib/db/gb.db/.component | 2 +- main/lib/db/gb.db/.project | 2 +- main/share/gb_common_buffer.h | 30 ++++++++++++---- main/share/gb_common_buffer_temp.h | 57 +++--------------------------- 4 files changed, 31 insertions(+), 60 deletions(-) diff --git a/main/lib/db/gb.db/.component b/main/lib/db/gb.db/.component index 2e639141b..fc97eac07 100644 --- a/main/lib/db/gb.db/.component +++ b/main/lib/db/gb.db/.component @@ -1,3 +1,3 @@ [Component] Key=gb.db -Version=3.13.90 +Version=3.14.90 diff --git a/main/lib/db/gb.db/.project b/main/lib/db/gb.db/.project index 44c094fa0..468747265 100644 --- a/main/lib/db/gb.db/.project +++ b/main/lib/db/gb.db/.project @@ -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 diff --git a/main/share/gb_common_buffer.h b/main/share/gb_common_buffer.h index 6d6fc6e93..85e1f6674 100644 --- a/main/share/gb_common_buffer.h +++ b/main/share/gb_common_buffer.h @@ -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 diff --git a/main/share/gb_common_buffer_temp.h b/main/share/gb_common_buffer_temp.h index 72113671d..077be052a 100644 --- a/main/share/gb_common_buffer_temp.h +++ b/main/share/gb_common_buffer_temp.h @@ -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; }