diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2015-06-16 17:27:20 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2015-06-16 17:27:20 (GMT) |
commit | 91eb17db8ee7fcda566436fa2336fac2cf2c3660 (patch) | |
tree | 3c5a7f44c41852889299d2c04e56a56f80ee9457 /src | |
parent | 4f231ddc9bd1e0b71b4ed7fd0d82e9ca362f942e (diff) | |
download | hdf5-91eb17db8ee7fcda566436fa2336fac2cf2c3660.zip hdf5-91eb17db8ee7fcda566436fa2336fac2cf2c3660.tar.gz hdf5-91eb17db8ee7fcda566436fa2336fac2cf2c3660.tar.bz2 |
[svn-r27215] Fix issue where % characters could not be used in non-printf mappings.
Other minor fixes/cleanup.
Tested: ummon
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dvirtual.c | 118 | ||||
-rw-r--r-- | src/H5Olayout.c | 37 | ||||
-rw-r--r-- | src/H5Oprivate.h | 6 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 40 |
4 files changed, 144 insertions, 57 deletions
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index f6a16ee..4a9f79f 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -228,22 +228,31 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) /* Copy the list entries, though set source_dset.dset and sub_dset to * NULL */ for(i = 0; i < layout->storage.u.virt.list_nused; i++) { - if(NULL == (layout->storage.u.virt.list[i].source_dset.file_name - = HDstrdup(orig_list[i].source_dset.file_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") - if(NULL == (layout->storage.u.virt.list[i].source_dset.dset_name - = HDstrdup(orig_list[i].source_dset.dset_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + /* Copy virtual selection */ if(NULL == (layout->storage.u.virt.list[i].source_dset.virtual_select = H5S_copy(orig_list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") + + /* Copy original source names */ + if(NULL == (layout->storage.u.virt.list[i].source_file_name + = HDstrdup(orig_list[i].source_file_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") + if(NULL == (layout->storage.u.virt.list[i].source_dset_name + = HDstrdup(orig_list[i].source_dset_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + + /* Copy source selection */ if(NULL == (layout->storage.u.virt.list[i].source_select = H5S_copy(orig_list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") + + /* Initialize clipped selections */ if(orig_list[i].unlim_dim_virtual < 0) { layout->storage.u.virt.list[i].source_dset.clipped_source_select = layout->storage.u.virt.list[i].source_select; layout->storage.u.virt.list[i].source_dset.clipped_virtual_select = layout->storage.u.virt.list[i].source_dset.virtual_select; } /* end if */ + + /* Copy parsed names */ if(H5D__virtual_copy_parsed_name(&layout->storage.u.virt.list[i].parsed_source_file_name, orig_list[i].parsed_source_file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source file name") layout->storage.u.virt.list[i].psfn_static_strlen = orig_list[i].psfn_static_strlen; @@ -252,6 +261,43 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source dataset name") layout->storage.u.virt.list[i].psdn_static_strlen = orig_list[i].psdn_static_strlen; layout->storage.u.virt.list[i].psdn_nsubs = orig_list[i].psdn_nsubs; + + /* Copy source names in source dset or add reference as appropriate + */ + if(orig_list[i].source_dset.file_name) { + if(orig_list[i].source_dset.file_name + == orig_list[i].source_file_name) + layout->storage.u.virt.list[i].source_dset.file_name = layout->storage.u.virt.list[i].source_file_name; + else if(orig_list[i].parsed_source_file_name + && (orig_list[i].source_dset.file_name + != orig_list[i].parsed_source_file_name->name_segment)) { + HDassert(layout->storage.u.virt.list[i].parsed_source_file_name); + HDassert(layout->storage.u.virt.list[i].parsed_source_file_name->name_segment); + layout->storage.u.virt.list[i].source_dset.file_name = layout->storage.u.virt.list[i].parsed_source_file_name->name_segment; + } /* end if */ + else + if(NULL == (layout->storage.u.virt.list[i].source_dset.file_name + = HDstrdup(orig_list[i].source_dset.file_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") + } /* end if */ + if(orig_list[i].source_dset.dset_name) { + if(orig_list[i].source_dset.dset_name + == orig_list[i].source_dset_name) + layout->storage.u.virt.list[i].source_dset.dset_name = layout->storage.u.virt.list[i].source_dset_name; + else if(orig_list[i].parsed_source_dset_name + && (orig_list[i].source_dset.dset_name + != orig_list[i].parsed_source_dset_name->name_segment)) { + HDassert(layout->storage.u.virt.list[i].parsed_source_dset_name); + HDassert(layout->storage.u.virt.list[i].parsed_source_dset_name->name_segment); + layout->storage.u.virt.list[i].source_dset.dset_name = layout->storage.u.virt.list[i].parsed_source_dset_name->name_segment; + } /* end if */ + else + if(NULL == (layout->storage.u.virt.list[i].source_dset.dset_name + = HDstrdup(orig_list[i].source_dset.dset_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + } /* end if */ + + /* Copy other fields in entry */ layout->storage.u.virt.list[i].unlim_dim_source = orig_list[i].unlim_dim_source; layout->storage.u.virt.list[i].unlim_dim_virtual = orig_list[i].unlim_dim_virtual; layout->storage.u.virt.list[i].unlim_extent_source = orig_list[i].unlim_extent_source; @@ -263,7 +309,7 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) } /* end for */ } /* end if */ else { - HDassert(0 && "checking code coverage...");//VDSINC + HDassert(0 && "checking code coverage..."); //VDSINC /* Zero out other fields related to list, just to be sure */ layout->storage.u.virt.list = NULL; layout->storage.u.virt.list_nalloc = 0; @@ -318,6 +364,10 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) if(H5D__virtual_reset_source_dset(&layout->storage.u.virt.list[i], &layout->storage.u.virt.list[i].source_dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") + /* Free original source names */ + (void)H5MM_xfree(layout->storage.u.virt.list[i].source_file_name); + (void)H5MM_xfree(layout->storage.u.virt.list[i].source_dset_name); + /* Free sub_dset */ for(j = 0; j < layout->storage.u.virt.list[i].sub_dset_nalloc; j++) if(H5D__virtual_reset_source_dset(&layout->storage.u.virt.list[i], &layout->storage.u.virt.list[i].sub_dset[j]) < 0) @@ -495,14 +545,28 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, } /* end if */ /* Free file name */ - if((source_dset == &virtual_ent->source_dset) - || virtual_ent->parsed_source_file_name) + if(virtual_ent->parsed_source_file_name + && (source_dset->file_name + != virtual_ent->parsed_source_file_name->name_segment)) source_dset->file_name = (char *)H5MM_xfree(source_dset->file_name); + else + HDassert((source_dset->file_name == virtual_ent->source_file_name) + || (virtual_ent->parsed_source_file_name + && (source_dset->file_name + == virtual_ent->parsed_source_file_name->name_segment)) + || !source_dset->file_name); /* Free dataset name */ - if((source_dset == &virtual_ent->source_dset) - || virtual_ent->parsed_source_dset_name) + if(virtual_ent->parsed_source_dset_name + && (source_dset->dset_name + != virtual_ent->parsed_source_dset_name->name_segment)) source_dset->dset_name = (char *)H5MM_xfree(source_dset->dset_name); + else + HDassert((source_dset->dset_name == virtual_ent->source_dset_name) + || (virtual_ent->parsed_source_dset_name + && (source_dset->dset_name + == virtual_ent->parsed_source_dset_name->name_segment)) + || !source_dset->dset_name); /* Free clipped virtual selection */ if(source_dset->clipped_virtual_select) { @@ -695,8 +759,9 @@ H5D_virtual_parse_source_name(const char *source_name, p = pct + 2; } /* end while */ - /* Copy last segment of name, if any, unless there were no substitutions */ - if(tmp_nsubs > 0) { + /* Copy last segment of name, if any, unless the parsed name was not + * allocated */ + if(tmp_parsed_name) { HDassert(p >= source_name); if(*p == '\0') HDassert((size_t)(p - source_name) == tmp_strlen); @@ -849,8 +914,10 @@ H5D__virtual_build_source_name(char *source_name, /* Check for static name */ if(nsubs == 0) { - HDassert(!parsed_name); - *built_name = source_name; + if(parsed_name) + *built_name = parsed_name->name_segment; + else + *built_name = source_name; } /* end if */ else { const H5O_storage_virtual_name_seg_t *name_seg = parsed_name; @@ -1105,12 +1172,12 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) else { /* Resolve file name */ if(!storage->list[i].sub_dset[j].file_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset.file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) + if(H5D__virtual_build_source_name(storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source file name") /* Resolve dset name */ if(!storage->list[i].sub_dset[j].dset_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset.dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) + if(H5D__virtual_build_source_name(storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source dataset name") /* Resolve virtual selection for block */ @@ -1399,7 +1466,7 @@ done: */ herr_t H5D__virtual_init(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, - const H5D_t *dset, hid_t dapl_id) + const H5D_t *dset, hid_t dapl_id) { H5O_storage_virtual_t *storage; /* Convenience pointer */ H5P_genplist_t *dapl; /* Data access property list object pointer */ @@ -1521,8 +1588,7 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { hbool_t partial_block; HDassert(storage->list[i].unlim_dim_virtual >= 0); @@ -1667,8 +1733,7 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) @@ -1795,8 +1860,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) @@ -1820,8 +1884,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) @@ -1978,8 +2041,7 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) { diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 33c35ed..5a388fe 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -283,16 +283,16 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED * for(i = 0; i < mesg->storage.u.virt.list_nused; i++) { /* Source file name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_dset.file_name = (char *)H5MM_malloc(tmp_size))) + if(NULL == (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source file name") - (void)HDmemcpy(mesg->storage.u.virt.list[i].source_dset.file_name, heap_block_p, tmp_size); + (void)HDmemcpy(mesg->storage.u.virt.list[i].source_file_name, heap_block_p, tmp_size); heap_block_p += tmp_size; /* Source dataset name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_dset.dset_name = (char *)H5MM_malloc(tmp_size))) + if(NULL == (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source dataset name") - (void)HDmemcpy(mesg->storage.u.virt.list[i].source_dset.dset_name, heap_block_p, tmp_size); + (void)HDmemcpy(mesg->storage.u.virt.list[i].source_dset_name, heap_block_p, tmp_size); heap_block_p += tmp_size; /* Source selection */ @@ -305,11 +305,24 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED * /* Parse source file and dataset names for "printf" * style format specifiers */ - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset.file_name, &mesg->storage.u.virt.list[i].parsed_source_file_name, &mesg->storage.u.virt.list[i].psfn_static_strlen, &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) + if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_file_name, &mesg->storage.u.virt.list[i].parsed_source_file_name, &mesg->storage.u.virt.list[i].psfn_static_strlen, &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source file name") - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset.dset_name, &mesg->storage.u.virt.list[i].parsed_source_dset_name, &mesg->storage.u.virt.list[i].psdn_static_strlen, &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) + if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset_name, &mesg->storage.u.virt.list[i].parsed_source_dset_name, &mesg->storage.u.virt.list[i].psdn_static_strlen, &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source dataset name") + /* Set source names in source_dset struct */ + if((mesg->storage.u.virt.list[i].psfn_nsubs == 0) + && (mesg->storage.u.virt.list[i].psdn_nsubs == 0)) { + if(mesg->storage.u.virt.list[i].parsed_source_file_name) + mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].parsed_source_file_name->name_segment; + else + mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].source_file_name; + if(mesg->storage.u.virt.list[i].parsed_source_dset_name) + mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].parsed_source_dset_name->name_segment; + else + mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].source_dset_name; + } /* end if */ + /* unlim_dim fields */ mesg->storage.u.virt.list[i].unlim_dim_source = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_select); mesg->storage.u.virt.list[i].unlim_dim_virtual = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_dset.virtual_select); @@ -486,17 +499,17 @@ H5O_layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c /* Calculate size of each entry */ for(i = 0; i < mesg->storage.u.virt.list_nused; i++) { - HDassert(mesg->storage.u.virt.list[i].source_dset.file_name); - HDassert(mesg->storage.u.virt.list[i].source_dset.dset_name); + HDassert(mesg->storage.u.virt.list[i].source_file_name); + HDassert(mesg->storage.u.virt.list[i].source_dset_name); HDassert(mesg->storage.u.virt.list[i].source_select); HDassert(mesg->storage.u.virt.list[i].source_dset.virtual_select); /* Source file name */ - str_size[2 * i] = HDstrlen(mesg->storage.u.virt.list[i].source_dset.file_name) + (size_t)1; + str_size[2 * i] = HDstrlen(mesg->storage.u.virt.list[i].source_file_name) + (size_t)1; block_size += str_size[2 * i]; /* Source dset name */ - str_size[(2 * i) + 1] = HDstrlen(mesg->storage.u.virt.list[i].source_dset.dset_name) + (size_t)1; + str_size[(2 * i) + 1] = HDstrlen(mesg->storage.u.virt.list[i].source_dset_name) + (size_t)1; block_size += str_size[(2 * i) + 1]; /* Source selection */ @@ -529,11 +542,11 @@ H5O_layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c /* Encode each entry */ for(i = 0; i < mesg->storage.u.virt.list_nused; i++) { /* Source file name */ - (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_dset.file_name); + (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_file_name); heap_block_p += str_size[2 * i]; /* Source dataset name */ - (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_dset.dset_name); + (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_dset_name); heap_block_p += str_size[(2 * i) + 1]; /* Source selection */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 8462382..29f727d 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -415,11 +415,11 @@ typedef struct H5O_storage_compact_t { typedef struct H5O_storage_virtual_srcdset_t { /* Stored */ - char *file_name; /* Source file name used for virtual dataset mapping */ - char *dset_name; /* Source dataset name used for virtual dataset mapping */ struct H5S_t *virtual_select; /* Selection in the virtual dataset that is mapped to source selection */ /* Not stored */ + char *file_name; /* Source file name used for virtual dataset mapping */ + char *dset_name; /* Source dataset name used for virtual dataset mapping */ struct H5S_t *clipped_source_select; /* Clipped version of source_select */ struct H5S_t *clipped_virtual_select; /* Clipped version of virtual_select */ struct H5D_t *dset; /* Source dataset */ @@ -443,6 +443,8 @@ typedef enum H5O_virtual_space_status_t { typedef struct H5O_storage_virtual_ent_t { /* Stored */ H5O_storage_virtual_srcdset_t source_dset; /* Information about the source dataset */ + char *source_file_name; /* Original (unparsed) source file name */ + char *source_dset_name; /* Original (unparsed) source dataset name */ struct H5S_t *source_select; /* Selection in the source dataset for mapping */ /* Not stored */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index d17a281..54694a0 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1674,19 +1674,29 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, /* Add virtual dataset mapping entry */ ent = &layout.storage.u.virt.list[layout.storage.u.virt.list_nused]; - if(NULL == (ent->source_dset.file_name = HDstrdup(src_file_name))) - HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - adding_entry = TRUE; - if(NULL == (ent->source_dset.dset_name = HDstrdup(src_dset_name))) - HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") if(NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") + adding_entry = TRUE; + if(NULL == (ent->source_file_name = HDstrdup(src_file_name))) + HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") + if(NULL == (ent->source_dset_name = HDstrdup(src_dset_name))) + HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") if(NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") - if(H5D_virtual_parse_source_name(ent->source_dset.file_name, &ent->parsed_source_file_name, &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) + if(H5D_virtual_parse_source_name(ent->source_file_name, &ent->parsed_source_file_name, &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") - if(H5D_virtual_parse_source_name(ent->source_dset.dset_name, &ent->parsed_source_dset_name, &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) + if(H5D_virtual_parse_source_name(ent->source_dset_name, &ent->parsed_source_dset_name, &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") + if((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) { + if(ent->parsed_source_file_name) + ent->source_dset.file_name = ent->parsed_source_file_name->name_segment; + else + ent->source_dset.file_name = ent->source_file_name; + if(ent->parsed_source_dset_name) + ent->source_dset.dset_name = ent->parsed_source_dset_name->name_segment; + else + ent->source_dset.dset_name = ent->source_dset_name; + } /* end if */ ent->unlim_dim_source = H5S_get_select_unlim_dim(src_space); ent->unlim_dim_virtual = H5S_get_select_unlim_dim(vspace); if(ent->unlim_dim_virtual < 0) { @@ -1735,8 +1745,8 @@ done: if(ret_value < 0) { /* Free incomplete entry if present */ if(ent) { - ent->source_dset.file_name = (char *)H5MM_xfree(ent->source_dset.file_name); - ent->source_dset.dset_name = (char *)H5MM_xfree(ent->source_dset.dset_name); + ent->source_file_name = (char *)H5MM_xfree(ent->source_file_name); + ent->source_dset_name = (char *)H5MM_xfree(ent->source_dset_name); if(ent->source_dset.virtual_select && H5S_close(ent->source_dset.virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") ent->source_dset.virtual_select = NULL; @@ -1960,10 +1970,10 @@ H5Pget_virtual_filename(hid_t dcpl_id, size_t index, char *name/*out*/, if(index >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); - HDassert(layout.storage.u.virt.list[index].source_dset.file_name); + HDassert(layout.storage.u.virt.list[index].source_file_name); if(name && (size > 0)) - (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_dset.file_name, size); - ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_dset.file_name); + (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_file_name, size); + ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_file_name); done: FUNC_LEAVE_API(ret_value) @@ -2007,10 +2017,10 @@ H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, char *name/*out*/, if(index >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); - HDassert(layout.storage.u.virt.list[index].source_dset.dset_name); + HDassert(layout.storage.u.virt.list[index].source_dset_name); if(name && (size > 0)) - (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_dset.dset_name, size); - ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_dset.dset_name); + (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_dset_name, size); + ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_dset_name); done: FUNC_LEAVE_API(ret_value) |