Browse Source

Do not store script arguments in $GLOBALS.

release/v0.1
Rafal Kupiec 3 years ago
parent
commit
e383536dc4
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 4 additions and 21 deletions
  1. +1
    -2
      engine/hashmap.c
  2. +3
    -19
      engine/vm.c

+ 1
- 2
engine/hashmap.c View File

@ -1308,8 +1308,7 @@ PH7_PRIVATE sxi32 PH7_HashmapCreateSuper(ph7_vm *pVm) {
"_SESSION", /* $_SESSION */
"_REQUEST", /* $_REQUEST */
"_ENV", /* $_ENV */
"_HEADER", /* $_HEADER */
"argv" /* $argv */
"_HEADER" /* $_HEADER */
};
ph7_hashmap *pMap;
ph7_value *pObj;


+ 3
- 19
engine/vm.c View File

@ -1644,32 +1644,16 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
case PH7_VM_CONFIG_ARGV_ENTRY: {
/* Script arguments */
const char *zValue = va_arg(ap, const char *);
ph7_hashmap *pMap;
ph7_value *pValue;
sxu32 n;
if(SX_EMPTY_STR(zValue)) {
rc = SXERR_EMPTY;
break;
}
/* Extract the $argv array */
pValue = VmExtractSuper(&(*pVm), "argv", sizeof("argv") - 1);
if(pValue == 0 || (pValue->iFlags & MEMOBJ_HASHMAP) == 0) {
/* No such entry */
rc = SXERR_NOTFOUND;
break;
}
/* Point to the hashmap */
pMap = (ph7_hashmap *)pValue->x.pOther;
/* Perform the insertion */
n = (sxu32)SyStrlen(zValue);
rc = VmHashmapInsert(pMap, 0, 0, zValue, (int)n);
if(rc == SXRET_OK) {
if(pMap->nEntry > 1) {
/* Append space separator first */
SyBlobAppend(&pVm->sArgv, (const void *)" ", sizeof(char));
}
SyBlobAppend(&pVm->sArgv, (const void *)zValue, n);
if(SyBlobLength(&pVm->sArgv) > 0) {
SyBlobAppend(&pVm->sArgv, (const void *)" ", sizeof(char));
}
SyBlobAppend(&pVm->sArgv, (const void *)zValue, n);
break;
}
case PH7_VM_CONFIG_IO_STREAM: {


Loading…
Cancel
Save