From d0587c9536708b75450f05712560cc182f2274fa Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 30 Nov 2018 09:14:53 -0700 Subject: [PATCH] more name normalization --- libhdf5/hdf5internal.c | 11 ++++++++++- libhdf5/hdf5var.c | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libhdf5/hdf5internal.c b/libhdf5/hdf5internal.c index 0d8a9d193..cb202fb75 100644 --- a/libhdf5/hdf5internal.c +++ b/libhdf5/hdf5internal.c @@ -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; diff --git a/libhdf5/hdf5var.c b/libhdf5/hdf5var.c index 70c77db9b..57333739a 100644 --- a/libhdf5/hdf5var.c +++ b/libhdf5/hdf5var.c @@ -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);