This commit is contained in:
parent
cbb4a0aa5c
commit
2160747479
21
engine/vm.c
21
engine/vm.c
@ -10600,7 +10600,6 @@ static int vm_builtin_get_included_files(ph7_context *pCtx, int nArg, ph7_value
|
|||||||
SySet *pFiles = &pCtx->pVm->aIncluded;
|
SySet *pFiles = &pCtx->pVm->aIncluded;
|
||||||
ph7_value *pArray, *pWorker;
|
ph7_value *pArray, *pWorker;
|
||||||
SyString *pEntry;
|
SyString *pEntry;
|
||||||
int c, d;
|
|
||||||
/* Create an array and a working value */
|
/* Create an array and a working value */
|
||||||
pArray = ph7_context_new_array(pCtx);
|
pArray = ph7_context_new_array(pCtx);
|
||||||
pWorker = ph7_context_new_scalar(pCtx);
|
pWorker = ph7_context_new_scalar(pCtx);
|
||||||
@ -10611,31 +10610,13 @@ static int vm_builtin_get_included_files(ph7_context *pCtx, int nArg, ph7_value
|
|||||||
SXUNUSED(apArg);
|
SXUNUSED(apArg);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
c = d = '/';
|
|
||||||
#ifdef __WINNT__
|
|
||||||
d = '\\';
|
|
||||||
#endif
|
|
||||||
/* Iterate throw entries */
|
/* Iterate throw entries */
|
||||||
SySetResetCursor(pFiles);
|
SySetResetCursor(pFiles);
|
||||||
while(SXRET_OK == SySetGetNextEntry(pFiles, (void **)&pEntry)) {
|
while(SXRET_OK == SySetGetNextEntry(pFiles, (void **)&pEntry)) {
|
||||||
const char *zBase, *zEnd;
|
|
||||||
int iLen;
|
|
||||||
/* reset the string cursor */
|
/* reset the string cursor */
|
||||||
ph7_value_reset_string_cursor(pWorker);
|
ph7_value_reset_string_cursor(pWorker);
|
||||||
/* Extract base name */
|
|
||||||
zEnd = &pEntry->zString[pEntry->nByte - 1];
|
|
||||||
/* Ignore trailing '/' */
|
|
||||||
while(zEnd > pEntry->zString && ((int)zEnd[0] == c || (int)zEnd[0] == d)) {
|
|
||||||
zEnd--;
|
|
||||||
}
|
|
||||||
iLen = (int)(&zEnd[1] - pEntry->zString);
|
|
||||||
while(zEnd > pEntry->zString && ((int)zEnd[0] != c && (int)zEnd[0] != d)) {
|
|
||||||
zEnd--;
|
|
||||||
}
|
|
||||||
zBase = (zEnd > pEntry->zString) ? &zEnd[1] : pEntry->zString;
|
|
||||||
zEnd = &pEntry->zString[iLen];
|
|
||||||
/* Copy entry name */
|
/* Copy entry name */
|
||||||
ph7_value_string(pWorker, zBase, (int)(zEnd - zBase));
|
ph7_value_string(pWorker, pEntry->zString, pEntry->nByte);
|
||||||
/* Perform the insertion */
|
/* Perform the insertion */
|
||||||
ph7_array_add_elem(pArray, 0/* Automatic index assign*/, pWorker); /* Will make it's own copy */
|
ph7_array_add_elem(pArray, 0/* Automatic index assign*/, pWorker); /* Will make it's own copy */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user