From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 11 Feb 2022 16:13:52 +0330 Subject: [PATCH] Get rid of wordexp on serenity --- src/file.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/file.c b/src/file.c index a3bfd16..720a6e5 100644 --- a/src/file.c +++ b/src/file.c @@ -18,11 +18,13 @@ #include "citron.h" #include "siphash.h" #include +#ifndef __serenity__ #include #ifndef WORDEXP_READY # define WORDEXP_READY 1 #endif +#endif #include static struct termios oldTermios, newTermios; @@ -461,6 +463,7 @@ ctr_object* ctr_file_rpath(ctr_object* myself, ctr_argument* argumentList) char rpath[PATH_MAX + 1]; char* ret = realpath(cpath, rpath); if (!ret) { +#ifndef __serenity__ if (WORDEXP_READY) { wordexp_t exp_result; int st = wordexp(cpath, &exp_result, 0); @@ -469,6 +472,7 @@ ctr_object* ctr_file_rpath(ctr_object* myself, ctr_argument* argumentList) memset(rpath, 0, PATH_MAX); memcpy(rpath, r, strlen(r)); wordfree(&exp_result); + ret = rpath; } else { char* err; switch (st) { @@ -499,8 +503,13 @@ ctr_object* ctr_file_rpath(ctr_object* myself, ctr_argument* argumentList) CtrStdFlow = ctr_build_string_from_cstring(strerror(errno)); return CtrStdNil; } +#else + ctr_heap_free(cpath); + CtrStdFlow = ctr_build_string_from_cstring(strerror(errno)); + return CtrStdNil; +#endif } - path = ctr_build_string_from_cstring(rpath); + path = ctr_build_string_from_cstring(ret); ctr_heap_free(cpath); return path; } @@ -515,6 +524,9 @@ ctr_object* ctr_file_expand(ctr_object* myself, ctr_argument* argumentList) if (argumentList->object == NULL) return CtrStdNil; ctr_object* path = ctr_internal_cast2string(argumentList->object); +#ifdef __serenity__ + return path; +#else char* cpath = ctr_heap_allocate_cstring(path); wordexp_t exp_result; int st = wordexp(cpath, &exp_result, 0); @@ -557,6 +569,7 @@ ctr_object* ctr_file_expand(ctr_object* myself, ctr_argument* argumentList) return CtrStdNil; } return arr; +#endif } /**