diff --git a/sapi/cli/main.c b/sapi/cli/main.c index 7cf879c..88100f8 100644 --- a/sapi/cli/main.c +++ b/sapi/cli/main.c @@ -29,6 +29,10 @@ */ #include #include +#include +#ifndef PATH_MAX + #define PATH_MAX MAX_PATH +#endif /* Make sure this header file is available.*/ #include "ph7.h" /* @@ -109,6 +113,7 @@ static int Output_Consumer(const void *pOutput, unsigned int nOutputLen, void *p int main(int argc, char **argv) { ph7 *pEngine; /* PH7 engine */ ph7_vm *pVm; /* Compiled PHP program */ + char pScriptPath[PATH_MAX]; /* Full path of the script */ int dump_vm = 0; /* Dump VM instructions if TRUE */ int err_report = 0; /* Report run-time errors if TRUE */ int n; /* Script arguments */ @@ -153,9 +158,16 @@ int main(int argc, char **argv) { 0 /* NULL: Callback Private data */ ); /* Now,it's time to compile our PHP file */ +#ifdef __UNIXES__ + if(realpath(argv[n], pScriptPath) == NULL) { +#else + if(GetFullPathName(argv[n], PATH_MAX, pScriptPath, NULL) != 0) { +#endif + Fatal("Error cannot retrieve full path of the script"); + } rc = ph7_compile_file( pEngine, /* PH7 Engine */ - argv[n], /* Path to the PHP file to compile */ + pScriptPath, /* Path to the PHP file to compile */ &pVm, /* OUT: Compiled PHP program */ 0 /* IN: Compile flags */ ); @@ -213,4 +225,4 @@ int main(int argc, char **argv) { ph7_vm_release(pVm); ph7_release(pEngine); return 0; -} \ No newline at end of file +}