From 00e1c842d5affcd870d3ea1b1779161664a954c4 Mon Sep 17 00:00:00 2001 From: belliash Date: Wed, 5 Sep 2018 20:43:39 +0200 Subject: [PATCH] Never disable builtin functions. --- engine/builtin.c | 4 ---- engine/hashmap.c | 2 -- engine/vfs.c | 40 +--------------------------------------- engine/vm.c | 15 --------------- 4 files changed, 1 insertion(+), 60 deletions(-) diff --git a/engine/builtin.c b/engine/builtin.c index 14952c7..3533dcc 100644 --- a/engine/builtin.c +++ b/engine/builtin.c @@ -272,7 +272,6 @@ static int PH7_builtin_empty(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_result_bool(pCtx, res); return PH7_OK; } -#ifndef PH7_DISABLE_BUILTIN_FUNC /* * float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] ) * Exponential expression. @@ -7480,7 +7479,6 @@ static int PH7_builtin_urldecode(ph7_context *pCtx, int nArg, ph7_value **apArg) SyUriDecode(zIn, (sxu32)nLen, Consumer, pCtx, TRUE); return PH7_OK; } -#endif /* PH7_DISABLE_BUILTIN_FUNC */ /* Table of the built-in functions */ static const ph7_builtin_func aBuiltInFunc[] = { /* Variable handling functions */ @@ -7498,7 +7496,6 @@ static const ph7_builtin_func aBuiltInFunc[] = { { "intval", PH7_builtin_intval }, { "stringval", PH7_builtin_strval }, { "empty", PH7_builtin_empty }, -#ifndef PH7_DISABLE_BUILTIN_FUNC { "round", PH7_builtin_round }, { "dechex", PH7_builtin_dechex }, { "decoct", PH7_builtin_decoct }, @@ -7593,7 +7590,6 @@ static const ph7_builtin_func aBuiltInFunc[] = { { "base64_decode", PH7_builtin_base64_decode }, { "urlencode", PH7_builtin_urlencode }, { "urldecode", PH7_builtin_urldecode }, -#endif /* PH7_DISABLE_BUILTIN_FUNC */ }; /* * Register the built-in functions defined above,the array functions diff --git a/engine/hashmap.c b/engine/hashmap.c index 8ef8478..afc0e00 100644 --- a/engine/hashmap.c +++ b/engine/hashmap.c @@ -1568,7 +1568,6 @@ PH7_PRIVATE void PH7_HashmapExtractNodeKey(ph7_hashmap_node *pNode, ph7_value *p MemObjSetType(pKey, MEMOBJ_STRING); } } -#ifndef PH7_DISABLE_BUILTIN_FUNC /* * Store the address of nodes value in the given container. * Refer to the [vfprintf(),vprintf(),vsprintf()] implementations @@ -1592,7 +1591,6 @@ PH7_PRIVATE int PH7_HashmapValuesToSet(ph7_hashmap *pMap, SySet *pOut) { /* Total inserted entries */ return (int)SySetUsed(pOut); } -#endif /* PH7_DISABLE_BUILTIN_FUNC */ /* * Merge sort. * The merge sort implementation is based on the one found in the SQLite3 source tree. diff --git a/engine/vfs.c b/engine/vfs.c index ec79d3d..cfe2609 100644 --- a/engine/vfs.c +++ b/engine/vfs.c @@ -51,10 +51,6 @@ PH7_PRIVATE const char *PH7_ExtractDirName(const char *zPath, int nByte, int *pL } return zPath; } -/* - * Omit the vfs layer implementation from the built if the PH7_DISABLE_BUILTIN_FUNC directive is defined. - */ -#ifndef PH7_DISABLE_BUILTIN_FUNC /* * bool chdir(string $directory) * Change the current directory. @@ -5685,7 +5681,6 @@ static int PH7_builtin_zip_entry_compressionmethod(ph7_context *pCtx, int nArg, } return PH7_OK; } -#endif /* #ifndef PH7_DISABLE_BUILTIN_FUNC*/ /* NULL VFS [i.e: a no-op VFS]*/ static const ph7_vfs null_vfs = { "NullVFS", @@ -5734,7 +5729,6 @@ static const ph7_vfs null_vfs = { 0, /* int (*xGid)(void) */ 0 /* void (*xUsername)(ph7_context *) */ }; -#ifndef PH7_DISABLE_BUILTIN_FUNC #ifndef PH7_DISABLE_DISK_IO #ifdef __WINNT__ /* @@ -7764,19 +7758,14 @@ static const ph7_io_stream sUnixFileStream = { }; #endif /* __WINNT__/__UNIXES__ */ #endif /* PH7_DISABLE_DISK_IO */ -#endif /* PH7_DISABLE_BUILTIN_FUNC */ /* * Export the builtin vfs. * Return a pointer to the builtin vfs if available. * Otherwise return the null_vfs [i.e: a no-op vfs] instead. * Note: * The built-in vfs is always available for Windows/UNIX systems. - * Note: - * If the engine is compiled with the PH7_DISABLE_DISK_IO/PH7_DISABLE_BUILTIN_FUNC - * directives defined then this function return the null_vfs instead. */ PH7_PRIVATE const ph7_vfs *PH7_ExportBuiltinVfs(void) { -#ifndef PH7_DISABLE_BUILTIN_FUNC #ifdef PH7_DISABLE_DISK_IO return &null_vfs; #else @@ -7788,11 +7777,7 @@ PH7_PRIVATE const ph7_vfs *PH7_ExportBuiltinVfs(void) { return &null_vfs; #endif /* __WINNT__/__UNIXES__ */ #endif /* PH7_DISABLE_DISK_IO */ -#else - return &null_vfs; -#endif /* PH7_DISABLE_BUILTIN_FUNC */ } -#ifndef PH7_DISABLE_BUILTIN_FUNC #ifndef PH7_DISABLE_DISK_IO /* * The following defines are mostly used by the UNIX built and have @@ -8051,17 +8036,11 @@ static int is_php_stream(const ph7_io_stream *pStream) { return 0; #endif /* PH7_DISABLE_DISK_IO */ } - -#endif /* PH7_DISABLE_BUILTIN_FUNC */ /* * Export the IO routines defined above and the built-in IO streams * [i.e: file://,php://]. - * Note: - * If the engine is compiled with the PH7_DISABLE_BUILTIN_FUNC directive - * defined then this function is a no-op. */ PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) { -#ifndef PH7_DISABLE_BUILTIN_FUNC /* VFS functions */ static const ph7_builtin_func aVfsFunc[] = { {"chdir", PH7_vfs_chdir }, @@ -8188,16 +8167,12 @@ PH7_PRIVATE sxi32 PH7_RegisterIORoutine(ph7_vm *pVm) { /* Install the file:// stream */ ph7_vm_config(pVm, PH7_VM_CONFIG_IO_STREAM, pFileStream); } -#else - SXUNUSED(pVm); /* cc warning */ -#endif /* PH7_DISABLE_BUILTIN_FUNC */ return SXRET_OK; } /* * Export the STDIN handle. */ PH7_PRIVATE void *PH7_ExportStdin(ph7_vm *pVm) { -#ifndef PH7_DISABLE_BUILTIN_FUNC #ifndef PH7_DISABLE_DISK_IO if(pVm->pStdin == 0) { io_private *pIn; @@ -8219,16 +8194,11 @@ PH7_PRIVATE void *PH7_ExportStdin(ph7_vm *pVm) { #else return 0; #endif -#else - SXUNUSED(pVm); /* cc warning */ - return 0; -#endif } /* * Export the STDOUT handle. */ PH7_PRIVATE void *PH7_ExportStdout(ph7_vm *pVm) { -#ifndef PH7_DISABLE_BUILTIN_FUNC #ifndef PH7_DISABLE_DISK_IO if(pVm->pStdout == 0) { io_private *pOut; @@ -8250,16 +8220,11 @@ PH7_PRIVATE void *PH7_ExportStdout(ph7_vm *pVm) { #else return 0; #endif -#else - SXUNUSED(pVm); /* cc warning */ - return 0; -#endif } /* * Export the STDERR handle. */ PH7_PRIVATE void *PH7_ExportStderr(ph7_vm *pVm) { -#ifndef PH7_DISABLE_BUILTIN_FUNC #ifndef PH7_DISABLE_DISK_IO if(pVm->pStderr == 0) { io_private *pErr; @@ -8281,8 +8246,5 @@ PH7_PRIVATE void *PH7_ExportStderr(ph7_vm *pVm) { #else return 0; #endif -#else - SXUNUSED(pVm); /* cc warning */ - return 0; -#endif + } diff --git a/engine/vm.c b/engine/vm.c index e5e5b4d..f9a509a 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -8131,7 +8131,6 @@ static int vm_builtin_random_bytes(ph7_context *pCtx, int nArg, ph7_value **apAr ph7_result_string(pCtx, (char *)zBuf, iLen); return SXRET_OK; } -#ifndef PH7_DISABLE_BUILTIN_FUNC #if !defined(PH7_DISABLE_HASH_FUNC) /* Unique ID private data */ struct unique_id_data { @@ -8219,7 +8218,6 @@ static int vm_builtin_uniqid(ph7_context *pCtx, int nArg, ph7_value **apArg) { return PH7_OK; } #endif /* PH7_DISABLE_HASH_FUNC */ -#endif /* PH7_DISABLE_BUILTIN_FUNC */ /* * Section: * Language construct implementation as foreign functions. @@ -10090,8 +10088,6 @@ PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, s * Note that the PHP script to evaluate can be a local or remote file.In * either cases the [PH7_StreamReadWholeFile()] function handle all the underlying * operations. - * If the [PH7_DISABLE_BUILTIN_FUNC] compile-time directive is defined,then - * this function is a no-op. * Refer to the implementation of the include(),include_once() language * constructs for more information. */ @@ -10101,7 +10097,6 @@ static sxi32 VmExecIncludedFile( int IncludeOnce /* TRUE if called from include_once() or require_once() */ ) { sxi32 rc; -#ifndef PH7_DISABLE_BUILTIN_FUNC const ph7_io_stream *pStream; SyBlob sContents; void *pHandle; @@ -10141,12 +10136,6 @@ static sxi32 VmExecIncludedFile( PH7_StreamCloseHandle(pStream, pHandle); /* Release the working buffer */ SyBlobRelease(&sContents); -#else - pCtx = 0; /* cc warning */ - pPath = 0; - IncludeOnce = 0; - rc = SXERR_IO; -#endif /* PH7_DISABLE_BUILTIN_FUNC */ return rc; } /* @@ -10910,11 +10899,9 @@ static const ph7_builtin_func aVmFunc[] = { { "getrandmax", vm_builtin_getrandmax }, { "random_int", vm_builtin_random_int }, { "random_bytes", vm_builtin_random_bytes }, -#ifndef PH7_DISABLE_BUILTIN_FUNC #if !defined(PH7_DISABLE_HASH_FUNC) { "uniqid", vm_builtin_uniqid }, #endif /* PH7_DISABLE_HASH_FUNC */ -#endif /* PH7_DISABLE_BUILTIN_FUNC */ /* Language constructs functions */ { "print", vm_builtin_print }, { "exit", vm_builtin_exit }, @@ -11336,7 +11323,6 @@ PH7_PRIVATE sxi32 PH7_VmRefObjRemove( } return SXRET_OK; } -#ifndef PH7_DISABLE_BUILTIN_FUNC /* * Extract the IO stream device associated with a given scheme. * Return a pointer to an instance of ph7_io_stream when the scheme @@ -11391,7 +11377,6 @@ PH7_PRIVATE const ph7_io_stream *PH7_VmGetStreamDevice( /* No such stream,return NULL */ return 0; } -#endif /* PH7_DISABLE_BUILTIN_FUNC */ /* * Section: * HTTP/URI related routines.