repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
BugChecker
github_2023
vitoplantamura
c
scan_digit_nz
static inline limb_t scan_digit_nz(const bfdec_t *r, slimb_t bit_pos) { slimb_t pos; limb_t v, q; int shift; if (bit_pos < 0) return 0; pos = (limb_t)bit_pos / LIMB_DIGITS; shift = (limb_t)bit_pos % LIMB_DIGITS; fast_shr_rem_dec(q, v, r->tab[pos], shift + 1); (void)q; if (v ...
/* return != 0 if one digit between 0 and bit_pos inclusive is not zero. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L6295-L6316
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_get_rnd_add
static int bfdec_get_rnd_add(int *pret, const bfdec_t *r, limb_t l, slimb_t prec, int rnd_mode) { int add_one, inexact; limb_t digit1, digit0; // bfdec_print_str("get_rnd_add", r); if (rnd_mode == BF_RNDF) { digit0 = 1; /* faithful rounding does not honor the...
/* return the addend for rounding. Note that prec can be <= 0 for bf_rint() */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L6358-L6412
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
__bfdec_round
static int __bfdec_round(bfdec_t *r, limb_t prec1, bf_flags_t flags, limb_t l) { int shift, add_one, rnd_mode, ret; slimb_t i, bit_pos, pos, e_min, e_max, e_range, prec; /* XXX: align to IEEE 754 2008 for decimal numbers ? */ e_range = (limb_t)1 << (bf_get_exp_bits(flags) - 1); e_min = -e_range + 3...
/* round to prec1 bits assuming 'r' is non zero and finite. 'r' is assumed to have length 'l' (1 <= l <= r->len). prec1 can be BF_PREC_INF. BF_FLAG_SUBNORMAL is not supported. Cannot fail with BF_ST_MEM_ERROR. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L6419-L6516
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_round
int bfdec_round(bfdec_t *r, limb_t prec, bf_flags_t flags) { if (r->len == 0) return 0; return __bfdec_round(r, prec, flags, r->len); }
/* Cannot fail with BF_ST_MEM_ERROR. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L6519-L6524
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_normalize_and_round
int bfdec_normalize_and_round(bfdec_t *r, limb_t prec1, bf_flags_t flags) { limb_t l, v; int shift, ret; // bfdec_print_str("bf_renorm", r); l = r->len; while (l > 0 && r->tab[l - 1] == 0) l--; if (l == 0) { /* zero */ r->expn = BF_EXP_ZERO; bfdec_resize(r...
/* 'r' must be a finite number. Cannot fail with BF_ST_MEM_ERROR. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L6527-L6554
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_tdivremu
static void bfdec_tdivremu(bf_context_t *s, bfdec_t *q, bfdec_t *r, const bfdec_t *a, const bfdec_t *b) { if (bfdec_cmpu(a, b) < 0) { bfdec_set_ui(q, 0); bfdec_set(r, a); } else { bfdec_div(q, a, b, 0, BF_RNDZ | BF_FLAG_RADPNT_PREC); bfdec_mul(r, q, b, ...
/* a and b must be finite numbers with a >= 0 and b > 0. 'q' is the integer defined as floor(a/b) and r = a - q * b. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L6928-L6939
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_divrem
int bfdec_divrem(bfdec_t *q, bfdec_t *r, const bfdec_t *a, const bfdec_t *b, limb_t prec, bf_flags_t flags, int rnd_mode) { bf_context_t *s = q->ctx; bfdec_t a1_s, *a1 = &a1_s; bfdec_t b1_s, *b1 = &b1_s; bfdec_t r1_s, *r1 = &r1_s; int q_sign, res; BOOL is_ceil, is_rndn; ...
/* division and remainder. rnd_mode is the rounding mode for the quotient. The additional rounding mode BF_RND_EUCLIDIAN is supported. 'q' is an integer. 'r' is rounded with prec and flags (prec can be BF_PREC_INF). */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L6949-L7052
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_rint
int bfdec_rint(bfdec_t *r, int rnd_mode) { return bfdec_round(r, 0, rnd_mode | BF_FLAG_RADPNT_PREC); }
/* convert to integer (infinite precision) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7067-L7070
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_get_int32
int bfdec_get_int32(int *pres, const bfdec_t *a) { uint32_t v; int ret; if (a->expn >= BF_EXP_INF) { ret = 0; if (a->expn == BF_EXP_INF) { v = (uint32_t)INT32_MAX + a->sign; /* XXX: return overflow ? */ } else { v = INT32_MAX; } } else...
/* The rounding mode is always BF_RNDZ. Return BF_ST_OVERFLOW if there is an overflow and 0 otherwise. No memory error is possible. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7156-L7201
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bfdec_pow_ui
int bfdec_pow_ui(bfdec_t *r, const bfdec_t *a, limb_t b) { int ret, n_bits, i; assert(r != a); if (b == 0) return bfdec_set_ui(r, 1); ret = bfdec_set(r, a); n_bits = LIMB_BITS - clz(b); for(i = n_bits - 2; i >= 0; i--) { ret |= bfdec_mul(r, r, r, BF_PREC_INF, BF_RNDZ); ...
/* power to an integer with infinite precision */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7204-L7219
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
put_bits
static inline void put_bits(limb_t *tab, limb_t len, slimb_t pos, limb_t val) { limb_t i; int p; i = pos >> LIMB_LOG2_BITS; p = pos & (LIMB_BITS - 1); if (i < len) tab[i] |= val << p; if (p != 0) { i++; if (i < len) { tab[i] |= val >> (LIMB_BITS - p); ...
/***************************************************************/ /* Integer multiplication with FFT */ /* or LIMB_BITS at bit position 'pos' in tab */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7241-L7256
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
add_mod
static inline limb_t add_mod(limb_t a, limb_t b, limb_t m) { limb_t r; r = a + b; if (r >= m) r -= m; return r; }
/* add modulo with up to (LIMB_BITS-1) bit modulo */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7368-L7375
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
sub_mod
static inline limb_t sub_mod(limb_t a, limb_t b, limb_t m) { limb_t r; r = a - b; if (r > a) r += m; return r; }
/* sub modulo with up to LIMB_BITS bit modulo */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7378-L7385
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
mod_fast
static inline limb_t mod_fast(dlimb_t r, limb_t m, limb_t m_inv) { limb_t a1, q, t0, r1, r0; a1 = r >> NTT_MOD_LOG2_MIN; q = ((dlimb_t)a1 * m_inv) >> LIMB_BITS; r = r - (dlimb_t)q * m - m * 2; r1 = r >> LIMB_BITS; t0 = (slimb_t)r1 >> 1; r += m & t0;...
/* return (r0+r1*B) mod m precondition: 0 <= r0+r1*B < 2^(64+NTT_MOD_LOG2_MIN) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7390-L7406
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
mul_mod_fast
static inline limb_t mul_mod_fast(limb_t a, limb_t b, limb_t m, limb_t m_inv) { dlimb_t r; r = (dlimb_t)a * (dlimb_t)b; return mod_fast(r, m, m_inv); }
/* faster version using precomputed modulo inverse. precondition: 0 <= a * b < 2^(64+NTT_MOD_LOG2_MIN) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7410-L7416
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
mul_mod_fast2
static inline limb_t mul_mod_fast2(limb_t a, limb_t b, limb_t m, limb_t b_inv) { limb_t r, q; q = ((dlimb_t)a * (dlimb_t)b_inv) >> LIMB_BITS; r = a * b - q * m; if (r >= m) r -= m; return r; }
/* Faster version used when the multiplier is constant. 0 <= a < 2^64, 0 <= b < m. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7429-L7439
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
mul_mod_fast3
static inline limb_t mul_mod_fast3(limb_t a, limb_t b, limb_t m, limb_t b_inv) { limb_t r, q; q = ((dlimb_t)a * (dlimb_t)b_inv) >> LIMB_BITS; r = a * b - q * m; return r; }
/* Faster version used when the multiplier is constant. 0 <= a < 2^64, 0 <= b < m. Let r = a * b mod m. The return value is 'r' or 'r + m'. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7444-L7452
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
ntt_mod1
static inline __m256d ntt_mod1(__m256d r, __m256d m) { return _mm256_blendv_pd(r, r + m, r); }
/* return r + m if r < 0 otherwise r. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7485-L7488
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
ntt_mod
static inline __m256d ntt_mod(__m256d r, __m256d mf, __m256d m2f) { return _mm256_blendv_pd(r, r + m2f, r) - mf; }
/* input: abs(r) < 2 * m. Output: abs(r) < m */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7491-L7494
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
ntt_mul_mod
static inline __m256d ntt_mul_mod(__m256d a, __m256d b, __m256d mf, __m256d m_inv) { __m256d r, q, ab1, ab0, qm0, qm1; ab1 = a * b; q = _mm256_round_pd(ab1 * m_inv, 0); /* round to nearest */ qm1 = q * mf; qm0 = _mm256_fmsub_pd(q, mf, qm1); /* low part */ ab0 = ...
/* input: abs(a*b) < 2 * m^2, output: abs(r) < m */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7497-L7508
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
ntt_fft_partial
static int ntt_fft_partial(BFNTTState *s, NTTLimb *buf1, int k1, int k2, limb_t n1, limb_t n2, int inverse, limb_t m_idx) { limb_t i, j, c_mul, c0, m, m_inv, strip_len, l; NTTLimb *buf2, *buf3; buf2 = NULL; buf3 = ntt_malloc(s, sizeof(NTTLimb) *...
/* dst = buf1, src = buf2 */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7882-L7936
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
ntt_conv
static int ntt_conv(BFNTTState *s, NTTLimb *buf1, NTTLimb *buf2, int k, int k_tot, limb_t m_idx) { limb_t n1, n2, i; int k1, k2; if (k <= NTT_TRIG_K_MAX) { k1 = k; } else { /* recursive split of the FFT */ k1 = bf_min(k / 2, NTT_TRIG_K_MAX); } k2 ...
/* dst = buf1, src = buf2, tmp = buf3 */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7940-L7970
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
fft_mul
static no_inline int fft_mul(bf_context_t *s1, bf_t *res, limb_t *a_tab, limb_t a_len, limb_t *b_tab, limb_t b_len, int mul_flags) { BFNTTState *s; int dpl, fft_len_log2, j, nb_mods, reduced_mem; slimb_t len, fft_len; NTTLimb *buf1, *buf2, *ptr; ...
/* return 0 if OK, -1 if memory error */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L8358-L8457
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
bf_get_fft_size
int bf_get_fft_size(int *pdpl, int *pnb_mods, limb_t len) { return 0; }
/* USE_FFT_MUL */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L8461-L8464
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
dbuf_insert
static int dbuf_insert(DynBuf *s, int pos, int len) { if (dbuf_realloc(s, s->size + len)) return -1; memmove(s->buf + pos + len, s->buf + pos, s->size - pos); s->size += len; return 0; }
/* insert 'len' bytes at position 'pos'. Return < 0 if error. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L114-L121
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
lre_canonicalize
static uint32_t lre_canonicalize(uint32_t c, BOOL is_utf16) { uint32_t res[LRE_CC_RES_LEN_MAX]; int len; if (is_utf16) { if (likely(c < 128)) { if (c >= 'A' && c <= 'Z') c = c - 'A' + 'a'; } else { lre_case_conv(res, c, 2); c = res[0]; ...
/* canonicalize with the specific JS regexp rules */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L124-L148
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
re_emit_op_u32
static int re_emit_op_u32(REParseState *s, int op, uint32_t val) { int pos; dbuf_putc(&s->byte_code, op); pos = s->byte_code.size; dbuf_put_u32(&s->byte_code, val); return pos; }
/* return the offset of the u32 value */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L400-L407
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
parse_digits
static int parse_digits(const uint8_t **pp, BOOL allow_overflow) { const uint8_t *p; uint64_t v; int c; p = *pp; v = 0; for(;;) { c = *p; if (c < '0' || c > '9') break; v = v * 10 + c - '0'; if (v >= INT32_MAX) { if (allow_overflow) ...
/* If allow_overflow is false, return -1 in case of overflow. Otherwise return INT32_MAX. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L446-L469
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
lre_parse_escape
int lre_parse_escape(const uint8_t **pp, int allow_utf16) { const uint8_t *p; uint32_t c; p = *pp; c = *p++; switch(c) { case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; ...
/* Parse an escape sequence, *pp points after the '\': allow_utf16 value: 0 : no UTF-16 escapes allowed 1 : UTF-16 escapes allowed 2 : UTF-16 escapes allowed and escapes of surrogate pairs are converted to a unicode character (unicode regexp case). Return the unicode char and update *pp if recognized...
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L492-L601
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
is_unicode_char
static BOOL is_unicode_char(int c) { return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '_')); }
/* XXX: we use the same chars for name and value */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L605-L611
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
get_class_atom
static int get_class_atom(REParseState *s, CharRange *cr, const uint8_t **pp, BOOL inclass) { const uint8_t *p; uint32_t c; int ret; p = *pp; c = *p; switch(c) { case '\\': p++; if (p >= s->buf_end) goto unexpected_end; c = ...
/* CONFIG_ALL_UNICODE */ /* return -1 if error otherwise the character or a class range (CLASS_RANGE_BASE). In case of class range, 'cr' is initialized. Otherwise, it is ignored. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L711-L819
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
re_check_advance
static int re_check_advance(const uint8_t *bc_buf, int bc_buf_len) { int pos, opcode, ret, len, i; uint32_t val, last; BOOL has_back_reference; uint8_t capture_bitmap[CAPTURE_COUNT_MAX]; ret = -2; /* not known yet */ pos = 0; has_back_reference = FALSE; memset(capture_bitmap, 0, siz...
/* Return: 1 if the opcodes in bc_buf[] always advance the character pointer. 0 if the character pointer may not be advanced. -1 if the code may depend on side effects of its previous execution (backreference) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L950-L1030
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
re_is_simple_quantifier
static int re_is_simple_quantifier(const uint8_t *bc_buf, int bc_buf_len) { int pos, opcode, len, count; uint32_t val; count = 0; pos = 0; while (pos < bc_buf_len) { opcode = bc_buf[pos]; len = reopcode_info[opcode].size; switch(opcode) { case REOP_range: ...
/* return -1 if a simple quantifier cannot be used. Otherwise return the number of characters in the atom. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L1034-L1071
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
re_parse_group_name
static int re_parse_group_name(char *buf, int buf_size, const uint8_t **pp, BOOL is_utf16) { const uint8_t *p; uint32_t c; char *q; p = *pp; q = buf; for(;;) { c = *p; if (c == '\\') { p++; if (*p != 'u') ret...
/* '*pp' is the first char after '<' */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L1074-L1120
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
re_parse_captures
static int re_parse_captures(REParseState *s, int *phas_named_captures, const char *capture_name) { const uint8_t *p; int capture_index; char name[TMP_BUF_SIZE]; capture_index = 1; *phas_named_captures = 0; for (p = s->buf_start; p < s->buf_end; p++) { switc...
/* if capture_name = NULL: return the number of captures + 1. Otherwise, return the capture index corresponding to capture_name or -1 if none */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L1125-L1175
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
compute_stack_size
static int compute_stack_size(const uint8_t *bc_buf, int bc_buf_len) { int stack_size, stack_size_max, pos, opcode, len; uint32_t val; stack_size = 0; stack_size_max = 0; bc_buf += RE_HEADER_LEN; bc_buf_len -= RE_HEADER_LEN; pos = 0; while (pos < bc_buf_len) { opcode = bc_bu...
/* the control flow is recursive so the analysis can be linear */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L1773-L1815
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
lre_exec_backtrack
static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture, StackInt *stack, int stack_len, const uint8_t *pc, const uint8_t *cptr, BOOL no_recurse) { int opcode, ret; int cbuf_type; uint32_t...
/* return 1 if match, 0 if not match or -1 if error. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L2089-L2494
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
lre_exec
int lre_exec(uint8_t **capture, const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen, int cbuf_type, void *opaque) { REExecContext s_s, *s = &s_s; int re_flags, i, alloca_size, ret; StackInt *stack_buf; re_flags = bc_buf[RE_HEADER_FLAGS]; s->multi_line = (r...
/* Return 1 if match, 0 if not match or -1 if error. cindex is the starting position of the match and must be such as 0 <= cindex <= clen. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libregexp.c#L2499-L2535
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
lre_case_conv
int lre_case_conv(uint32_t *res, uint32_t c, int conv_type) { if (c < 128) { if (conv_type) { if (c >= 'A' && c <= 'Z') { c = c - 'A' + 'a'; } } else { if (c >= 'a' && c <= 'z') { c = c - 'a' + 'A'; } } } els...
/* conv_type: 0 = to upper 1 = to lower 2 = case folding (= to lower with modifications) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L56-L158
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
get_index_pos
static int get_index_pos(uint32_t *pcode, uint32_t c, const uint8_t *index_table, int index_table_len) { uint32_t code, v; int idx_min, idx_max, idx; idx_min = 0; v = get_le24(index_table); code = v & ((1 << 21) - 1); if (c < code) { *pcode = 0; return 0...
/* return -1 if not in table, otherwise the offset in the block */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L172-L203
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
cr_dump
static __maybe_unused void cr_dump(CharRange *cr) { int i; for(i = 0; i < cr->len; i++) printf("%d: 0x%04x\n", i, cr->points[i]); }
/* character range */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L274-L279
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
cr_compress
static void cr_compress(CharRange *cr) { int i, j, k, len; uint32_t *pt; pt = cr->points; len = cr->len; i = 0; j = 0; k = 0; while ((i + 1) < len) { if (pt[i] == pt[i + 1]) { /* empty interval */ i += 2; } else { j = i; ...
/* merge consecutive intervals and remove empty intervals */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L326-L352
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
cr_op
int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len, const uint32_t *b_pt, int b_len, int op) { int a_idx, b_idx, is_in; uint32_t v; a_idx = 0; b_idx = 0; for(;;) { /* get one more point from a or b in increasing order */ if (a_idx < a_len && b_idx < b_len) { ...
/* union or intersection */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L355-L405
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_decomp_char
static int unicode_decomp_char(uint32_t *res, uint32_t c, BOOL is_compat1) { uint32_t v, type, is_compat, code, len; int idx_min, idx_max, idx; idx_min = 0; idx_max = countof(unicode_decomp_table1) - 1; while (idx_min <= idx_max) { idx = (idx_max + idx_min) / 2; v = unicode_deco...
/* return the length of the decomposition (length <= UNICODE_DECOMP_LEN_MAX) or 0 if no decomposition */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L657-L683
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_compose_pair
static int unicode_compose_pair(uint32_t c0, uint32_t c1) { uint32_t code, len, type, v, idx1, d_idx, d_offset, ch; int idx_min, idx_max, idx, d; uint32_t pair[2]; idx_min = 0; idx_max = countof(unicode_comp_table) - 1; while (idx_min <= idx_max) { idx = (idx_max + idx_min) / 2; ...
/* return 0 if no pair found */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L686-L719
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_get_cc
static int unicode_get_cc(uint32_t c) { uint32_t code, n, type, cc, c1, b; int pos; const uint8_t *p; pos = get_index_pos(&code, c, unicode_cc_index, sizeof(unicode_cc_index) / 3); if (pos < 0) return 0; p = unicode_cc_table + pos; for(;;) { b = *...
/* return the combining class of character c (between 0 and 255) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L722-L771
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
compose_pair
static int compose_pair(uint32_t c0, uint32_t c1) { /* Hangul composition */ if (c0 >= 0x1100 && c0 < 0x1100 + 19 && c1 >= 0x1161 && c1 < 0x1161 + 21) { return 0xac00 + (c0 - 0x1100) * 588 + (c1 - 0x1161) * 28; } else if (c0 >= 0xac00 && c0 < 0xac00 + 11172 && (c0 - 0xac00) % ...
/* return 0 if not found */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L838-L851
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_find_name
static int unicode_find_name(const char *name_table, const char *name) { const char *p, *r; int pos; size_t name_len, len; p = name_table; pos = 0; name_len = strlen(name); while (*p) { for(;;) { r = strchr(p, ','); if (!r) len = strlen(p)...
/* char ranges for various unicode properties */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L928-L953
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_script
int unicode_script(CharRange *cr, const char *script_name, BOOL is_ext) { int script_idx; const uint8_t *p, *p_end; uint32_t c, c1, b, n, v, v_len, i, type; CharRange cr1_s, *cr1; CharRange cr2_s, *cr2 = &cr2_s; BOOL is_common; script_idx = unicode_find_name(unicode_s...
/* 'cr' must be initialized and empty. Return 0 if OK, -1 if error, -2 if not found */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L957-L1073
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_case1
static int unicode_case1(CharRange *cr, int case_mask) { #define MR(x) (1 << RUN_TYPE_ ## x) const uint32_t tab_run_mask[3] = { MR(U) | MR(UF) | MR(UL) | MR(LSU) | MR(U2L_399_EXT2) | MR(UF_D20) | MR(UF_D1_EXT) | MR(U_EXT) | MR(U_EXT2) | MR(U_EXT3), MR(L) | MR(LF) | MR(UL) | MR(LSU) | MR(U2L...
/* use the case conversion table to generate range of characters. CASE_U: set char if modified by uppercasing, CASE_L: set char if modified by lowercasing, CASE_F: set char if modified by case folding, */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L1177-L1238
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_general_category
int unicode_general_category(CharRange *cr, const char *gc_name) { int gc_idx; uint32_t gc_mask; gc_idx = unicode_find_name(unicode_gc_name_table, gc_name); if (gc_idx < 0) return -2; if (gc_idx <= UNICODE_GC_Co) { gc_mask = (uint64_t)1 << gc_idx; } else { gc_mask = ...
/* 'cr' must be initialized and empty. Return 0 if OK, -1 if error, -2 if not found */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L1341-L1355
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
unicode_prop
int unicode_prop(CharRange *cr, const char *prop_name) { int prop_idx, ret; prop_idx = unicode_find_name(unicode_prop_name_table, prop_name); if (prop_idx < 0) return -2; prop_idx += UNICODE_PROP_ASCII_Hex_Digit; ret = 0; switch(prop_idx) { case UNICODE_PROP_ASCII: if (...
/* 'cr' must be initialized and empty. Return 0 if OK, -1 if error, -2 if not found */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libunicode.c#L1360-L1554
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_loadScript
static JSValue js_loadScript(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint8_t *buf; const char *filename; JSValue ret; size_t buf_len; filename = JS_ToCString(ctx, argv[0]); if (!filename) return JS_EXCEPTION; buf = js_l...
/* load and evaluate a file */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L417-L439
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_std_loadFile
static JSValue js_std_loadFile(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint8_t *buf; const char *filename; JSValue ret; size_t buf_len; filename = JS_ToCString(ctx, argv[0]); if (!filename) return JS_EXCEPTION; buf = ...
/* load a file as a UTF-8 encoded string */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L442-L460
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_module_set_import_meta
int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val, JS_BOOL use_realpath, JS_BOOL is_main) { JSModuleDef *m; char buf[PATH_MAX + 16]; JSValue meta_obj; JSAtom module_name_atom; const char *module_name; assert(JS_VALUE_GET_TAG(func_val) == JS_TA...
/* !_WIN32 */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L524-L575
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_std_setenv
static JSValue js_std_setenv(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { const char *name, *value; name = JS_ToCString(ctx, argv[0]); if (!name) return JS_EXCEPTION; value = JS_ToCString(ctx, argv[1]); if (!value) { JS_FreeCString...
/* _WIN32 */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L658-L674
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_std_getenviron
static JSValue js_std_getenviron(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { char **envp; const char *name, *p, *value; JSValue obj; uint32_t idx; size_t name_len; JSAtom atom; int ret; obj = JS_NewObject(ctx); if (JS_IsExc...
/* return an object containing the list of the available environment variables. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L690-L725
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_std_file_getline
static JSValue js_std_file_getline(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { FILE *f = js_std_file_get(ctx, this_val); int c; DynBuf dbuf; JSValue obj; if (!f) return JS_EXCEPTION; js_std_dbuf_init(ctx, &dbuf); for...
/* XXX: could use less memory and go faster */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L1185-L1218
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_std_file_readAsString
static JSValue js_std_file_readAsString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { FILE *f = js_std_file_get(ctx, this_val); int c; DynBuf dbuf; JSValue obj; uint64_t max_size64; size_t max_size; JSValueConst max_size_val; ...
/* XXX: could use less memory and go faster */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L1221-L1261
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_open
static JSValue js_os_open(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { const char *filename; int flags, mode, ret; filename = JS_ToCString(ctx, argv[0]); if (!filename) return JS_EXCEPTION; if (JS_ToInt32(ctx, &flags, argv[1])) got...
/**********************************************************/ /* 'os' object */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L1580-L1608
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_ttySetRaw
static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { struct termios tty; int fd; if (JS_ToInt32(ctx, &fd, argv[0])) return JS_EXCEPTION; memset(&tty, 0, sizeof(tty)); tcgetattr(fd, &tty); oldtty = t...
/* XXX: should add a way to go back to normal mode */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L1754-L1780
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_remove
static JSValue js_os_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { const char *filename; int ret; filename = JS_ToCString(ctx, argv[0]); if (!filename) return JS_EXCEPTION; #if defined(_WIN32) { struct stat st; ...
/* !_WIN32 */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L1784-L1808
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
get_time_ms
static int64_t get_time_ms(void) { struct timeval tv; gettimeofday(&tv, NULL); return (int64_t)tv.tv_sec * 1000 + (tv.tv_usec / 1000); }
/* more portable, but does not work if the date is updated */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L1985-L1990
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
handle_posted_message
static int handle_posted_message(JSRuntime *rt, JSContext *ctx, JSWorkerMessageHandler *port) { JSWorkerMessagePipe *ps = port->recv_pipe; int ret; struct list_head *el; JSWorkerMessage *msg; JSValue obj, data_obj, func, retval; pthread_mutex_lock(&ps->mutex...
/* return 1 if a message was handled, 0 if no message */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2170-L2233
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
make_obj_error
static JSValue make_obj_error(JSContext *ctx, JSValue obj, int err) { JSValue arr; if (JS_IsException(obj)) return obj; arr = JS_NewArray(ctx); if (JS_IsException(arr)) return JS_EXCEPTION; JS_DefinePropertyValueUint32(ctx, ...
/* !_WIN32 */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2357-L2372
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_getcwd
static JSValue js_os_getcwd(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { char buf[PATH_MAX]; int err; if (!getcwd(buf, sizeof(buf))) { buf[0] = '\0'; err = errno; } else { err = 0; } return make_string_error(ctx, ...
/* return [cwd, errorcode] */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2382-L2395
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_readdir
static JSValue js_os_readdir(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { const char *path; DIR *f; struct dirent *d; JSValue obj; int err; uint32_t len; path = JS_ToCString(ctx, argv[0]); if (!path) return JS_EXCEPTION;...
/* return [array, errorcode] */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2437-L2478
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_stat
static JSValue js_os_stat(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int is_lstat) { const char *path; int err, res; struct stat st; JSValue obj; path = JS_ToCString(ctx, argv[0]); if (!path) return JS_EXCEPTION; #if defined(_WIN32) ...
/* return [obj, errcode] */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2488-L2588
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_sleep
static JSValue js_os_sleep(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int64_t delay; int ret; if (JS_ToInt64(ctx, &delay, argv[0])) return JS_EXCEPTION; if (delay < 0) delay = 0; #if defined(_WIN32) { if (delay > INT3...
/* sleep(delay_ms) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2632-L2659
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_realpath
static JSValue js_os_realpath(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { const char *path; char buf[PATH_MAX], *res; int err; path = JS_ToCString(ctx, argv[0]); if (!path) return JS_EXCEPTION; res = realpath(path, buf); JS_Fr...
/* return [path, errorcode] */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2674-L2693
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_readlink
static JSValue js_os_readlink(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { const char *path; char buf[PATH_MAX]; int err; ssize_t res; path = JS_ToCString(ctx, argv[0]); if (!path) return JS_EXCEPTION; res = readlink(path, ...
/* return [path, errorcode] */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2717-L2738
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
my_execvpe
static int my_execvpe(const char *filename, char **argv, char **envp) { char *path, *p, *p_next, *p1; char buf[PATH_MAX]; size_t filename_len, path_len; BOOL eacces_error; filename_len = strlen(filename); if (filename_len == 0) { errno = ENOENT; return -1; } if (strc...
/* execvpe is not available on non GNU systems */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2800-L2853
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_exec
static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { JSValueConst options, args = argv[0]; JSValue val, ret_val; const char **exec_argv, *file = NULL, *str, *cwd = NULL; char **envp = environ; uint32_t exec_argc, i; int ret, p...
/* exec(args[, options]) -> exitcode */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L2856-L3051
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_waitpid
static JSValue js_os_waitpid(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int pid, status, options, ret; JSValue obj; if (JS_ToInt32(ctx, &pid, argv[0])) return JS_EXCEPTION; if (JS_ToInt32(ctx, &options, argv[1])) return JS_EXC...
/* waitpid(pid, block) -> [pid, status] */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3054-L3079
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_pipe
static JSValue js_os_pipe(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int pipe_fds[2], ret; JSValue obj; ret = pipe(pipe_fds); if (ret < 0) return JS_NULL; obj = JS_NewArray(ctx); if (JS_IsException(obj)) return obj; J...
/* pipe() -> [read_fd, write_fd] or null if error */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3082-L3099
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_kill
static JSValue js_os_kill(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int pid, sig, ret; if (JS_ToInt32(ctx, &pid, argv[0])) return JS_EXCEPTION; if (JS_ToInt32(ctx, &sig, argv[1])) return JS_EXCEPTION; ret = js_get_errno(kill(pid...
/* kill(pid, sig) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3102-L3113
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_dup
static JSValue js_os_dup(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int fd, ret; if (JS_ToInt32(ctx, &fd, argv[0])) return JS_EXCEPTION; ret = js_get_errno(dup(fd)); return JS_NewInt32(ctx, ret); }
/* sleep(delay_ms) */ /*static JSValue js_os_sleep(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int64_t delay; struct timespec ts; int ret; if (JS_ToInt64(ctx, &delay, argv[0])) return JS_EXCEPTION; ts.tv_sec = delay / 1000; ts.tv_...
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3132-L3141
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_os_dup2
static JSValue js_os_dup2(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int fd, fd2, ret; if (JS_ToInt32(ctx, &fd, argv[0])) return JS_EXCEPTION; if (JS_ToInt32(ctx, &fd2, argv[1])) return JS_EXCEPTION; ret = js_get_errno(dup2(fd, fd...
/* dup2(fd) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3144-L3155
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_std_set_worker_new_context_func
void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt)) { #ifdef USE_WORKER js_worker_new_context_func = func; #endif }
/* USE_WORKER */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3597-L3602
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_print
static JSValue js_print(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int i; const char *str; size_t len; for(i = 0; i < argc; i++) { if (i != 0) putchar(' '); str = JS_ToCStringLen(ctx, &len, argv[i]); if (!str)...
/**********************************************************/
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3753-L3771
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_std_loop
void js_std_loop(JSContext *ctx) { JSContext *ctx1; int err; for(;;) { /* execute the pending jobs */ for(;;) { err = JS_ExecutePendingJob(JS_GetRuntime(ctx), &ctx1); if (err <= 0) { if (err < 0) { js_std_dump_error(ctx1); ...
/* main loop which calls the user JS callbacks */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs-libc.c#L3914-L3934
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_get_stack_pointer
static inline uintptr_t js_get_stack_pointer(void) { return 0; }
/* no stack limitation */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L1629-L1632
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_get_stack_pointer
static inline uintptr_t js_get_stack_pointer(void) { return (uintptr_t)__builtin_frame_address(0); }
/* Note: OS and CPU dependent */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L1640-L1643
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
JS_StringToBigInt
static JSValue JS_StringToBigInt(JSContext *ctx, JSValue val) { const char *str, *p; size_t len; int flags; str = JS_ToCStringLen(ctx, &len, val); JS_FreeValue(ctx, val); if (!str) return JS_EXCEPTION; p = str; p += skip_spaces(p); if ((p - str) == len) { val = JS_Ne...
/* return NaN if bad bigint literal */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L12296-L12325
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
JS_FreeBigInt
static void JS_FreeBigInt(JSContext *ctx, bf_t *a, bf_t *buf) { if (a == buf) { bf_delete(a); } else { JSBigFloat *p = (JSBigFloat *)((uint8_t *)a - offsetof(JSBigFloat, num)); JS_FreeValue(ctx, JS_MKPTR(JS_TAG_BIG_FLOAT, p)); } }
/* free the bf_t allocated by JS_ToBigInt */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L12439-L12448
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
JS_ToBigInt64Free
static int JS_ToBigInt64Free(JSContext *ctx, int64_t *pres, JSValue val) { bf_t a_s, *a; a = JS_ToBigIntFree(ctx, &a_s, val); if (!a) { *pres = 0; return -1; } bf_get_int64(pres, a, BF_GET_INT_MOD); JS_FreeBigInt(ctx, a, &a_s); return 0; }
/* XXX: merge with JS_ToInt64Free with a specific flag */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L12451-L12463
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
JS_CompactBigInt
static JSValue JS_CompactBigInt(JSContext *ctx, JSValue val) { return JS_CompactBigInt1(ctx, val, is_math_mode(ctx)); }
/* Convert the big int to a safe integer if in math mode. normalize the zero representation. Could also be used to convert the bigint to a short bigint value. The reference count of the value must be 1. Cannot fail */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L12539-L12542
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_call_binary_op_fallback
static __exception int js_call_binary_op_fallback(JSContext *ctx, JSValue *pret, JSValueConst op1, JSValueConst op2, OPC...
/* return -1 if exception, 0 if no operator overloading, 1 if overloaded operator called */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L12634-L12759
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_call_binary_op_simple
static __exception int js_call_binary_op_simple(JSContext *ctx, JSValue *pret, JSValueConst obj, JSValueConst op1, JSValueConst ...
/* try to call the operation on the operatorSet field of 'obj'. Only used for "/" and "**" on the BigInt prototype in math mode */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L12763-L12816
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_call_unary_op_fallback
static __exception int js_call_unary_op_fallback(JSContext *ctx, JSValue *pret, JSValueConst op1, OPCodeEnum op) { JSValue opset1_obj, method, ret; JSOperatorSetData...
/* return -1 if exception, 0 if no operator overloading, 1 if overloaded operator called */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L12820-L12865
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_bfdec_pow
static int js_bfdec_pow(bfdec_t *r, const bfdec_t *a, const bfdec_t *b) { bfdec_t b1; int32_t b2; int ret; bfdec_init(b->ctx, &b1); ret = bfdec_set(&b1, b); if (ret) { bfdec_delete(&b1); return ret; } ret = bfdec_rint(&b1, BF_RNDZ); if (ret) { bfdec_delete(&b...
/* b must be a positive integer */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L13397-L13421
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_compare_bigfloat
static int js_compare_bigfloat(JSContext *ctx, OPCodeEnum op, JSValue op1, JSValue op2) { bf_t a_s, b_s, *a, *b; int res; a = JS_ToBigFloat(ctx, &a_s, op1); if (!a) { JS_FreeValue(ctx, op2); return -1; } b = JS_ToBigFloat(ctx, &b_s, op2); if (!...
/* Note: also used for bigint */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L13856-L13900
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
JS_ThrowUnsupportedBigint
static JSValue JS_ThrowUnsupportedBigint(JSContext *ctx) { return JS_ThrowTypeError(ctx, "bigint is not supported"); }
/* !CONFIG_BIGNUM */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L14365-L14368
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_post_inc_slow
static __exception int js_post_inc_slow(JSContext *ctx, JSValue *sp, OPCodeEnum op) { JSValue op1; double d, r; op1 = sp[-1]; if (unlikely(JS_ToFloat64Free(ctx, &d, op1))) { sp[-1] = JS_UNDEFINED; return -1; } r = d + 2 * (op - OP_post_dec...
/* specific case necessary for correct return value semantics */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L14419-L14434
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
JS_CallConstructorInternal
static JSValue JS_CallConstructorInternal(JSContext *ctx, JSValueConst func_obj, JSValueConst new_target, int argc, JSValue *argv, int flags) { JSObject *p; JSFunctionBytecode *b; i...
/* argv[] is modified if (flags & JS_CALL_FLAG_COPY_ARGV) = 0. */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L19065-L19111
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
async_func_init
static __exception int async_func_init(JSContext *ctx, JSAsyncFunctionState *s, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv) { JSObject *p; JSFunctionBytecode *b; JSStackFrame *sf; int local_coun...
/* JSAsyncFunctionState (used by generator and async functions) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L19149-L19181
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_async_function_terminate
static void js_async_function_terminate(JSRuntime *rt, JSAsyncFunctionData *s) { if (s->is_active) { async_func_free(rt, &s->func_state); s->is_active = FALSE; } }
/* AsyncFunction */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L19415-L19421
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_async_generator_next
static JSValue js_async_generator_next(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) { JSAsyncGeneratorData *s = JS_GetOpaque(this_val, JS_CLASS_ASYNC_GENERATOR); JSValue promise, resolving_funcs[2]; ...
/* magic = GEN_MAGIC_x */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L19951-L19992
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
js_object___setOwnProperty
static JSValue js_object___setOwnProperty(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { int ret; ret = JS_DefinePropertyValueValue(ctx, argv[0], JS_DupValue(ctx, argv[1]), JS_DupValue(ctx, argv[2]), ...
/* Note: corresponds to ECMA spec: CreateDataPropertyOrThrow() */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L37585-L37596
8b81e76efe457b59be3a6e752efd43916ba0cabb
BugChecker
github_2023
vitoplantamura
c
JS_ToUTF32String
static int JS_ToUTF32String(JSContext *ctx, uint32_t **pbuf, JSValueConst val1) { JSValue val; JSString *p; uint32_t *buf; int i, j, len; val = JS_ToString(ctx, val1); if (JS_IsException(val)) return -1; p = JS_VALUE_GET_STRING(val); len = p->len; /* UTF32 buffer length is l...
/* return (-1, NULL) if exception, otherwise (len, buf) */
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/quickjs.c#L41825-L41851
8b81e76efe457b59be3a6e752efd43916ba0cabb