This commit is contained in:
John Kerl 2017-02-10 22:54:36 -05:00
parent feee0c49d5
commit ad375d1e0b
2 changed files with 35 additions and 2 deletions

View file

@ -1535,3 +1535,34 @@ void mlhmmv_root_print_json_single_lines(mlhmmv_root_t* pmap, int quote_keys_alw
quote_values_always, ostream);
fprintf(ostream, "%s", line_term);
}
// xxx to do
//// Temporarily wrap the localvar in a parent map whose single key is the variable name.
//void mlhmmv_named_level_to_lrecs(
// sllmv_t* pmvkeys,
// sllmv_t* pmvnames,
// mv_t* pname,
// xxx pmvnames,
// mlhmmv_xvalue_t* pxval,
// sllv_t* poutrecs,
// int do_full_prefixing,
// char* oosvar_flatten_separator)
//{
// mlhmmv_root_t* pmap = mlhmmv_root_alloc();
// mlhmmv_level_put_xvalue_singly_keyed(pmap->root_xvalue.proot_level, &name, pmval);
//
// mlhmmv_root_partial_to_lrecs(pmap, pmvkeys, pmvnames, poutrecs,
// pstate->do_full_prefixing, oosvar_flatten_separator);
//
// mlhmmv_level_unreference_single_key(pmap->root_xvalue.proot_level);
//
// mlhmmv_root_free(pmap);
//}
//
//void mlhmmv_level_unreference_single_key(mlhmmv_t* plevel) {
// mlhmmv_level_entry_t* pentry = plevel->phead;
// mv_free(&pentry->level_key);
// plevel->phead = NULL;
// plevel->tail = NULL;
// plevel->num_occupied = 0;
//}

View file

@ -869,6 +869,10 @@ static void record_emitter_from_local_variable(
{
int keys_all_non_null_or_error = TRUE;
sllmv_t* pmvkeys = evaluate_list(pstate->pemit_keylist_evaluators, pvars, &keys_all_non_null_or_error);
mv_t name = mv_from_string(pstate->localvar_name, NO_FREE);
sllmv_prepend_no_free(pmvkeys, &name);
if (keys_all_non_null_or_error) {
int names_all_non_null_or_error = TRUE;
sllmv_t* pmvnames = evaluate_list(pstate->pemit_namelist_evaluators, pvars,
@ -882,7 +886,6 @@ static void record_emitter_from_local_variable(
// xxx this is an unpleasant hack. The idea is to temporarily wrap the localvar
// in a parent map whose single key is the variable name.
mv_t name = mv_from_string(pstate->localvar_name, NO_FREE);
// xxx libify
mlhmmv_level_t* proot_level = mlhmmv_level_alloc();
@ -893,7 +896,6 @@ static void record_emitter_from_local_variable(
map.root_xvalue.is_terminal = FALSE;
map.root_xvalue.terminal_mlrval = mv_absent();
map.root_xvalue.pnext_level = proot_level;
sllmv_prepend_no_free(pmvkeys, &name);
mlhmmv_root_partial_to_lrecs(&map, pmvkeys, pmvnames, poutrecs,
pstate->do_full_prefixing, oosvar_flatten_separator);