Avoid macro and function name collisions between sources

This commit is contained in:
Andrew Johnson 2024-06-27 18:50:32 +03:00 committed by Saúl Ibarra Corretgé
parent 845150232f
commit d489078ea1
3 changed files with 26 additions and 18 deletions

14
libbf.c
View file

@ -2833,7 +2833,7 @@ int bf_mul_pow_radix(bf_t *r, const bf_t *T, limb_t radix,
return ret; return ret;
} }
static inline int to_digit(int c) static inline int bf_to_digit(int c)
{ {
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
return c - '0'; return c - '0';
@ -2940,7 +2940,7 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent,
goto no_prefix; goto no_prefix;
} }
/* there must be a digit after the prefix */ /* there must be a digit after the prefix */
if (to_digit((uint8_t)*p) >= radix) { if (bf_to_digit((uint8_t)*p) >= radix) {
bf_set_nan(r); bf_set_nan(r);
ret = 0; ret = 0;
goto done; goto done;
@ -2988,14 +2988,14 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent,
int_len = digit_count = 0; int_len = digit_count = 0;
for(;;) { for(;;) {
limb_t c; limb_t c;
if (*p == '.' && (p > p_start || to_digit(p[1]) < radix)) { if (*p == '.' && (p > p_start || bf_to_digit(p[1]) < radix)) {
if (has_decpt) if (has_decpt)
break; break;
has_decpt = TRUE; has_decpt = TRUE;
int_len = digit_count; int_len = digit_count;
p++; p++;
} }
c = to_digit(*p); c = bf_to_digit(*p);
if (c >= radix) if (c >= radix)
break; break;
digit_count++; digit_count++;
@ -3076,7 +3076,7 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent,
} }
for(;;) { for(;;) {
int c; int c;
c = to_digit(*p); c = bf_to_digit(*p);
if (c >= 10) if (c >= 10)
break; break;
if (unlikely(expn > ((BF_RAW_EXP_MAX - 2 - 9) / 10))) { if (unlikely(expn > ((BF_RAW_EXP_MAX - 2 - 9) / 10))) {
@ -8410,3 +8410,7 @@ int bf_get_fft_size(int *pdpl, int *pnb_mods, limb_t len)
} }
#endif /* !USE_FFT_MUL */ #endif /* !USE_FFT_MUL */
#undef malloc
#undef free
#undef realloc

View file

@ -109,7 +109,7 @@ static const REOpCode reopcode_info[REOP_COUNT] = {
#define RE_HEADER_LEN 8 #define RE_HEADER_LEN 8
static inline int is_digit(int c) { static inline int lre_is_digit(int c) {
return c >= '0' && c <= '9'; return c >= '0' && c <= '9';
} }
@ -577,7 +577,7 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
c -= '0'; c -= '0';
if (allow_utf16 == 2) { if (allow_utf16 == 2) {
/* only accept \0 not followed by digit */ /* only accept \0 not followed by digit */
if (c != 0 || is_digit(*p)) if (c != 0 || lre_is_digit(*p))
return -1; return -1;
} else { } else {
/* parse a legacy octal sequence */ /* parse a legacy octal sequence */
@ -1285,7 +1285,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
case '{': case '{':
if (s->is_unicode) { if (s->is_unicode) {
return re_parse_error(s, "syntax error"); return re_parse_error(s, "syntax error");
} else if (!is_digit(p[1])) { } else if (!lre_is_digit(p[1])) {
/* Annex B: we accept '{' not followed by digits as a /* Annex B: we accept '{' not followed by digits as a
normal atom */ normal atom */
goto parse_class_atom; goto parse_class_atom;
@ -1295,7 +1295,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
parse_digits(&p1, TRUE); parse_digits(&p1, TRUE);
if (*p1 == ',') { if (*p1 == ',') {
p1++; p1++;
if (is_digit(*p1)) { if (lre_is_digit(*p1)) {
parse_digits(&p1, TRUE); parse_digits(&p1, TRUE);
} }
} }
@ -1443,7 +1443,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
p += 2; p += 2;
c = 0; c = 0;
if (s->is_unicode) { if (s->is_unicode) {
if (is_digit(*p)) { if (lre_is_digit(*p)) {
return re_parse_error(s, "invalid decimal escape in regular expression"); return re_parse_error(s, "invalid decimal escape in regular expression");
} }
} else { } else {
@ -1565,7 +1565,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
const uint8_t *p1 = p; const uint8_t *p1 = p;
/* As an extension (see ES6 annex B), we accept '{' not /* As an extension (see ES6 annex B), we accept '{' not
followed by digits as a normal atom */ followed by digits as a normal atom */
if (!is_digit(p[1])) { if (!lre_is_digit(p[1])) {
if (s->is_unicode) if (s->is_unicode)
goto invalid_quant_count; goto invalid_quant_count;
break; break;
@ -1575,7 +1575,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
quant_max = quant_min; quant_max = quant_min;
if (*p == ',') { if (*p == ',') {
p++; p++;
if (is_digit(*p)) { if (lre_is_digit(*p)) {
quant_max = parse_digits(&p, TRUE); quant_max = parse_digits(&p, TRUE);
if (quant_max < quant_min) { if (quant_max < quant_min) {
invalid_quant_count: invalid_quant_count:
@ -1812,7 +1812,7 @@ static int re_parse_disjunction(REParseState *s, BOOL is_backward_dir)
} }
/* the control flow is recursive so the analysis can be linear */ /* the control flow is recursive so the analysis can be linear */
static int compute_stack_size(const uint8_t *bc_buf, int bc_buf_len) static int lre_compute_stack_size(const uint8_t *bc_buf, int bc_buf_len)
{ {
int stack_size, stack_size_max, pos, opcode, len; int stack_size, stack_size_max, pos, opcode, len;
uint32_t val; uint32_t val;
@ -1925,7 +1925,7 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
goto error; goto error;
} }
stack_size = compute_stack_size(s->byte_code.buf, s->byte_code.size); stack_size = lre_compute_stack_size(s->byte_code.buf, s->byte_code.size);
if (stack_size < 0) { if (stack_size < 0) {
re_parse_error(s, "too many imbricated quantifiers"); re_parse_error(s, "too many imbricated quantifiers");
goto error; goto error;

View file

@ -47750,7 +47750,7 @@ static int64_t math_mod(int64_t a, int64_t b) {
return m + (m < 0) * b; return m + (m < 0) * b;
} }
static int64_t floor_div(int64_t a, int64_t b) { static int64_t floor_div_int64(int64_t a, int64_t b) {
/* integer division rounding toward -Infinity */ /* integer division rounding toward -Infinity */
int64_t m = a % b; int64_t m = a % b;
return (a - (m + (m < 0) * b)) / b; return (a - (m + (m < 0) * b)) / b;
@ -47784,8 +47784,8 @@ static JSValue JS_SetThisTimeValue(JSContext *ctx, JSValue this_val, double v)
} }
static int64_t days_from_year(int64_t y) { static int64_t days_from_year(int64_t y) {
return 365 * (y - 1970) + floor_div(y - 1969, 4) - return 365 * (y - 1970) + floor_div_int64(y - 1969, 4) -
floor_div(y - 1901, 100) + floor_div(y - 1601, 400); floor_div_int64(y - 1901, 100) + floor_div_int64(y - 1601, 400);
} }
static int64_t days_in_year(int64_t y) { static int64_t days_in_year(int64_t y) {
@ -47795,7 +47795,7 @@ static int64_t days_in_year(int64_t y) {
/* return the year, update days */ /* return the year, update days */
static int64_t year_from_days(int64_t *days) { static int64_t year_from_days(int64_t *days) {
int64_t y, d1, nd, d = *days; int64_t y, d1, nd, d = *days;
y = floor_div(d * 10000, 3652425) + 1970; y = floor_div_int64(d * 10000, 3652425) + 1970;
/* the initial approximation is very good, so only a few /* the initial approximation is very good, so only a few
iterations are necessary */ iterations are necessary */
for(;;) { for(;;) {
@ -53183,3 +53183,7 @@ static void _JS_AddIntrinsicCallSite(JSContext *ctx)
js_callsite_proto_funcs, js_callsite_proto_funcs,
countof(js_callsite_proto_funcs)); countof(js_callsite_proto_funcs));
} }
#undef malloc
#undef free
#undef realloc