Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no subsets option to h5diff like h5dump #2698

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ Bug Fixes since HDF5-1.14.0 release

Tools
-----
-
- Names of objects with square brackets will have trouble without the
special argument, --no-compact-subset, on the h5dump command line.

h5diff did not have this option and now it has been added.

(ADB - 2023/04/08 GH-2598)


Performance
Expand Down
45 changes: 23 additions & 22 deletions tools/lib/h5diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,29 @@ typedef struct {
int mode_quiet; /* quiet mode: no output at all */
int mode_report; /* report mode: print the data */
int mode_verbose; /* verbose mode: print the data, list of objcets, warnings */
int mode_verbose_level; /* control verbose details */
int mode_list_not_cmp; /* list not comparable messages */
int print_header; /* print header */
int print_percentage; /* print percentage */
int print_dims; /* print dimension index */
int delta_bool; /* delta, absolute value to compare */
double delta; /* delta value */
int use_system_epsilon; /* flag to use system epsilon (1 or 0) */
int percent_bool; /* relative error to compare*/
double percent; /* relative error value */
hbool_t follow_links; /* follow symbolic links */
int no_dangle_links; /* return error when find dangling link */
int cmn_objs; /* do we have common objects */
int not_cmp; /* are the objects comparable */
int contents; /* equal contents */
int do_nans; /* consider Nans while diffing floats */
int exclude_path; /* exclude path to an object */
int exclude_attr_path; /* exclude path to an object */
struct exclude_path_list *exclude; /* keep exclude path list */
struct exclude_path_list *exclude_attr; /* keep exclude attribute list */
int count_bool; /* count, compare up to count */
hsize_t count; /* count value */
int mode_verbose_level; /* control verbose details */
int mode_list_not_cmp; /* list not comparable messages */
int print_header; /* print header */
int print_percentage; /* print percentage */
int print_dims; /* print dimension index */
int delta_bool; /* delta, absolute value to compare */
double delta; /* delta value */
int use_system_epsilon; /* flag to use system epsilon (1 or 0) */
int percent_bool; /* relative error to compare*/
double percent; /* relative error value */
hbool_t follow_links; /* follow symbolic links */
int no_dangle_links; /* return error when find dangling link */
int cmn_objs; /* do we have common objects */
int not_cmp; /* are the objects comparable */
int contents; /* equal contents */
int do_nans; /* consider Nans while diffing floats */
int disable_compact_subset; /* disable compact form of subset notation */
int exclude_path; /* exclude path to an object */
int exclude_attr_path; /* exclude path to an object */
struct exclude_path_list *exclude; /* keep exclude path list */
struct exclude_path_list *exclude_attr; /* keep exclude attribute list */
int count_bool; /* count, compare up to count */
hsize_t count; /* count value */
diff_err_t err_stat; /* an error occurred (2, error, 1, differences, 0, no error) */
hsize_t nelmts; /* total number of elements */
hsize_t hs_nelmts; /* number of elements to read at a time*/
Expand Down
122 changes: 122 additions & 0 deletions tools/lib/h5tools_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,128 @@ help_ref_msg(FILE *output)
HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n", h5tools_getprogname());
}

/*-------------------------------------------------------------------------
* Function: parse_hsize_list
*
* Purpose: Parse a list of comma or space separated integers and return
* them in a list. The string being passed into this function
* should be at the start of the list you want to parse. You are
* responsible for freeing the array returned from here.
*
* Lists in the so-called "terse" syntax are separated by
* semicolons (;). The lists themselves can be separated by
* either commas (,) or white spaces.
*
* Return: <none>
*-------------------------------------------------------------------------
*/
void
parse_hsize_list(const char *h_list, subset_d *d)
{
hsize_t *p_list;
const char *ptr;
unsigned int size_count = 0;
unsigned int i = 0;
unsigned int last_digit = 0;

if (!h_list || !*h_list || *h_list == ';')
return;

H5TOOLS_START_DEBUG(" - h_list:%s", h_list);
/* count how many integers do we have */
for (ptr = h_list; ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
if (HDisdigit(*ptr)) {
if (!last_digit)
/* the last read character wasn't a digit */
size_count++;

last_digit = 1;
}
else
last_digit = 0;

if (size_count == 0) {
/* there aren't any integers to read */
H5TOOLS_ENDDEBUG("No integers to read");
return;
}
H5TOOLS_DEBUG("Number integers to read=%ld", size_count);

/* allocate an array for the integers in the list */
if ((p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t))) == NULL)
H5TOOLS_INFO("Unable to allocate space for subset data");

for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
if (HDisdigit(*ptr)) {
/* we should have an integer now */
p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0);

while (HDisdigit(*ptr))
/* scroll to end of integer */
ptr++;
}
d->data = p_list;
d->len = size_count;
H5TOOLS_ENDDEBUG(" ");
}

/*-------------------------------------------------------------------------
* Function: parse_subset_params
*
* Purpose: Parse the so-called "terse" syntax for specifying subsetting parameters.
*
* Return: Success: struct subset_t object
* Failure: NULL
*-------------------------------------------------------------------------
*/
struct subset_t *
parse_subset_params(const char *dset)
{
struct subset_t *s = NULL;
char *brace;
const char *q_dset;

H5TOOLS_START_DEBUG(" - dset:%s", dset);
/* if dset name is quoted wait till after second quote to look for subset brackets */
if (*dset == '"')
q_dset = HDstrchr(dset, '"');
else
q_dset = dset;
if ((brace = HDstrrchr(q_dset, '[')) != NULL) {
*brace++ = '\0';

s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
parse_hsize_list(brace, &s->start);

while (*brace && *brace != ';')
brace++;

if (*brace)
brace++;

parse_hsize_list(brace, &s->stride);

while (*brace && *brace != ';')
brace++;

if (*brace)
brace++;

parse_hsize_list(brace, &s->count);

while (*brace && *brace != ';')
brace++;

if (*brace)
brace++;

parse_hsize_list(brace, &s->block);
}
H5TOOLS_ENDDEBUG(" ");

return s;
}

/*****************************************************************************
*
* Function: parse_tuple()
Expand Down
3 changes: 3 additions & 0 deletions tools/lib/h5tools_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ typedef struct find_objs_t {
H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */

/* Definitions of useful routines */
H5TOOLS_DLL struct subset_t *parse_subset_params(const char *dset);

H5TOOLS_DLL void indentation(unsigned);
H5TOOLS_DLL void print_version(const char *progname);
H5TOOLS_DLL void parallel_print(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2);
H5TOOLS_DLL void parse_hsize_list(const char *h_list, subset_d *d);
H5TOOLS_DLL herr_t parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems,
char ***ptrs_out);
H5TOOLS_DLL void error_msg(const char *fmt, ...) H5_ATTR_FORMAT(printf, 1, 2);
Expand Down
Loading