Skip to content

Commit 374915a

Browse files
authored
Rename some internal symbols to avoid collisions
1 parent 7e29205 commit 374915a

File tree

9 files changed

+31
-30
lines changed

9 files changed

+31
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ cmake-*
1010
out/
1111
CMakeUserPresets.json
1212
fuzz
13+
.vscode/

cutils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#pragma GCC visibility push(default)
4242
#endif
4343

44-
void pstrcpy(char *buf, int buf_size, const char *str)
44+
void js__pstrcpy(char *buf, int buf_size, const char *str)
4545
{
4646
int c;
4747
char *q = buf;
@@ -59,16 +59,16 @@ void pstrcpy(char *buf, int buf_size, const char *str)
5959
}
6060

6161
/* strcat and truncate. */
62-
char *pstrcat(char *buf, int buf_size, const char *s)
62+
char *js__pstrcat(char *buf, int buf_size, const char *s)
6363
{
6464
int len;
6565
len = strlen(buf);
6666
if (len < buf_size)
67-
pstrcpy(buf + len, buf_size - len, s);
67+
js__pstrcpy(buf + len, buf_size - len, s);
6868
return buf;
6969
}
7070

71-
int strstart(const char *str, const char *val, const char **ptr)
71+
int js__strstart(const char *str, const char *val, const char **ptr)
7272
{
7373
const char *p, *q;
7474
p = str;
@@ -84,7 +84,7 @@ int strstart(const char *str, const char *val, const char **ptr)
8484
return 1;
8585
}
8686

