Needs a touch more
This commit is contained in:
parent
61afa57339
commit
a7b33fd4dc
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -38,6 +38,8 @@
|
|||||||
"codingworkshop",
|
"codingworkshop",
|
||||||
],
|
],
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"ph7int.h": "c"
|
"ph7int.h": "c",
|
||||||
|
"ph7.h": "c",
|
||||||
|
"stdlib.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -169,6 +169,7 @@ int main(int argc, char **argv) {
|
|||||||
Fatal("Compile error");
|
Fatal("Compile error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we have our script compiled,it's time to configure our VM.
|
* Now we have our script compiled,it's time to configure our VM.
|
||||||
* We will install the VM output consumer callback defined above
|
* We will install the VM output consumer callback defined above
|
||||||
|
5
ph7.h
5
ph7.h
@ -166,11 +166,16 @@ typedef struct ph7 ph7;
|
|||||||
#if !defined(SYMISC_STANDARD_DEFS)
|
#if !defined(SYMISC_STANDARD_DEFS)
|
||||||
#define SYMISC_STANDARD_DEFS
|
#define SYMISC_STANDARD_DEFS
|
||||||
#if defined (_WIN32) || defined (WIN32) || defined(__MINGW32__) || defined (_MSC_VER) || defined (_WIN32_WCE)
|
#if defined (_WIN32) || defined (WIN32) || defined(__MINGW32__) || defined (_MSC_VER) || defined (_WIN32_WCE)
|
||||||
|
#include <direct.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
/* Windows Systems */
|
/* Windows Systems */
|
||||||
#if !defined(__WINNT__)
|
#if !defined(__WINNT__)
|
||||||
#define __WINNT__
|
#define __WINNT__
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
#include <libgen.h>
|
||||||
/*
|
/*
|
||||||
* By default we will assume that we are compiling on a UNIX systems.
|
* By default we will assume that we are compiling on a UNIX systems.
|
||||||
* Otherwise the OS_OTHER directive must be defined.
|
* Otherwise the OS_OTHER directive must be defined.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
echo '[a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
require_once 'b.php';
|
require_once '../b/b.php';
|
||||||
echo '[a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo '[b] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[b] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
require_once 'c.php';
|
require_once 'c/c.php';
|
||||||
echo '[b] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[b] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo '[c] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[c] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
require_once 'more/a.php';
|
require_once '../../more/a.php';
|
||||||
echo '[c] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[c] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
echo '[main] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[main] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
require_once 'a.php';
|
require_once 'a/a.php';
|
||||||
echo '[main] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
echo '[main] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo '[more/a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
|
||||||
require_once 'b.php';
|
|
||||||
echo '[more/a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo '[more/a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
var_dump(debug_backtrace());
|
var_dump(debug_backtrace());
|
||||||
|
echo '[more/a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
|
4
vfs.c
4
vfs.c
@ -2880,7 +2880,9 @@ PH7_PRIVATE void *PH7_StreamOpenHandle(ph7_vm *pVm, const ph7_io_stream *pStream
|
|||||||
#endif
|
#endif
|
||||||
(sFile.nByte > 1 && sFile.zString[0] == '.' && sFile.zString[1] == '/') ||
|
(sFile.nByte > 1 && sFile.zString[0] == '.' && sFile.zString[1] == '/') ||
|
||||||
(sFile.nByte > 2 && sFile.zString[0] == '.' && sFile.zString[1] == '.' && sFile.zString[2] == '/')) {
|
(sFile.nByte > 2 && sFile.zString[0] == '.' && sFile.zString[1] == '.' && sFile.zString[2] == '/')) {
|
||||||
|
|
||||||
/* Open the file directly */
|
/* Open the file directly */
|
||||||
|
//printf("open file directly = %s\n", sFile.zString);
|
||||||
rc = pStream->xOpen(zFile, iFlags, pResource, &pHandle);
|
rc = pStream->xOpen(zFile, iFlags, pResource, &pHandle);
|
||||||
} else {
|
} else {
|
||||||
SyString *pPath;
|
SyString *pPath;
|
||||||
@ -2907,7 +2909,7 @@ PH7_PRIVATE void *PH7_StreamOpenHandle(ph7_vm *pVm, const ph7_io_stream *pStream
|
|||||||
if(rc == PH7_OK) {
|
if(rc == PH7_OK) {
|
||||||
if(bPushInclude) {
|
if(bPushInclude) {
|
||||||
/* Mark as included */
|
/* Mark as included */
|
||||||
//PH7_VmPushFilePath(pVm, (const char *)SyBlobData(&sWorker), SyBlobLength(&sWorker), FALSE, pNew);
|
PH7_VmPushFilePath(pVm, (const char *)SyBlobData(&sWorker), SyBlobLength(&sWorker), FALSE, pNew);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
35
vm.c
35
vm.c
@ -10543,7 +10543,7 @@ PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, s
|
|||||||
*pNew = 1;
|
*pNew = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("push file = %s\n", sPath.zString);
|
//printf("push file = %s\n", sPath.zString);
|
||||||
SySetPut(&pVm->aFiles, (const void *)&sPath);
|
SySetPut(&pVm->aFiles, (const void *)&sPath);
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
@ -10577,15 +10577,44 @@ static sxi32 VmExecIncludedFile(
|
|||||||
isNew = 0;
|
isNew = 0;
|
||||||
/* Extract the associated stream */
|
/* Extract the associated stream */
|
||||||
pStream = PH7_VmGetStreamDevice(pVm, &pPath->zString, pPath->nByte);
|
pStream = PH7_VmGetStreamDevice(pVm, &pPath->zString, pPath->nByte);
|
||||||
|
/* Set the cwd */
|
||||||
|
SyString *cFile = SySetPeek(&pVm->aFiles);
|
||||||
|
//printf("cwd: %s\n", cwd->zString);
|
||||||
|
#ifdef __WINNT__
|
||||||
|
char cwd[256];
|
||||||
|
_splitpath_s(cFile->zString,
|
||||||
|
NULL, 0, // Don't need drive
|
||||||
|
cwd, sizeof(cwd), // Just the directory
|
||||||
|
NULL, 0, // Don't need filename
|
||||||
|
NULL, 0);
|
||||||
|
//printf("dir: %s\n", dir);
|
||||||
|
if (_chdir(cwd)) {
|
||||||
|
/*switch (errno) {
|
||||||
|
case ENOENT:
|
||||||
|
printf("Unable to locate the directory: %s\n", cwd);
|
||||||
|
break;
|
||||||
|
case EINVAL:
|
||||||
|
printf("Invalid buffer.\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Unknown error.\n");
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
char *cwd = dirname(cFile->zString);
|
||||||
|
chdir(cwd);
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Open the file or the URL [i.e: http://ph7.symisc.net/example/hello.php"]
|
* Open the file or the URL [i.e: http://ph7.symisc.net/example/hello.php"]
|
||||||
* in a read-only mode.
|
* in a read-only mode.
|
||||||
*/
|
*/
|
||||||
printf("eval file: %s\n", pPath->zString);
|
//printf("try eval file: %s, %s\n", pPath->zString, pPath->zString);
|
||||||
pHandle = PH7_StreamOpenHandle(pVm, pStream, pPath->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) {
|
if(pHandle == 0) {
|
||||||
|
//printf("file not found: %s\n", pPath->zString);
|
||||||
return SXERR_IO;
|
return SXERR_IO;
|
||||||
}
|
}
|
||||||
|
//printf("eval file: %s\n", pPath->zString);
|
||||||
rc = SXRET_OK; /* Stupid cc warning */
|
rc = SXRET_OK; /* Stupid cc warning */
|
||||||
if(IncludeOnce && !isNew) {
|
if(IncludeOnce && !isNew) {
|
||||||
/* Already included */
|
/* Already included */
|
||||||
@ -10600,7 +10629,7 @@ static sxi32 VmExecIncludedFile(
|
|||||||
VmEvalChunk(pCtx->pVm, &(*pCtx), &sScript, 0, TRUE);
|
VmEvalChunk(pCtx->pVm, &(*pCtx), &sScript, 0, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("pop file = %s\n", ((SyString*)SySetPop(&pVm->aFiles))->zString);
|
//printf("pop file = %s\n", ((SyString*)SySetPop(&pVm->aFiles))->zString);
|
||||||
/* Pop from the set of included file */
|
/* Pop from the set of included file */
|
||||||
//(void)SySetPop(&pVm->aFiles);
|
//(void)SySetPop(&pVm->aFiles);
|
||||||
/* Close the handle */
|
/* Close the handle */
|
||||||
|
Loading…
Reference in New Issue
Block a user