Skip to content

Commit a9512d4

Browse files
pinotreesaghul
authored andcommitted
Use JS__PATH_MAX instead of PATH_MAX in common code
PATH_MAX is optional in POSIX, and it is not available on GNU/Hurd. There is already a fallback definition called JS__PATH_MAX, so switch all the common code (i.e. not the bits specific to a certain OS) to use it.
1 parent 3c4bc74 commit a9512d4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

quickjs-libc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
728728
bool use_realpath, bool is_main)
729729
{
730730
JSModuleDef *m;
731-
char buf[PATH_MAX + 16];
731+
char buf[JS__PATH_MAX + 16];
732732
JSValue meta_obj;
733733
JSAtom module_name_atom;
734734
const char *module_name;
@@ -2756,7 +2756,7 @@ static JSValue make_string_error(JSContext *ctx,
27562756
static JSValue js_os_getcwd(JSContext *ctx, JSValueConst this_val,
27572757
int argc, JSValueConst *argv)
27582758
{
2759-
char buf[PATH_MAX];
2759+
char buf[JS__PATH_MAX];
27602760
int err;
27612761

27622762
if (!getcwd(buf, sizeof(buf))) {
@@ -3039,7 +3039,7 @@ static JSValue js_os_realpath(JSContext *ctx, JSValueConst this_val,
30393039
int argc, JSValueConst *argv)
30403040
{
30413041
const char *path;
3042-
char buf[PATH_MAX], *res;
3042+
char buf[JS__PATH_MAX], *res;
30433043
int err;
30443044

30453045
path = JS_ToCString(ctx, argv[0]);
@@ -3083,7 +3083,7 @@ static JSValue js_os_readlink(JSContext *ctx, JSValueConst this_val,
30833083
int argc, JSValueConst *argv)
30843084
{
30853085
const char *path;
3086-
char buf[PATH_MAX];
3086+
char buf[JS__PATH_MAX];
30873087
int err;
30883088
ssize_t res;
30893089

@@ -3165,7 +3165,7 @@ static char **build_envp(JSContext *ctx, JSValue obj)
31653165
static int my_execvpe(const char *filename, char **argv, char **envp)
31663166
{
31673167
char *path, *p, *p_next, *p1;
3168-
char buf[PATH_MAX];
3168+
char buf[JS__PATH_MAX];
31693169
size_t filename_len, path_len;
31703170
bool eacces_error;
31713171

@@ -3192,7 +3192,7 @@ static int my_execvpe(const char *filename, char **argv, char **envp)
31923192
path_len = p1 - p;
31933193
}
31943194
/* path too long */
3195-
if ((path_len + 1 + filename_len + 1) > PATH_MAX)
3195+
if ((path_len + 1 + filename_len + 1) > JS__PATH_MAX)
31963196
continue;
31973197
memcpy(buf, p, path_len);
31983198
buf[path_len] = '/';

0 commit comments

Comments
 (0)