diff options
Diffstat (limited to 'tools/h5repack/h5repack_parse.c')
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index a9a890d..05af197 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -42,7 +42,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, size_t i, m, u; char c; size_t len = HDstrlen(str); - int k, l, p, q, end_obj = -1, no_param = 0; + int f, k, l, p, q, end_obj = -1, no_param = 0; unsigned j, n; char sobj[MAX_NC_NAME]; char scomp[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -58,26 +58,30 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, /* check for the end of object list and number of objects */ for (i = 0, n = 0; i < len; i++) { c = str[i]; - if (c == ':') + if (c == ':') { end_obj = (int) i; + break; + } if (c == ',') n++; } + n++; /* Check for missing : */ if (end_obj == -1) { /* apply to all objects */ options->all_filter = 1; *is_glb = 1; + *n_objs = 1; } + else + *n_objs = n; - n++; obj_list = (obj_list_t *) HDmalloc(n * sizeof(obj_list_t)); if (obj_list == NULL) { error_msg("could not allocate object list\n"); return NULL; } - *n_objs = n; /* get object list */ if (end_obj > 0) @@ -89,6 +93,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, sobj[k] = '\0'; else sobj[k + 1] = '\0'; + HDstrcpy(obj_list[n].obj, sobj); HDmemset(sobj, 0, sizeof(sobj)); n++; @@ -142,7 +147,6 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, if (l == 2) { smask[l] = '\0'; i = len - 1; /* end */ - (*n_objs)--; /* we counted an extra ',' */ if (HDstrcmp(smask,"NN") == 0) filt->cd_values[j++] = H5_SZIP_NN_OPTION_MASK; else if (HDstrcmp(smask,"EC") == 0) @@ -193,7 +197,6 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, if (l == 2) { smask[l] = '\0'; i = len - 1; /* end */ - (*n_objs)--; /* we counted an extra ',' */ if (HDstrcmp(smask,"IN") == 0) filt->cd_values[j++] = H5Z_SO_INT; else if (HDstrcmp(smask, "DS") == H5Z_SO_FLOAT_DSCALE) @@ -209,13 +212,14 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, /*------------------------------------------------------------------------- * User Defined - * has the format UD=<filter_number,cd_value_count,value_1[,value_2,...,value_N]> + * has the format UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]> * BZIP2 example - * UD=307,1,9 + * UD=307,0,1,9 *------------------------------------------------------------------------- */ else if (HDstrcmp(scomp, "UD") == 0) { l = -1; /* filter number index check */ + f = -1; /* filter flag index check */ p = -1; /* CD_VAL count check */ for (m = 0, q = 0, u = i + 1; u < len; u++, m++, q++) { if (str[u] == ',') { @@ -224,6 +228,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, filt->filtn = HDatoi(stype); l = 0; } + else if (f == -1) { + filt->filt_flag = HDstrtoul(stype, NULL, 0); + f = 0; + } else if (p == -1) { filt->cd_nelmts = HDstrtoull(stype, NULL, 0); p = 0; @@ -240,6 +248,12 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, error_msg("filter number parameter is not a digit in <%s>\n", str); HDexit(EXIT_FAILURE); } + else if (!HDisdigit(c) && f == -1) { + if (obj_list) + HDfree(obj_list); + error_msg("filter flag parameter is not a digit in <%s>\n", str); + HDexit(EXIT_FAILURE); + } stype[q] = c; } /* for u */ stype[q] = '\0'; |