Skip to content

Commit 2ff2e44

Browse files
committed
Avoid macro and function name collisions between sources
1 parent 136f5a2 commit 2ff2e44

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

libbf.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ int bf_mul_pow_radix(bf_t *r, const bf_t *T, limb_t radix,
28332833
return ret;
28342834
}
28352835

2836-
static inline int to_digit(int c)
2836+
static inline int bf_to_digit(int c)
28372837
{
28382838
if (c >= '0' && c <= '9')
28392839
return c - '0';
@@ -2940,7 +2940,7 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent,
29402940
goto no_prefix;
29412941
}
29422942
/* there must be a digit after the prefix */
2943-
if (to_digit((uint8_t)*p) >= radix) {
2943+
if (bf_to_digit((uint8_t)*p) >= radix) {
29442944
bf_set_nan(r);
29452945
ret = 0;
29462946
goto done;
@@ -2988,14 +2988,14 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent,
29882988
int_len = digit_count = 0;
29892989
for(;;) {
29902990
limb_t c;
2991-
if (*p == '.' && (p > p_start || to_digit(p[1]) < radix)) {
2991+
if (*p == '.' && (p > p_start || bf_to_digit(p[1]) < radix)) {
29922992
if (has_decpt)
29932993
break;
29942994
has_decpt = TRUE;
29952995
int_len = digit_count;
29962996
p++;
29972997
}
2998-
c = to_digit(*p);
2998+
c = bf_to_digit(*p);
29992999
if (c >= radix)
30003000
break;
30013001
digit_count++;
@@ -3076,7 +3076,7 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent,
30763076
}
30773077
for(;;) {
30783078
int c;
3079-
c = to_digit(*p);
3079+
c = bf_to_digit(*p);
30803080
if (c >= 10)
30813081
break;
30823082
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)
84108410
}
84118411

84128412
#endif /* !USE_FFT_MUL */
8413+
8414+
#undef malloc
8415+
#undef free
8416+
#undef realloc

libregexp.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static const REOpCode reopcode_info[REOP_COUNT] = {
109109

110110
#define RE_HEADER_LEN 8
111111

112-
static inline int is_digit(int c) {
112+
static inline int lre_is_digit(int c) {
113113
return c >= '0' && c <= '9';
114114
}
115115

@@ -577,7 +577,7 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
577577
c -= '0';
578578
if (allow_utf16 == 2) {
579579
/* only accept \0 not followed by digit */
580-
if (c != 0 || is_digit(*p))
580+
if (c != 0 || lre_is_digit(*p))
581581
return -1;
582582
} else {
583583
/* parse a legacy octal sequence */
@@ -1285,7 +1285,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
12851285
case '{':
12861286
if (s->is_unicode) {
12871287
return re_parse_error(s, "syntax error");
1288-
} else if (!is_digit(p[1])) {
1288+
} else if (!lre_is_digit(p[1])) {
12891289
/* Annex B: we accept '{' not followed by digits as a
12901290
normal atom */
12911291
goto parse_class_atom;
@@ -1295,7 +1295,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
12951295
parse_digits(&p1, TRUE);
12961296
if (*p1 == ',') {
12971297
p1++;
1298-
if (is_digit(*p1)) {
1298+
if (lre_is_digit(*p1)) {
12991299
parse_digits(&p1, TRUE);
13001300
}
13011301
}
@@ -1443,7 +1443,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
14431443
p += 2;
14441444
c = 0;
14451445
if (s->is_unicode) {
1446-
if (is_digit(*p)) {
1446+
if (lre_is_digit(*p)) {
14471447
return re_parse_error(s, "invalid decimal escape in regular expression");
14481448
}
14491449
} else {
@@ -1565,7 +1565,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
15651565
const uint8_t *p1 = p;
15661566
/* As an extension (see ES6 annex B), we accept '{' not
15671567
followed by digits as a normal atom */
1568-
if (!is_digit(p[1])) {
1568+
if (!lre_is_digit(p[1])) {
15691569
if (s->is_unicode)
15701570
goto invalid_quant_count;
15711571
break;
@@ -1575,7 +1575,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
15751575
quant_max = quant_min;
15761576
if (*p == ',') {
15771577
p++;
1578-
if (is_digit(*p)) {
1578+
if (lre_is_digit(*p)) {
15791579
quant_max = parse_digits(&p, TRUE);
15801580
if (quant_max < quant_min) {
15811581
invalid_quant_count:
@@ -1812,7 +1812,7 @@ static int re_parse_disjunction(REParseState *s, BOOL is_backward_dir)
18121812
}
18131813

18141814
/* the control flow is recursive so the analysis can be linear */
1815-
static int compute_stack_size(const uint8_t *bc_buf, int bc_buf_len)
1815+
static int lre_compute_stack_size(const uint8_t *bc_buf, int bc_buf_len)
18161816
{
18171817
int stack_size, stack_size_max, pos, opcode, len;
18181818
uint32_t val;
@@ -1925,7 +1925,7 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
19251925
goto error;
19261926
}
19271927

1928-
stack_size = compute_stack_size(s->byte_code.buf, s->byte_code.size);
1928+
stack_size = lre_compute_stack_size(s->byte_code.buf, s->byte_code.size);
19291929
if (stack_size < 0) {
19301930
re_parse_error(s, "too many imbricated quantifiers");
19311931
goto error;

quickjs.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -47750,7 +47750,7 @@ static int64_t math_mod(int64_t a, int64_t b) {
4775047750
return m + (m < 0) * b;
4775147751
}
4775247752

47753-
static int64_t floor_div(int64_t a, int64_t b) {
47753+
static int64_t floor_div_int64(int64_t a, int64_t b) {
4775447754
/* integer division rounding toward -Infinity */
4775547755
int64_t m = a % b;
4775647756
return (a - (m + (m < 0) * b)) / b;
@@ -47784,8 +47784,8 @@ static JSValue JS_SetThisTimeValue(JSContext *ctx, JSValue this_val, double v)
4778447784
}
4778547785

4778647786
static int64_t days_from_year(int64_t y) {
47787-
return 365 * (y - 1970) + floor_div(y - 1969, 4) -
47788-
floor_div(y - 1901, 100) + floor_div(y - 1601, 400);
47787+
return 365 * (y - 1970) + floor_div_int64(y - 1969, 4) -
47788+
floor_div_int64(y - 1901, 100) + floor_div_int64(y - 1601, 400);
4778947789
}
4779047790

4779147791
static int64_t days_in_year(int64_t y) {
@@ -47795,7 +47795,7 @@ static int64_t days_in_year(int64_t y) {
4779547795
/* return the year, update days */
4779647796
static int64_t year_from_days(int64_t *days) {
4779747797
int64_t y, d1, nd, d = *days;
47798-
y = floor_div(d * 10000, 3652425) + 1970;
47798+
y = floor_div_int64(d * 10000, 3652425) + 1970;
4779947799
/* the initial approximation is very good, so only a few
4780047800
iterations are necessary */
4780147801
for(;;) {
@@ -53183,3 +53183,7 @@ static void _JS_AddIntrinsicCallSite(JSContext *ctx)
5318353183
js_callsite_proto_funcs,
5318453184
countof(js_callsite_proto_funcs));
5318553185
}
53186+
53187+
#undef malloc
53188+
#undef free
53189+
#undef realloc

0 commit comments

Comments
 (0)