Merge pull request #3255 from RaiKoHoff/Dev_Lexilla

Update component : "uthash"  v.2.3.0
This commit is contained in:
Rainer Kottenhoff 2021-04-01 20:05:29 +02:00 committed by GitHub
commit 86a2ca8c8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 94 deletions

View File

@ -158,8 +158,17 @@ static int msgcmp(void* mqc1, void* mqc2)
}
return 1;
}
static int sortcmp(void *mqc1, void *mqc2) {
const CmdMessageQueue_t *const pMQC1 = (CmdMessageQueue_t *)mqc1;
const CmdMessageQueue_t *const pMQC2 = (CmdMessageQueue_t *)mqc2;
return (pMQC1->delay - pMQC2->delay);
}
// ----------------------------------------------------------------------------
#define _MQ_TIMER_CYCLE (USER_TIMER_MINIMUM << 1)
#define _MQ_ms2cycl(T) (((T) + USER_TIMER_MINIMUM) / _MQ_TIMER_CYCLE)
#define _MQ_STD (_MQ_TIMER_CYCLE << 2)
@ -167,6 +176,7 @@ static int msgcmp(void* mqc1, void* mqc2)
static void _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles)
{
if (!pMsgQCmd) { return; }
cycles = clampi(cycles, 0, _MQ_ms2cycl(60000));
CmdMessageQueue_t* pmqc = NULL;
@ -189,27 +199,20 @@ static void _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles)
if (0 == cycles) {
PostMessage(pMsgQCmd->hwnd, pMsgQCmd->cmd, pMsgQCmd->wparam, pMsgQCmd->lparam);
}
//~DL_SORT(MessageQueue, sortcmp); // next scheduled first
}
// ----------------------------------------------------------------------------
/* unused yet
static void _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd)
{
CmdMessageQueue_t* pmqc = NULL;
DL_FOREACH(MessageQueue, pmqc)
{
if ((pMsgQCmd->hwnd == pmqc->hwnd)
&& (pMsgQCmd->cmd == pmqc->cmd)
&& (pMsgQCmd->wparam == pmqc->wparam)
&& (pMsgQCmd->lparam == pmqc->lparam)
) {
pmqc->delay = -1;
/* not used yet
static void _MQ_DropAll() {
CmdMessageQueue_t *pmqc = NULL;
DL_FOREACH(MessageQueue, pmqc) {
pmqc->delay = -1;
}
}
}
// ----------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
//
@ -223,13 +226,12 @@ static void CALLBACK MQ_ExecuteNext(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWOR
UNREFERENCED_PARAMETER(dwTime); // This is the value returned by the GetTickCount function
CmdMessageQueue_t *pmqc;
DL_FOREACH(MessageQueue, pmqc) {
if (pmqc->delay >= 0) {
--(pmqc->delay);
}
if (pmqc->delay == 0) {
SendMessage(pmqc->hwnd, pmqc->cmd, pmqc->wparam, pmqc->lparam);
PostMessage(pmqc->hwnd, pmqc->cmd, pmqc->wparam, pmqc->lparam);
}
}
}

View File

@ -452,7 +452,15 @@ static int msgcmp(void* mqc1, void* mqc2)
) {
return 0; // equal
}
return (pMQC1->delay < pMQC2->delay) ? -1 : 1;
return 1;
}
static int sortcmp(void *mqc1, void *mqc2) {
const CmdMessageQueue_t *const pMQC1 = (CmdMessageQueue_t *)mqc1;
const CmdMessageQueue_t *const pMQC2 = (CmdMessageQueue_t *)mqc2;
return (pMQC1->delay - pMQC2->delay);
}
// ----------------------------------------------------------------------------
@ -466,6 +474,7 @@ static int msgcmp(void* mqc1, void* mqc2)
static void _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles)
{
if (!pMsgQCmd) { return; }
cycles = clampi(cycles, 0, _MQ_ms2cycl(60000));
CmdMessageQueue_t* pmqc = NULL;
@ -485,28 +494,21 @@ static void _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles)
pmqc->delay = cycles;
}
}
if (0 == cycles) {
PostMessage(pMsgQCmd->hwnd, pMsgQCmd->cmd, pMsgQCmd->wparam, pMsgQCmd->lparam);
}
//~DL_SORT(MessageQueue, sortcmp); // next scheduled first
}
// ----------------------------------------------------------------------------
/* Not used yet
static void _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd)
/* not used yet
static void _MQ_DropAll()
{
CmdMessageQueue_t* pmqc;
DL_FOREACH(MessageQueue, pmqc)
{
if ((pMsgQCmd->cmd == pmqc->cmd)
&& (pMsgQCmd->hwnd == pmqc->hwnd)
&& (pMsgQCmd->wparam == pmqc->wparam)
&& (pMsgQCmd->lparam == pmqc->lparam))
CmdMessageQueue_t *pmqc = NULL;
DL_FOREACH(MessageQueue, pmqc)
{
pmqc->delay = -1;
pmqc->delay = -1;
}
}
}
*/
// ----------------------------------------------------------------------------
@ -524,13 +526,12 @@ static void CALLBACK MQ_ExecuteNext(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWOR
UNREFERENCED_PARAMETER(dwTime); // This is the value returned by the GetTickCount function
CmdMessageQueue_t* pmqc;
DL_FOREACH(MessageQueue, pmqc) {
if (pmqc->delay >= 0) {
--(pmqc->delay); // count down
}
if (pmqc->delay == 0) {
SendMessage(pmqc->hwnd, pmqc->cmd, pmqc->wparam, pmqc->lparam);
PostMessage(pmqc->hwnd, pmqc->cmd, pmqc->wparam, pmqc->lparam);
}
}
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2018, Troy D. Hanson https://troydhanson.github.com/uthash/
Copyright (c) 2008-2021, Troy D. Hanson http://troydhanson.github.io/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef UTARRAY_H
#define UTARRAY_H
#define UTARRAY_VERSION 2.1.0
#define UTARRAY_VERSION 2.3.0
#include <stddef.h> /* size_t */
#include <string.h> /* memset, etc */
@ -232,12 +232,13 @@ typedef struct {
/* last we pre-define a few icd for common utarrays of ints and strings */
static void utarray_str_cpy(void *dst, const void *src) {
char * const *_src = (char* const *)src, **_dst = (char**)dst;
*_dst = (*_src == NULL) ? NULL : _strdup(*_src);
char *const *srcc = (char *const *)src;
char **dstc = (char**)dst;
*dstc = (*srcc == NULL) ? NULL : _strdup(*srcc);
}
static void utarray_str_dtor(void *elt) {
char **eltc = (char**)elt;
if (*eltc != NULL) { free(*eltc); }
if (*eltc != NULL) free(*eltc);
}
static const UT_icd ut_str_icd UTARRAY_UNUSED = {sizeof(char*),NULL,utarray_str_cpy,utarray_str_dtor};
static const UT_icd ut_int_icd UTARRAY_UNUSED = {sizeof(int),NULL,NULL,NULL};

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2003-2018, Troy D. Hanson https://troydhanson.github.com/uthash/
Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.io/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -24,12 +24,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef UTHASH_H
#define UTHASH_H
#define UTHASH_VERSION 2.1.0
#define UTHASH_VERSION 2.3.0
#include <string.h> /* memcmp, memset, strlen */
#include <stddef.h> /* ptrdiff_t */
#include <stdlib.h> /* exit */
#if defined(HASH_DEFINE_OWN_STDINT) && HASH_DEFINE_OWN_STDINT
/* This codepath is provided for backward compatibility, but I plan to remove it. */
#warning "HASH_DEFINE_OWN_STDINT is deprecated; please use HASH_NO_STDINT instead"
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
#elif defined(HASH_NO_STDINT) && HASH_NO_STDINT
#else
#include <stdint.h> /* uint8_t, uint32_t */
#endif
/* These macros use decltype or the earlier __typeof GNU extension.
As decltype is only available in newer compilers (VS2010 or gcc 4.3+
when compiling c++ source) this code uses whatever method is needed
@ -62,23 +72,6 @@ do {
} while (0)
#endif
/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */
#if defined(_WIN32)
#if defined(_MSC_VER) && _MSC_VER >= 1600
#include <stdint.h>
#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__)
#include <stdint.h>
#else
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
#endif
#elif defined(__GNUC__) && !defined(__VXWORKS__)
#include <stdint.h>
#else
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
#endif
#ifndef uthash_malloc
#define uthash_malloc(sz) malloc(sz) /* malloc fcn */
#endif
@ -92,15 +85,12 @@ typedef unsigned char uint8_t;
#define uthash_strlen(s) strlen(s)
#endif
#ifdef uthash_memcmp
/* This warning will not catch programs that define uthash_memcmp AFTER including uthash.h. */
#warning "uthash_memcmp is deprecated; please use HASH_KEYCMP instead"
#else
#define uthash_memcmp(a,b,n) memcmp(a,b,n)
#ifndef HASH_FUNCTION
#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
#endif
#ifndef HASH_KEYCMP
#define HASH_KEYCMP(a,b,n) uthash_memcmp(a,b,n)
#define HASH_KEYCMP(a,b,n) memcmp(a,b,n)
#endif
#ifndef uthash_noexpand_fyi
@ -158,7 +148,7 @@ do {
#define HASH_VALUE(keyptr,keylen,hashv) \
do { \
HASH_FCN(keyptr, keylen, hashv); \
HASH_FUNCTION(keyptr, keylen, hashv); \
} while (0)
#define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \
@ -408,7 +398,7 @@ do {
do { \
IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \
(add)->hh.hashv = (hashval); \
(add)->hh.key = (char*) (keyptr); \
(add)->hh.key = (const void*) (keyptr); \
(add)->hh.keylen = (unsigned) (keylen_in); \
if (!(head)) { \
(add)->hh.next = NULL; \
@ -590,13 +580,6 @@ do {
#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)
#endif
/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */
#ifdef HASH_FUNCTION
#define HASH_FCN HASH_FUNCTION
#else
#define HASH_FCN HASH_JEN
#endif
/* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */
#define HASH_BER(key,keylen,hashv) \
do { \
@ -695,7 +678,8 @@ do {
case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \
case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \
case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \
case 1: _hj_i += _hj_key[0]; \
case 1: _hj_i += _hj_key[0]; /* FALLTHROUGH */ \
default: ; \
} \
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
} while (0)
@ -743,6 +727,8 @@ do {
case 1: hashv += *_sfh_key; \
hashv ^= hashv << 10; \
hashv += hashv >> 1; \
break; \
default: ; \
} \
\
/* Force "avalanching" of final 127 bits */ \
@ -850,12 +836,12 @@ do {
struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
_he_new_buckets = (UT_hash_bucket*)uthash_malloc( \
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \
if (!_he_new_buckets) { \
HASH_RECORD_OOM(oomed); \
} else { \
uthash_bzero(_he_new_buckets, \
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \
(tbl)->ideal_chain_maxlen = \
((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \
((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \
@ -1142,7 +1128,7 @@ typedef struct UT_hash_handle {
void *next; /* next element in app order */
struct UT_hash_handle *hh_prev; /* previous hh in bucket order */
struct UT_hash_handle *hh_next; /* next hh in bucket order */
void *key; /* ptr to enclosing struct's key */
const void *key; /* ptr to enclosing struct's key */
unsigned keylen; /* enclosing struct's key len */
unsigned hashv; /* result of hash-fcn(key) */
} UT_hash_handle;

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2007-2018, Troy D. Hanson https://troydhanson.github.com/uthash/
Copyright (c) 2007-2021, Troy D. Hanson http://troydhanson.github.io/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -24,7 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef UTLIST_H
#define UTLIST_H
#define UTLIST_VERSION 2.1.0
#define UTLIST_VERSION 2.3.0
#include <assert.h>
@ -438,7 +438,7 @@ do {
#define LL_SEARCH2(head,out,elt,cmp,next) \
do { \
LL_FOREACH2(head,out,next) { \
if ((cmp(out,elt)) == 0) break; \
if ((cmp(out,elt))==0) break; \
} \
} while (0)

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2015-2018, Troy D. Hanson https://troydhanson.github.com/uthash/
Copyright (c) 2015-2021, Troy D. Hanson http://troydhanson.github.io/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef UTRINGBUFFER_H
#define UTRINGBUFFER_H
#define UTRINGBUFFER_VERSION 2.1.0
#define UTRINGBUFFER_VERSION 2.3.0
#include <stdlib.h>
#include <string.h>

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2018-2018, Troy D. Hanson https://troydhanson.github.com/uthash/
Copyright (c) 2018-2021, Troy D. Hanson http://troydhanson.github.io/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -24,7 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef UTSTACK_H
#define UTSTACK_H
#define UTSTACK_VERSION 2.1.0
#define UTSTACK_VERSION 2.3.0
/*
* This file contains macros to manipulate a singly-linked list as a stack.

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2018, Troy D. Hanson https://troydhanson.github.com/uthash/
Copyright (c) 2008-2021, Troy D. Hanson http://troydhanson.github.io/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef UTSTRING_H
#define UTSTRING_H
#define UTSTRING_VERSION 2.1.0
#define UTSTRING_VERSION 2.3.0
#include <stdlib.h>
#include <string.h>
@ -215,7 +215,7 @@ UTSTRING_UNUSED static void _utstring_BuildTableR(
{
long i, j;
i = (long) P_NeedleLen - 1;
i = P_NeedleLen - 1;
j = i + 1;
P_KMP_Table[i + 1] = j;
while (i >= 0)
@ -260,7 +260,7 @@ UTSTRING_UNUSED static long _utstring_find(
/* Search from left to right. */
i = j = 0;
while ( (j < (long)P_HaystackLen) && (((P_HaystackLen - j) + i) >= P_NeedleLen) )
while ( (j < (int)P_HaystackLen) && (((P_HaystackLen - j) + i) >= P_NeedleLen) )
{
while ( (i > -1) && (P_Needle[i] != P_Haystack[j]) )
{
@ -292,11 +292,11 @@ UTSTRING_UNUSED static long _utstring_findR(
long V_FindPosition = -1;
/* Search from right to left. */
j = ((long)P_HaystackLen - 1);
i = ((long)P_NeedleLen - 1);
j = (P_HaystackLen - 1);
i = (P_NeedleLen - 1);
while ( (j >= 0) && (j >= i) )
{
while ( (i < (long)P_NeedleLen) && (P_Needle[i] != P_Haystack[j]) )
while ( (i < (int)P_NeedleLen) && (P_Needle[i] != P_Haystack[j]) )
{
i = P_KMP_Table[i + 1];
}
@ -328,16 +328,16 @@ UTSTRING_UNUSED static long utstring_find(
if (P_StartPosition < 0)
{
V_StartPosition = (long)s->i + P_StartPosition;
V_StartPosition = s->i + P_StartPosition;
}
else
{
V_StartPosition = P_StartPosition;
}
V_HaystackLen = (long)s->i - V_StartPosition;
V_HaystackLen = s->i - V_StartPosition;
if ( (V_HaystackLen >= (long) P_NeedleLen) && (P_NeedleLen > 0) )
{
V_KMP_Table = (long *)malloc(sizeof(long) * ((long)P_NeedleLen + 1));
V_KMP_Table = (long *)malloc(sizeof(long) * (P_NeedleLen + 1));
if (V_KMP_Table != NULL)
{
_utstring_BuildTable(P_Needle, P_NeedleLen, V_KMP_Table);
@ -374,7 +374,7 @@ UTSTRING_UNUSED static long utstring_findR(
if (P_StartPosition < 0)
{
V_StartPosition = (long)s->i + P_StartPosition;
V_StartPosition = s->i + P_StartPosition;
}
else
{