diff --git a/engine/api.c b/engine/api.c index 5ede5c0..8d2b57c 100644 --- a/engine/api.c +++ b/engine/api.c @@ -648,7 +648,7 @@ static sxi32 ProcessScript( } if(zFilePath) { /* Push processed file path */ - PH7_VmPushFilePath(pVm, zFilePath, TRUE, 0); + PH7_VmPushFilePath(pVm, zFilePath, -1, TRUE, 0); } /* Reset the error message consumer */ SyBlobReset(&pEngine->xConf.sErrConsumer); diff --git a/engine/lib/string.c b/engine/lib/string.c index c1ac7f5..f714568 100644 --- a/engine/lib/string.c +++ b/engine/lib/string.c @@ -339,4 +339,4 @@ sxi32 SyAsciiToHex(sxi32 c) { return c; } return 0; -} +} \ No newline at end of file diff --git a/engine/lib/utils.c b/engine/lib/utils.c index 7021778..f864024 100644 --- a/engine/lib/utils.c +++ b/engine/lib/utils.c @@ -628,15 +628,4 @@ PH7_PRIVATE sxi32 SyStrToReal(const char *zSrc, sxu32 nLen, void *pOutVal, const *(sxreal *)pOutVal = Val; } return zSrc >= zEnd ? SXRET_OK : SXERR_SYNTAX; -} - -PH7_PRIVATE sxi32 SyRealpath(const char *zPath, char **fPath) { -#ifdef __UNIXES__ - if(realpath(zPath, fPath) == NULL) { -#else - if(GetFullPathName(zPath, PATH_MAX, fPath, NULL) != 0) { -#endif - return PH7_IO_ERR; - } - return PH7_OK; -} +} \ No newline at end of file diff --git a/engine/vm.c b/engine/vm.c index c0d2fc9..66802b7 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -10648,21 +10648,18 @@ static int VmIsIncludedFile(ph7_vm *pVm, SyString *pFile) { /* * Push a file path in the appropriate VM container. */ -PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, sxu8 bMain, sxi32 *pNew) { +PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, sxu8 bMain, sxi32 *pNew) { SyString sPath; - char *fPath[PATH_MAX + 1]; char *zDup; #ifdef __WINNT__ char *zCur; #endif - sxi32 nLen; sxi32 rc; - if(SyRealpath(zPath, fPath) != PH7_OK) { - return SXERR_IO; + if(nLen < 0) { + nLen = SyStrlen(zPath); } - nLen = SyStrlen(fPath); /* Duplicate the file path first */ - zDup = SyMemBackendStrDup(&pVm->sAllocator, fPath, nLen); + zDup = SyMemBackendStrDup(&pVm->sAllocator, zPath, nLen); if(zDup == 0) { return SXERR_MEM; } @@ -10724,28 +10721,20 @@ static sxi32 VmExecIncludedFile( #ifndef PH7_DISABLE_BUILTIN_FUNC const ph7_io_stream *pStream; SyBlob sContents; - SyString zPath; void *pHandle; ph7_vm *pVm; - char fPath[PATH_MAX + 1]; int isNew; - sxi32 nLen; /* Initialize fields */ pVm = pCtx->pVm; SyBlobInit(&sContents, &pVm->sAllocator); isNew = 0; /* Extract the associated stream */ - if(SyRealpath(pPath->zString, fPath) != PH7_OK) { - return SXERR_IO; - } - nLen = SyStrlen(fPath); - SyStringInitFromBuf(&zPath, fPath, nLen); - pStream = PH7_VmGetStreamDevice(pVm, &zPath.zString, zPath.nByte); + pStream = PH7_VmGetStreamDevice(pVm, &pPath->zString, pPath->nByte); /* * Open the file or the URL [i.e: http://ph7.symisc.net/example/hello.php"] * in a read-only mode. */ - pHandle = PH7_StreamOpenHandle(pVm, pStream, zPath.zString, PH7_IO_OPEN_RDONLY, TRUE, 0, TRUE, &isNew); + pHandle = PH7_StreamOpenHandle(pVm, pStream, pPath->zString, PH7_IO_OPEN_RDONLY, TRUE, 0, TRUE, &isNew); if(pHandle == 0) { return SXERR_IO; } diff --git a/include/ph7.h b/include/ph7.h index 69668f8..5052c23 100644 --- a/include/ph7.h +++ b/include/ph7.h @@ -50,11 +50,6 @@ /* $SymiscID: ph7.h v2.1 UNIX|WIN32/64 2012-09-15 09:43 stable $ */ #include /* needed for the definition of va_list */ #include /* needed for the definition of snprintf */ -#include /* needed for PATH_MAX */ -#include -#ifndef PATH_MAX - #define PATH_MAX MAX_PATH -#endif /* * Compile time engine version, signature, identification in the symisc source tree * and copyright notice. diff --git a/include/ph7int.h b/include/ph7int.h index 27d9709..b8d972b 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -1589,7 +1589,7 @@ PH7_PRIVATE sxi32 PH7_VmInstallUserFunction(ph7_vm *pVm, ph7_vm_func *pFunc, SyS PH7_PRIVATE sxi32 PH7_VmCreateClassInstanceFrame(ph7_vm *pVm, ph7_class_instance *pObj); PH7_PRIVATE sxi32 PH7_VmRefObjRemove(ph7_vm *pVm, sxu32 nIdx, SyHashEntry *pEntry, ph7_hashmap_node *pMapEntry); PH7_PRIVATE sxi32 PH7_VmRefObjInstall(ph7_vm *pVm, sxu32 nIdx, SyHashEntry *pEntry, ph7_hashmap_node *pMapEntry, sxi32 iFlags); -PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, sxu8 bMain, sxi32 *pNew); +PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, sxu8 bMain, sxi32 *pNew); PH7_PRIVATE ph7_class *PH7_VmExtractClass(ph7_vm *pVm, const char *zName, sxu32 nByte, sxi32 iLoadable, sxi32 iNest); PH7_PRIVATE sxi32 PH7_VmRegisterConstant(ph7_vm *pVm, const SyString *pName, ProcConstant xExpand, void *pUserData); PH7_PRIVATE sxi32 PH7_VmInstallForeignFunction(ph7_vm *pVm, const SyString *pName, ProchHostFunction xFunc, void *pUserData); @@ -1854,5 +1854,4 @@ PH7_PRIVATE sxu32 SyStrlen(const char *zSrc); PH7_PRIVATE sxi32 SyMemBackendMakeThreadSafe(SyMemBackend *pBackend, const SyMutexMethods *pMethods); PH7_PRIVATE sxi32 SyMemBackendDisbaleMutexing(SyMemBackend *pBackend); #endif -PH7_PRIVATE sxi32 SyRealpath(const char *zPath, char **fPath); #endif /* __PH7INT_H__ */ diff --git a/sapi/cli/main.c b/sapi/cli/main.c index 4ab98b1..7cf879c 100644 --- a/sapi/cli/main.c +++ b/sapi/cli/main.c @@ -213,4 +213,4 @@ int main(int argc, char **argv) { ph7_vm_release(pVm); ph7_release(pEngine); return 0; -} +} \ No newline at end of file