more name normalization

This commit is contained in:
Ed Hartnett 2018-11-30 09:14:53 -07:00
parent 77d0922d49
commit d0587c9536
2 changed files with 11 additions and 3 deletions

View File

@ -696,6 +696,10 @@ nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum,
LOG((4, "%s: ncid %d varid %d attnum %d use_name %d", __func__, ncid, varid,
attnum, use_name));
/* Don't need to provide name unless getting att pointer and using
* use_name. */
assert(!att || ((use_name && name) || !use_name));
/* Find info for this file, group, and h5 info. */
if ((retval = nc4_find_nc_grp_h5(ncid, NULL, &my_grp, &my_h5)))
return retval;
@ -725,10 +729,15 @@ nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum,
}
assert(attlist);
/* Normalize the name. */
if (use_name && name)
if ((retval = nc4_normalize_name(name, my_norm_name)))
return retval;
/* Now find the attribute by name or number. */
if (att)
{
my_att = use_name ? (NC_ATT_INFO_T *)ncindexlookup(attlist, name) :
my_att = use_name ? (NC_ATT_INFO_T *)ncindexlookup(attlist, my_norm_name) :
(NC_ATT_INFO_T *)ncindexith(attlist, attnum);
if (!my_att)
return NC_ENOTATT;

View File

@ -2062,14 +2062,13 @@ NC4_HDF5_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
NC_FILE_INFO_T *h5;
NC_GRP_INFO_T *grp;
NC_VAR_INFO_T *var = NULL;
char norm_name[NC_MAX_NAME + 1];
int retval;
LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid));
/* Find the file, group, and var info, and do lazy att read if
* needed. */
if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, name, 0, 1, norm_name,
if ((retval = nc4_hdf5_find_grp_var_att(ncid, varid, NULL, 0, 0, NULL,
&h5, &grp, &var, NULL)))
return retval;
assert(grp && h5);