Skip to content

Commit

Permalink
Added INT_MIN and INT_MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Jan 10, 2024
1 parent 6750d77 commit b76da38
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Rename change._tasks in C code, no user impact.
* Replaced Docker images _(both tests and builds)_ with newer versions.
* Removed `ti_pkg_check` hack for old compilers _(no longer required with recent compilers)_.
* Added `INT_MIN` and `INT_MAX` fixed keywords with corresponding values.

# v1.4.16

Expand Down
3 changes: 3 additions & 0 deletions inc/ti/fn/fnnewbackup.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ static int do__f_new_backup(ti_query_t * query, cleri_node_t * nd, ex_t * e)

if (!ti_raw_endswith(rname, tar_gz_str))
{
/* The ti_backup_is_gcloud() function depends on a filename size of at
* least 5 characters, this ensures 7 characters;
*/
ex_set(e, EX_VALUE_ERROR,
"expecting a backup file-name to end with `%.*s`"
DOC_NEW_BACKUP, tar_gz_str->n, (char *) tar_gz_str->data);
Expand Down
2 changes: 1 addition & 1 deletion inc/ti/forloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef int (*ti_forloop_t) (
cleri_node_t *,
ex_t *);

static ti_forloop_t ti_forloop_callbacks[21] = {
static const ti_forloop_t ti_forloop_callbacks[21] = {
ti_forloop_no_iter, /* TI_VAL_NIL */
ti_forloop_no_iter, /* TI_VAL_INT */
ti_forloop_no_iter, /* TI_VAL_FLOAT */
Expand Down
1 change: 1 addition & 0 deletions inc/ti/val.t.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* Both copy() and dup() use the following code to set the default deep value:
* !(type & 0x4); THING/WRAP: 1 ARR/SET: 0
* Be careful when changing the order in the enumerator.
* The ti_forloop_t also depends on the order in this enumerator;
*/
typedef enum
{
Expand Down
2 changes: 1 addition & 1 deletion inc/ti/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* "-rc0"
* ""
*/
#define TI_VERSION_PRE_RELEASE "-alpha4"
#define TI_VERSION_PRE_RELEASE "-alpha5"

#define TI_MAINTAINER \
"Jeroen van der Heijden <jeroen@cesbit.com>"
Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* author/maintainer : Jeroen van der Heijden <jeroen@cesbit.com>
* home page : https://thingsdb.net
* copyright : 2021, Jeroen van der Heijden
* copyright : 2024, Jeroen van der Heijden
*
* This code will be release as open source but the exact license might be
* changed to something else than MIT.
Expand Down
5 changes: 4 additions & 1 deletion src/ti/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ ti_val_t * ti_backup_as_mpval(ti_backup_t * backup)
_Bool ti_backup_is_gcloud(ti_backup_t * backup)
{
char * s = backup->fn_template;

/*
* This check depends on the test that each backup file ends
* with ".tar.gz" and therefore must have a length of at least seven;
*/
return s[0] == 'g' &&
s[1] == 's' &&
s[2] == ':' &&
Expand Down
60 changes: 31 additions & 29 deletions src/ti/do.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,11 +860,11 @@ int ti_do_closure(ti_query_t * query, cleri_node_t * nd, ex_t * e)

enum
{
TOTAL_KEYWORDS = 13,
TOTAL_KEYWORDS = 15,
MIN_WORD_LENGTH = 3,
MAX_WORD_LENGTH = 8,
MIN_HASH_VALUE = 3,
MAX_HASH_VALUE = 15
MAX_HASH_VALUE = 17
};

static inline unsigned int do__hash(
Expand All @@ -873,32 +873,32 @@ static inline unsigned int do__hash(
{
static unsigned char asso_values[] =
{
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 1, 5, 1, 4, 0,
3, 1, 3, 0, 5, 16, 2, 16, 0, 1,
16, 0, 0, 0, 0, 0, 16, 0, 16, 0,
16, 16, 16, 16, 16, 3, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 2, 2, 2, 9, 0,
6, 1, 3, 0, 8, 18, 1, 0, 0, 1,
18, 0, 0, 0, 0, 0, 18, 0, 0, 0,
18, 18, 18, 18, 18, 0, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18
};

register unsigned int hval = n;
Expand Down Expand Up @@ -937,7 +937,7 @@ static inline unsigned int do__hash(
typedef struct
{
char name[MAX_WORD_LENGTH+1];
int value;
int64_t value;
ti_val_t * val;
size_t n;
} do__fixed_t;
Expand All @@ -956,6 +956,8 @@ do__fixed_t do__fixed_mapping[TOTAL_KEYWORDS] = {
{.name="ERROR", .value=LOGGER_ERROR},
{.name="CRITICAL", .value=LOGGER_CRITICAL},
{.name="NO_IDS", .value=TI_FLAGS_NO_IDS},
{.name="INT_MIN", .value=LLONG_MIN},
{.name="INT_MAX", .value=LLONG_MAX},
};

static do__fixed_t * do__fixed_map[MAX_HASH_VALUE+1];
Expand Down

0 comments on commit b76da38

Please sign in to comment.