summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2023-04-19 12:44:56 (GMT)
committerGitHub <noreply@github.com>2023-04-19 12:44:56 (GMT)
commit39099bd397ac8d27965b70e7bfc644abc27fd5df (patch)
tree2f1cbf4a64950b762ec157c329c1dab93dd55725 /tools/lib
parent7d24d61ea26c522f673c3e97ae68aa1f3f530f01 (diff)
downloadhdf5-39099bd397ac8d27965b70e7bfc644abc27fd5df.zip
hdf5-39099bd397ac8d27965b70e7bfc644abc27fd5df.tar.gz
hdf5-39099bd397ac8d27965b70e7bfc644abc27fd5df.tar.bz2
Add no subsets option to h5diff like h5dump (#2760)
* reorder argument in alpha order
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c4
-rw-r--r--tools/lib/h5diff.h45
-rw-r--r--tools/lib/h5tools_utils.c122
-rw-r--r--tools/lib/h5tools_utils.h3
4 files changed, 150 insertions, 24 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index a0cd8db..9b49be9 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -181,7 +181,7 @@ is_exclude_path(char *path, h5trav_type_t type, diff_opt_t *opts)
/* search objects in exclude list */
while (NULL != exclude_path_ptr) {
- /* if exclude path is is group, exclude its members as well */
+ /* if exclude path is in group, exclude its members as well */
if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP) {
ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path, HDstrlen(exclude_path_ptr->obj_path));
if (ret_cmp == 0) { /* found matching members */
@@ -245,7 +245,7 @@ is_exclude_attr(const char *path, h5trav_type_t type, diff_opt_t *opts)
/* search objects in exclude list */
while (NULL != exclude_ptr) {
- /* if exclude path is is group, exclude its members as well */
+ /* if exclude path is in group, exclude its members as well */
if (exclude_ptr->obj_type == H5TRAV_TYPE_GROUP) {
ret_cmp = HDstrncmp(exclude_ptr->obj_path, path, HDstrlen(exclude_ptr->obj_path));
if (ret_cmp == 0) { /* found matching members */
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index d67d224..0aec94f 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -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*/
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 1f4345c..17609c7 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -162,6 +162,128 @@ help_ref_msg(FILE *output)
}
/*-------------------------------------------------------------------------
+ * 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: get_option
*
* Purpose: Determine the command-line options a user specified. We can
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index b714b7d..bf8ce75 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -114,9 +114,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, ...);
+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, ...);