87-
int has_suffix(const char *str, const char *suffix)
87+
int js__has_suffix(const char *str, const char *suffix)
8888
{
8989
size_t len = strlen(str);
9090
size_t slen = strlen(suffix);

cutils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ enum {
133133
};
134134
#endif
135135

136-
void pstrcpy(char *buf, int buf_size, const char *str);
137-
char *pstrcat(char *buf, int buf_size, const char *s);
138-
int strstart(const char *str, const char *val, const char **ptr);
139-
int has_suffix(const char *str, const char *suffix);
136+
void js__pstrcpy(char *buf, int buf_size, const char *str);
137+
char *js__pstrcat(char *buf, int buf_size, const char *s);
138+
int js__strstart(const char *str, const char *val, const char **ptr);
139+
int js__has_suffix(const char *str, const char *suffix);
140140

141141
static inline uint8_t is_be(void) {
142142
union {

libregexp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
18211821
error:
18221822
dbuf_free(&s->byte_code);
18231823
dbuf_free(&s->group_names);
1824-
pstrcpy(error_msg, error_msg_size, s->u.error_msg);
1824+
js__pstrcpy(error_msg, error_msg_size, s->u.error_msg);
18251825
*plen = 0;
18261826
return NULL;
18271827
}

qjs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int eval_file(JSContext *ctx, const char *filename, int module)
146146
}
147147

148148
if (module < 0) {
149-
module = (has_suffix(filename, ".mjs") ||
149+
module = (js__has_suffix(filename, ".mjs") ||
150150
JS_DetectModule((const char *)buf, buf_len));
151151
}
152152
if (module)

qjsc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void get_c_name(char *buf, size_t buf_size, const char *file)
126126
len = strlen(p);
127127
else
128128
len = r - p;
129-
pstrcpy(buf, buf_size, c_ident_prefix);
129+
js__pstrcpy(buf, buf_size, c_ident_prefix);
130130
q = buf + strlen(buf);
131131
for(i = 0; i < len; i++) {
132132
c = p[i];
@@ -218,7 +218,7 @@ static void find_unique_cname(char *cname, size_t cname_size)
218218
break;
219219
suffix_num++;
220220
}
221-
pstrcpy(cname, cname_size, cname1);
221+
js__pstrcpy(cname, cname_size, cname1);
222222
}
223223

224224
JSModuleDef *jsc_module_loader(JSContext *ctx,
@@ -234,7 +234,7 @@ JSModuleDef *jsc_module_loader(JSContext *ctx,
234234
namelist_add(&init_module_list, e->name, e->short_name, 0);
235235
/* create a dummy module */
236236
m = JS_NewCModule(ctx, module_name, js_module_dummy_init);
237-
} else if (has_suffix(module_name, ".so")) {
237+
} else if (js__has_suffix(module_name, ".so")) {
238238
JS_ThrowReferenceError(ctx, "%s: dynamically linking to shared libraries not supported",
239239
module_name);
240240
return NULL;
@@ -289,7 +289,7 @@ static void compile_file(JSContext *ctx, FILE *fo,
289289
}
290290
eval_flags = JS_EVAL_FLAG_COMPILE_ONLY;
291291
if (module < 0) {
292-
module = (has_suffix(filename, ".mjs") ||
292+
module = (js__has_suffix(filename, ".mjs") ||
293293
JS_DetectModule((const char *)buf, buf_len));
294294
}
295295
if (module)
@@ -303,7 +303,7 @@ static void compile_file(JSContext *ctx, FILE *fo,
303303
}
304304
js_free(ctx, buf);
305305
if (c_name1) {
306-
pstrcpy(c_name, sizeof(c_name), c_name1);
306+
js__pstrcpy(c_name, sizeof(c_name), c_name1);
307307
} else {
308308
get_c_name(c_name, sizeof(c_name), filename);
309309
}
@@ -422,11 +422,11 @@ int main(int argc, char **argv)
422422
char *p;
423423
char path[1024];
424424
char cname[1024];
425-
pstrcpy(path, sizeof(path), optarg);
425+
js__pstrcpy(path, sizeof(path), optarg);
426426
p = strchr(path, ',');
427427
if (p) {
428428
*p = '\0';
429-
pstrcpy(cname, sizeof(cname), p + 1);
429+
js__pstrcpy(cname, sizeof(cname), p + 1);
430430
} else {
431431
get_c_name(cname, sizeof(cname), path);
432432
}
@@ -459,7 +459,7 @@ int main(int argc, char **argv)
459459
if (!out_filename)
460460
out_filename = "out.c";
461461

462-
pstrcpy(cfilename, sizeof(cfilename), out_filename);
462+
js__pstrcpy(cfilename, sizeof(cfilename), out_filename);
463463

464464
if (output_type == OUTPUT_RAW)
465465
fo = fopen(cfilename, "wb");

quickjs-libc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,10 @@ int js_module_set_import_meta(JSContext *ctx, JSValue func_val,
672672
} else
673673
#endif
674674
{
675-
pstrcat(buf, sizeof(buf), module_name);
675+
js__pstrcat(buf, sizeof(buf), module_name);
676676
}
677677
} else {
678-
pstrcpy(buf, sizeof(buf), module_name);
678+
js__pstrcpy(buf, sizeof(buf), module_name);
679679
}
680680
JS_FreeCString(ctx, module_name);
681681

@@ -697,7 +697,7 @@ JSModuleDef *js_module_loader(JSContext *ctx,
697697
{
698698
JSModuleDef *m;
699699

700-
if (has_suffix(module_name, QJS_NATIVE_MODULE_SUFFIX)) {
700+
if (js__has_suffix(module_name, QJS_NATIVE_MODULE_SUFFIX)) {
701701
m = js_module_loader_so(ctx, module_name);
702702
} else {
703703
size_t buf_len;

quickjs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10497,7 +10497,7 @@ static JSValue js_atof(JSContext *ctx, const char *p, size_t len,
1049710497
}
1049810498
}
1049910499
} else {
10500-
if (*p == 'I' && (flags & ATOD_ACCEPT_INFINITY) && strstart(p, "Infinity", &p)) {
10500+
if (*p == 'I' && (flags & ATOD_ACCEPT_INFINITY) && js__strstart(p, "Infinity", &p)) {
1050110501
d = INF;
1050210502
if (sign == '-')
1050310503
d = -d;
@@ -26496,8 +26496,8 @@ static char *js_default_module_normalize_name(JSContext *ctx,
2649626496
}
2649726497
}
2649826498
if (filename[0] != '\0')
26499-
pstrcat(filename, cap, "/");
26500-
pstrcat(filename, cap, r);
26499+
js__pstrcat(filename, cap, "/");
26500+
js__pstrcat(filename, cap, r);
2650126501
// printf("normalize: %s %s -> %s\n", base_name, name, filename);
2650226502
return filename;
2650326503
}

run-test262.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void namelist_free(namelist_t *lp)
398398
static int add_test_file(const char *filename)
399399
{
400400
namelist_t *lp = &test_list;
401-
if (has_suffix(filename, ".js") && !has_suffix(filename, "_FIXTURE.js"))
401+
if (js__has_suffix(filename, ".js") && !js__has_suffix(filename, "_FIXTURE.js"))
402402
namelist_add(lp, NULL, filename);
403403
return 0;
404404
}
@@ -472,7 +472,7 @@ static JSValue js_print_262(JSContext *ctx, JSValue this_val,
472472
return JS_EXCEPTION;
473473
if (!strcmp(str, "Test262:AsyncTestComplete")) {
474474
tls->async_done++;
475-
} else if (strstart(str, "Test262:AsyncTestFailure", NULL)) {
475+
} else if (js__strstart(str, "Test262:AsyncTestFailure", NULL)) {
476476
tls->async_done = 2; /* force an error */
477477
}
478478
if (outfile) {
@@ -1062,7 +1062,7 @@ void update_exclude_dirs(void)
10621062
/* split directpries from exclude_list */
10631063
for (count = i = 0; i < ep->count; i++) {
10641064
name = ep->array[i];
1065-
if (has_suffix(name, "/")) {
1065+
if (js__has_suffix(name, "/")) {
10661066
namelist_add(dp, NULL, name);
10671067
free(name);
10681068
} else {
@@ -1265,7 +1265,7 @@ char *find_error(const char *filename, int *pline, int is_strict)
12651265
q++;
12661266
}
12671267
/* check strict mode indicator */
1268-
if (!strstart(q, "strict mode: ", &q) != !is_strict)
1268+
if (!js__strstart(q, "strict mode: ", &q) != !is_strict)
12691269
continue;
12701270
r = q = skip_prefix(q, "unexpected error: ");
12711271
r += strcspn(r, "\n");
@@ -1486,7 +1486,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len,
14861486
if (ret == 0) {
14871487
if (msg && s &&
14881488
(str_equal(s, "expected error") ||
1489-
strstart(s, "unexpected error type:", NULL) ||
1489+
js__strstart(s, "unexpected error type:", NULL) ||
14901490
str_equal(s, msg))) { // did not have error yet
14911491
if (!has_error_line) {
14921492
longest_match(buf, msg, pos, &pos, pos_line, &error_line);

0 commit comments

Comments
 (0)