env-var iterate

This commit is contained in:
John Kerl 2016-02-12 09:29:19 -05:00
parent 971aaa1c3b
commit ba06a02d74
3 changed files with 11 additions and 8 deletions

View file

@ -122,7 +122,7 @@ char* mv_format_val(mv_t* pval, char* pfree_flags) {
break;
case MT_STRING:
// Ownership transfer to the caller
*pfree_flags = FREE_ENTRY_VALUE;
*pfree_flags = pval->free_flags;;
rv = pval->u.strv;
*pval = MV_NULL;
break;

View file

@ -1748,16 +1748,19 @@ mv_t lrec_evaluator_environment_func(lrec_t* prec, lhmsv_t* ptyped_overlay, mlhm
if (mv_is_null(&mvname)) {
return MV_NULL;
}
// xxx string strict ...
char* value = getenv(mvname.u.strv);
if (value == NULL) {
char free_flags;
char* strname = mv_format_val(&mvname, &free_flags);
char* strvalue = getenv(strname);
if (strvalue == NULL) {
mv_free(&mvname);
if (free_flags & FREE_ENTRY_VALUE)
free(strname);
return MV_NULL;
}
mv_t rv = mv_from_string(value, NO_FREE);
mv_t rv = mv_from_string(strvalue, NO_FREE);
mv_free(&mvname);
if (free_flags & FREE_ENTRY_VALUE)
free(strname);
return rv;
}

View file

@ -7,7 +7,7 @@ BUGFIXES
TOP-OF-LIST SUMMARY
* JSON input: UT/doc items
* env vars: UT
* env vars: UT; OLH ~ PI/E/etc.
! rh/fedora/centos mlr-3.3.2: after patch-file for manpage
* parameterized emit: needs spec & impl
* pattern-action: note that breaks the simple LHS/RHS partition I've enjoyed up until now