summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/CMakeLists.txt2
-rw-r--r--tools/lib/h5diff.c136
-rw-r--r--tools/lib/h5diff_array.c274
-rw-r--r--tools/lib/h5diff_dset.c2
-rw-r--r--tools/lib/h5diff_util.c2
-rw-r--r--tools/lib/h5tools.c31
-rw-r--r--tools/lib/h5tools.h4
-rw-r--r--tools/lib/h5tools_dump.c88
-rw-r--r--tools/lib/h5tools_dump.h4
-rw-r--r--tools/lib/h5tools_error.h7
-rw-r--r--tools/lib/h5tools_str.c60
-rw-r--r--tools/lib/h5tools_str.h2
-rw-r--r--tools/lib/h5tools_utils.c45
-rw-r--r--tools/lib/h5trav.c6
14 files changed, 377 insertions, 286 deletions
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index a75596d..837a14e 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -4,8 +4,6 @@ PROJECT (HDF5_TOOLS_LIB)
#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
-#INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib)
-#INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test)
SET (H5_TOOLS_LIB_SRCS
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff.c
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 4ffee2b..cef30dd 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -25,11 +25,11 @@
* Debug printf macros. The prefix allows output filtering by test scripts.
*/
#ifdef H5DIFF_DEBUG
-#define h5diffdebug(x) fprintf(stderr, "h5diff debug: " x)
-#define h5diffdebug2(x1, x2) fprintf(stderr, "h5diff debug: " x1, x2)
-#define h5diffdebug3(x1, x2, x3) fprintf(stderr, "h5diff debug: " x1, x2, x3)
-#define h5diffdebug4(x1, x2, x3, x4) fprintf(stderr, "h5diff debug: " x1, x2, x3, x4)
-#define h5diffdebug5(x1, x2, x3, x4, x5) fprintf(stderr, "h5diff debug: " x1, x2, x3, x4, x5)
+#define h5diffdebug(x) HDfprintf(stderr, "h5diff debug: " x)
+#define h5diffdebug2(x1, x2) HDfprintf(stderr, "h5diff debug: " x1, x2)
+#define h5diffdebug3(x1, x2, x3) HDfprintf(stderr, "h5diff debug: " x1, x2, x3)
+#define h5diffdebug4(x1, x2, x3, x4) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4)
+#define h5diffdebug5(x1, x2, x3, x4, x5) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4, x5)
#else
#define h5diffdebug(x)
#define h5diffdebug2(x1, x2)
@@ -153,13 +153,13 @@ void print_manager_output(void)
overflow_file = NULL;
}
- fflush(stdout);
+ HDfflush(stdout);
HDmemset(outBuff, 0, OUTBUFF_SIZE);
outBuffOffset = 0;
}
else if( (outBuffOffset>0) && !g_Parallel)
{
- fprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n");
+ HDfprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n");
}
}
@@ -270,12 +270,12 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
/* search objects in exclude list */
while (NULL != exclude_path_ptr)
{
- /* if given object is group, exclude its members as well */
+ /* if exclude path is is group, exclude its members as well */
if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP)
{
ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path,
- strlen(exclude_path_ptr->obj_path));
- if (ret_cmp == 0)
+ HDstrlen(exclude_path_ptr->obj_path));
+ if (ret_cmp == 0) /* found matching members */
{
/* check if given path belong to an excluding group, if so
* exclude it as well.
@@ -295,12 +295,13 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
else
{
ret_cmp = HDstrcmp(exclude_path_ptr->obj_path, path);
- if (ret_cmp == 0)
+ if (ret_cmp == 0) /* found matching object */
{
/* excluded non-group object */
ret = 1;
- /* assign type as scan progress, which is sufficient to
- * determine type for excluding groups from the above if. */
+ /* remember the type of this maching object.
+ * if it's group, it can be used for excluding its member
+ * objects in this while() loop */
exclude_path_ptr->obj_type = type;
break; /* while */
}
@@ -443,9 +444,11 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
infile[1] = 0;
while(curr1 < info1->nused)
{
+ path1_lp = (info1->paths[curr1].path) + path1_offset;
+ type1_l = info1->paths[curr1].type;
+
if(!is_exclude_path(path1_lp, type1_l, options))
{
- path1_lp = (info1->paths[curr1].path) + path1_offset;
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
}
curr1++;
@@ -456,9 +459,11 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
infile[1] = 1;
while(curr2 < info2->nused)
{
+ path2_lp = (info2->paths[curr2].path) + path2_offset;
+ type2_l = info2->paths[curr2].type;
+
if (!is_exclude_path(path2_lp, type2_l, options))
{
- path2_lp = (info2->paths[curr2].path) + path2_offset;
trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table);
}
curr2++;
@@ -614,7 +619,7 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
done:
if (lnk_info.trg_path)
- HDfree(lnk_info.trg_path);
+ HDfree((char *)lnk_info.trg_path);
return 0;
}
@@ -644,8 +649,8 @@ hsize_t h5diff(const char *fname1,
char filenames[2][MAX_FILENAME];
hsize_t nfound = 0;
int i;
- //int i1, i2;
- int l_ret;
+ int l_ret1 = -1;
+ int l_ret2 = -1;
const char * obj1fullname = NULL;
const char * obj2fullname = NULL;
/* init to group type */
@@ -728,25 +733,25 @@ hsize_t h5diff(const char *fname1,
/* make the given object1 fullpath, start with "/" */
if (HDstrncmp(objname1, "/", 1))
{
- HDstrcpy(obj1fullname, "/");
- HDstrcat(obj1fullname, objname1);
+ HDstrcpy((char *)obj1fullname, "/");
+ HDstrcat((char *)obj1fullname, objname1);
}
else
- HDstrcpy(obj1fullname, objname1);
+ HDstrcpy((char *)obj1fullname, objname1);
/* make the given object2 fullpath, start with "/" */
if (HDstrncmp(objname2, "/", 1))
{
- HDstrcpy(obj2fullname, "/");
- HDstrcat(obj2fullname, objname2);
+ HDstrcpy((char *)obj2fullname, "/");
+ HDstrcat((char *)obj2fullname, objname2);
}
else
- HDstrcpy(obj2fullname, objname2);
+ HDstrcpy((char *)obj2fullname, objname2);
/*----------------------------------------------------------
* check if obj1 is root, group, single object or symlink
*/
- if(!HDstrcmp(obj1fullname, "/"))
+ if(!HDstrcmp((char *)obj1fullname, "/"))
{
obj1type = H5TRAV_TYPE_GROUP;
}
@@ -856,12 +861,16 @@ hsize_t h5diff(const char *fname1,
{
/* set root group */
obj1fullname = (char*)HDcalloc(2, sizeof(char));
- HDstrcat(obj1fullname, "/");
+ HDstrcat((char *)obj1fullname, "/");
obj2fullname = (char*)HDcalloc(2, sizeof(char));
- HDstrcat(obj2fullname, "/");
+ HDstrcat((char *)obj2fullname, "/");
}
+ /* get any symbolic links info */
+ l_ret1 = H5tools_get_symlink_info(file1_id, obj1fullname, &trg_linfo1, TRUE);
+ l_ret2 = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, TRUE);
+
/*---------------------------------------------
* check for following symlinks
*/
@@ -874,13 +883,12 @@ hsize_t h5diff(const char *fname1,
/*-------------------------------
* check symbolic link (object1)
*/
- l_ret = H5tools_get_symlink_info(file1_id, obj1fullname, &trg_linfo1, TRUE);
/* dangling link */
- if (l_ret == 0)
+ if (l_ret1 == 0)
{
if (options->no_dangle_links)
{
- /* gangling link is error */
+ /* treat dangling link is error */
if(options->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname);
options->err_stat = 1;
@@ -890,30 +898,33 @@ hsize_t h5diff(const char *fname1,
{
if(options->m_verbose)
parallel_print("obj1 <%s> is a dangling link.\n", obj1fullname);
- nfound++;
- print_found(nfound);
- goto out;
+ if (l_ret1 != 0 || l_ret2 != 0)
+ {
+ nfound++;
+ print_found(nfound);
+ goto out;
+ }
}
}
- else if(l_ret < 0) /* fail */
+ else if(l_ret1 < 0) /* fail */
{
parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
options->err_stat = 1;
goto out;
}
- else if(l_ret != 2) /* symbolic link */
+ else if(l_ret1 != 2) /* symbolic link */
obj1type = trg_linfo1.trg_type;
/*-------------------------------
* check symbolic link (object2)
*/
- l_ret = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, TRUE);
+
/* dangling link */
- if (l_ret == 0)
+ if (l_ret2 == 0)
{
if (options->no_dangle_links)
{
- /* gangling link is error */
+ /* treat dangling link is error */
if(options->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname);
options->err_stat = 1;
@@ -923,18 +934,21 @@ hsize_t h5diff(const char *fname1,
{
if(options->m_verbose)
parallel_print("obj2 <%s> is a dangling link.\n", obj2fullname);
- nfound++;
- print_found(nfound);
- goto out;
+ if (l_ret1 != 0 || l_ret2 != 0)
+ {
+ nfound++;
+ print_found(nfound);
+ goto out;
+ }
}
}
- else if(l_ret < 0) /* fail */
+ else if(l_ret2 < 0) /* fail */
{
parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
options->err_stat = 1;
goto out;
}
- else if(l_ret != 2) /* symbolic link */
+ else if(l_ret2 != 2) /* symbolic link */
obj2type = trg_linfo2.trg_type;
} /* end of if follow symlinks */
@@ -947,8 +961,10 @@ hsize_t h5diff(const char *fname1,
if(!(options->m_verbose || options->m_report))
{
- if (h5tools_is_obj_same(file1_id,obj1fullname,file2_id,obj2fullname)!=0)
- goto out;
+ /* if no danglink links */
+ if ( l_ret1 > 0 && l_ret2 > 0 )
+ if (h5tools_is_obj_same(file1_id,obj1fullname,file2_id,obj2fullname)!=0)
+ goto out;
}
@@ -995,7 +1011,7 @@ hsize_t h5diff(const char *fname1,
if((HDstrlen(fname1) > MAX_FILENAME) ||
(HDstrlen(fname2) > MAX_FILENAME))
{
- fprintf(stderr, "The parallel diff only supports path names up to %d characters\n", MAX_FILENAME);
+ HDfprintf(stderr, "The parallel diff only supports path names up to %d characters\n", MAX_FILENAME);
MPI_Abort(MPI_COMM_WORLD, 0);
} /* end if */
@@ -1045,15 +1061,15 @@ out:
/* free buffers */
if (obj1fullname)
- HDfree(obj1fullname);
+ HDfree((char *)obj1fullname);
if (obj2fullname)
- HDfree(obj2fullname);
+ HDfree((char *)obj2fullname);
/* free link info buffer */
if (trg_linfo1.trg_path)
- HDfree(trg_linfo1.trg_path);
+ HDfree((char *)trg_linfo1.trg_path);
if (trg_linfo2.trg_path)
- HDfree(trg_linfo2.trg_path);
+ HDfree((char *)trg_linfo2.trg_path);
/* close */
H5E_BEGIN_TRY
@@ -1112,9 +1128,9 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
* make full path
*/
if (HDstrcmp (grp1, "/"))
- grp1_path = grp1;
+ grp1_path = (char *)grp1;
if (HDstrcmp (grp2, "/"))
- grp2_path = grp2;
+ grp2_path = (char *)grp2;
/*-------------------------------------------------------------------------
* regarding the return value of h5diff (0, no difference in files, 1 difference )
@@ -1180,12 +1196,12 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
{
objtype = table->objs[i].type;
/* make full path for obj1 */
- obj1_fullpath = (char*)HDcalloc (strlen(grp1_path) + strlen (table->objs[i].name) + 1, sizeof (char));
+ obj1_fullpath = (char*)HDcalloc (HDstrlen(grp1_path) + strlen (table->objs[i].name) + 1, sizeof (char));
HDstrcpy(obj1_fullpath, grp1_path);
HDstrcat(obj1_fullpath, table->objs[i].name);
/* make full path for obj2 */
- obj2_fullpath = (char*)HDcalloc (strlen(grp2_path) + strlen (table->objs[i].name) + 1, sizeof (char));
+ obj2_fullpath = (char*)HDcalloc (HDstrlen(grp2_path) + strlen (table->objs[i].name) + 1, sizeof (char));
HDstrcpy(obj2_fullpath, grp2_path);
HDstrcat(obj2_fullpath, table->objs[i].name);
@@ -1769,9 +1785,9 @@ out:
/* free link info buffer */
if (linkinfo1.trg_path)
- HDfree(linkinfo1.trg_path);
+ HDfree((char *)linkinfo1.trg_path);
if (linkinfo2.trg_path)
- HDfree(linkinfo2.trg_path);
+ HDfree((char *)linkinfo2.trg_path);
return nfound;
}
@@ -2163,9 +2179,9 @@ hsize_t diff(hid_t file1_id,
/* free link info buffer */
if (linkinfo1.trg_path)
- HDfree(linkinfo1.trg_path);
+ HDfree((char *)linkinfo1.trg_path);
if (linkinfo2.trg_path)
- HDfree(linkinfo2.trg_path);
+ HDfree((char *)linkinfo2.trg_path);
return nfound;
@@ -2206,9 +2222,9 @@ out2:
/* free link info buffer */
if (linkinfo1.trg_path)
- HDfree(linkinfo1.trg_path);
+ HDfree((char *)linkinfo1.trg_path);
if (linkinfo2.trg_path)
- HDfree(linkinfo2.trg_path);
+ HDfree((char *)linkinfo2.trg_path);
/* close */
/* disable error reporting */
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 6437809..604a825 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -898,8 +898,8 @@ hsize_t diff_datum(void *_mem1,
char temp1_char;
char temp2_char;
HDassert(type_size==sizeof(char));
- memcpy(&temp1_char, mem1, sizeof(char));
- memcpy(&temp2_char, mem2, sizeof(char));
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -995,8 +995,8 @@ hsize_t diff_datum(void *_mem1,
unsigned char temp2_uchar;
HDassert(type_size==sizeof(unsigned char));
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1094,8 +1094,8 @@ hsize_t diff_datum(void *_mem1,
short temp2_short;
HDassert(type_size==sizeof(short));
- memcpy(&temp1_short, mem1, sizeof(short));
- memcpy(&temp2_short, mem2, sizeof(short));
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1193,8 +1193,8 @@ hsize_t diff_datum(void *_mem1,
unsigned short temp2_ushort;
HDassert(type_size==sizeof(short));
- memcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- memcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1293,8 +1293,8 @@ hsize_t diff_datum(void *_mem1,
int temp2_int;
HDassert(type_size==sizeof(int));
- memcpy(&temp1_int, mem1, sizeof(int));
- memcpy(&temp2_int, mem2, sizeof(int));
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1391,8 +1391,8 @@ hsize_t diff_datum(void *_mem1,
unsigned int temp2_uint;
HDassert(type_size==sizeof(int));
- memcpy(&temp1_uint, mem1, sizeof(unsigned int));
- memcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1489,8 +1489,8 @@ hsize_t diff_datum(void *_mem1,
long temp2_long;
HDassert(type_size==sizeof(long));
- memcpy(&temp1_long, mem1, sizeof(long));
- memcpy(&temp2_long, mem2, sizeof(long));
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1589,8 +1589,8 @@ hsize_t diff_datum(void *_mem1,
unsigned long temp2_ulong;
HDassert(type_size==sizeof(unsigned long));
- memcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- memcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1688,8 +1688,8 @@ hsize_t diff_datum(void *_mem1,
long long temp2_llong;
HDassert(type_size==sizeof(long long));
- memcpy(&temp1_llong, mem1, sizeof(long long));
- memcpy(&temp2_llong, mem2, sizeof(long long));
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1786,8 +1786,8 @@ hsize_t diff_datum(void *_mem1,
unsigned long long temp2_ullong;
HDassert(type_size==sizeof(unsigned long long));
- memcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- memcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
/* -d and !-p */
if (options->d && !options->p)
{
@@ -1906,8 +1906,8 @@ hsize_t diff_datum(void *_mem1,
HDassert(type_size==sizeof(float));
- memcpy(&temp1_float, mem1, sizeof(float));
- memcpy(&temp2_float, mem2, sizeof(float));
+ HDmemcpy(&temp1_float, mem1, sizeof(float));
+ HDmemcpy(&temp2_float, mem2, sizeof(float));
/* logic for detecting NaNs is different with options -d, -p and no options */
@@ -2119,8 +2119,8 @@ hsize_t diff_datum(void *_mem1,
HDassert(type_size==sizeof(double));
- memcpy(&temp1_double, mem1, sizeof(double));
- memcpy(&temp2_double, mem2, sizeof(double));
+ HDmemcpy(&temp1_double, mem1, sizeof(double));
+ HDmemcpy(&temp2_double, mem2, sizeof(double));
/* logic for detecting NaNs is different with options -d, -p and no options */
@@ -2334,8 +2334,8 @@ hsize_t diff_datum(void *_mem1,
HDassert(type_size==sizeof(long double));
- memcpy(&temp1_double, mem1, sizeof(long double));
- memcpy(&temp2_double, mem2, sizeof(long double));
+ HDmemcpy(&temp1_double, mem1, sizeof(long double));
+ HDmemcpy(&temp2_double, mem2, sizeof(long double));
/* logic for detecting NaNs is different with options -d, -p and no options */
@@ -2820,8 +2820,8 @@ hsize_t character_compare(unsigned char *mem1,
unsigned char temp1_uchar;
unsigned char temp2_uchar;
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
if (temp1_uchar != temp2_uchar)
{
@@ -2869,8 +2869,8 @@ hsize_t character_compare_opt(unsigned char *mem1,
double per;
int both_zero;
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
/* -d and !-p */
@@ -2975,8 +2975,8 @@ hsize_t diff_float(unsigned char *mem1,
{
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_float, mem1, sizeof(float));
- memcpy(&temp2_float, mem2, sizeof(float));
+ HDmemcpy(&temp1_float, mem1, sizeof(float));
+ HDmemcpy(&temp2_float, mem2, sizeof(float));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3029,8 +3029,8 @@ hsize_t diff_float(unsigned char *mem1,
{
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_float, mem1, sizeof(float));
- memcpy(&temp2_float, mem2, sizeof(float));
+ HDmemcpy(&temp1_float, mem1, sizeof(float));
+ HDmemcpy(&temp2_float, mem2, sizeof(float));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3102,8 +3102,8 @@ hsize_t diff_float(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_float, mem1, sizeof(float));
- memcpy(&temp2_float, mem2, sizeof(float));
+ HDmemcpy(&temp1_float, mem1, sizeof(float));
+ HDmemcpy(&temp2_float, mem2, sizeof(float));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3176,8 +3176,8 @@ hsize_t diff_float(unsigned char *mem1,
{
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_float, mem1, sizeof(float));
- memcpy(&temp2_float, mem2, sizeof(float));
+ HDmemcpy(&temp1_float, mem1, sizeof(float));
+ HDmemcpy(&temp2_float, mem2, sizeof(float));
if (equal_float(temp1_float,temp2_float,options)==FALSE)
{
@@ -3248,8 +3248,8 @@ hsize_t diff_double(unsigned char *mem1,
{
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(double));
- memcpy(&temp2_double, mem2, sizeof(double));
+ HDmemcpy(&temp1_double, mem1, sizeof(double));
+ HDmemcpy(&temp2_double, mem2, sizeof(double));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3302,8 +3302,8 @@ hsize_t diff_double(unsigned char *mem1,
{
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(double));
- memcpy(&temp2_double, mem2, sizeof(double));
+ HDmemcpy(&temp1_double, mem1, sizeof(double));
+ HDmemcpy(&temp2_double, mem2, sizeof(double));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3375,8 +3375,8 @@ hsize_t diff_double(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(double));
- memcpy(&temp2_double, mem2, sizeof(double));
+ HDmemcpy(&temp1_double, mem1, sizeof(double));
+ HDmemcpy(&temp2_double, mem2, sizeof(double));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3452,8 +3452,8 @@ hsize_t diff_double(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(double));
- memcpy(&temp2_double, mem2, sizeof(double));
+ HDmemcpy(&temp1_double, mem1, sizeof(double));
+ HDmemcpy(&temp2_double, mem2, sizeof(double));
if (equal_double(temp1_double,temp2_double,options)==FALSE)
@@ -3531,8 +3531,8 @@ hsize_t diff_ldouble(unsigned char *mem1,
{
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(long double));
- memcpy(&temp2_double, mem2, sizeof(long double));
+ HDmemcpy(&temp1_double, mem1, sizeof(long double));
+ HDmemcpy(&temp2_double, mem2, sizeof(long double));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3585,8 +3585,8 @@ hsize_t diff_ldouble(unsigned char *mem1,
{
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(long double));
- memcpy(&temp2_double, mem2, sizeof(long double));
+ HDmemcpy(&temp1_double, mem1, sizeof(long double));
+ HDmemcpy(&temp2_double, mem2, sizeof(long double));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3658,8 +3658,8 @@ hsize_t diff_ldouble(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(long double));
- memcpy(&temp2_double, mem2, sizeof(long double));
+ HDmemcpy(&temp1_double, mem1, sizeof(long double));
+ HDmemcpy(&temp2_double, mem2, sizeof(long double));
/*-------------------------------------------------------------------------
* detect NaNs
@@ -3735,8 +3735,8 @@ hsize_t diff_ldouble(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_double, mem1, sizeof(long double));
- memcpy(&temp2_double, mem2, sizeof(long double));
+ HDmemcpy(&temp1_double, mem1, sizeof(long double));
+ HDmemcpy(&temp2_double, mem2, sizeof(long double));
if (equal_ldouble(temp1_double,temp2_double,options)==FALSE)
@@ -3809,8 +3809,8 @@ hsize_t diff_schar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_char, mem1, sizeof(char));
- memcpy(&temp2_char, mem2, sizeof(char));
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
if (ABS(temp1_char-temp2_char) > options->delta)
{
@@ -3835,8 +3835,8 @@ hsize_t diff_schar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_char, mem1, sizeof(char));
- memcpy(&temp2_char, mem2, sizeof(char));
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
PER(temp1_char,temp2_char);
@@ -3879,8 +3879,8 @@ hsize_t diff_schar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_char, mem1, sizeof(char));
- memcpy(&temp2_char, mem2, sizeof(char));
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
PER(temp1_char,temp2_char);
@@ -3922,8 +3922,8 @@ hsize_t diff_schar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_char, mem1, sizeof(char));
- memcpy(&temp2_char, mem2, sizeof(char));
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
if (temp1_char != temp2_char)
{
@@ -3986,8 +3986,8 @@ hsize_t diff_uchar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
{
@@ -4013,8 +4013,8 @@ hsize_t diff_uchar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
@@ -4057,8 +4057,8 @@ hsize_t diff_uchar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
@@ -4100,8 +4100,8 @@ hsize_t diff_uchar(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- memcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
if (temp1_uchar != temp2_uchar)
{
@@ -4161,8 +4161,8 @@ hsize_t diff_short(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_short, mem1, sizeof(short));
- memcpy(&temp2_short, mem2, sizeof(short));
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
if (ABS(temp1_short-temp2_short) > options->delta)
{
@@ -4188,8 +4188,8 @@ hsize_t diff_short(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_short, mem1, sizeof(short));
- memcpy(&temp2_short, mem2, sizeof(short));
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
PER(temp1_short,temp2_short);
@@ -4234,8 +4234,8 @@ hsize_t diff_short(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_short, mem1, sizeof(short));
- memcpy(&temp2_short, mem2, sizeof(short));
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
PER(temp1_short,temp2_short);
@@ -4277,8 +4277,8 @@ hsize_t diff_short(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_short, mem1, sizeof(short));
- memcpy(&temp2_short, mem2, sizeof(short));
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
if (temp1_short != temp2_short)
{
@@ -4339,8 +4339,8 @@ hsize_t diff_ushort(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- memcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
{
@@ -4366,8 +4366,8 @@ hsize_t diff_ushort(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- memcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
@@ -4412,8 +4412,8 @@ hsize_t diff_ushort(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- memcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
@@ -4455,8 +4455,8 @@ hsize_t diff_ushort(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- memcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
if (temp1_ushort != temp2_ushort)
{
@@ -4518,8 +4518,8 @@ hsize_t diff_int(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_int, mem1, sizeof(int));
- memcpy(&temp2_int, mem2, sizeof(int));
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
if (ABS(temp1_int-temp2_int) > options->delta)
{
@@ -4545,8 +4545,8 @@ hsize_t diff_int(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_int, mem1, sizeof(int));
- memcpy(&temp2_int, mem2, sizeof(int));
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
PER(temp1_int,temp2_int);
@@ -4591,8 +4591,8 @@ hsize_t diff_int(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_int, mem1, sizeof(int));
- memcpy(&temp2_int, mem2, sizeof(int));
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
PER(temp1_int,temp2_int);
@@ -4634,8 +4634,8 @@ hsize_t diff_int(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_int, mem1, sizeof(int));
- memcpy(&temp2_int, mem2, sizeof(int));
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
if (temp1_int != temp2_int)
{
@@ -4697,8 +4697,8 @@ hsize_t diff_uint(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uint, mem1, sizeof(unsigned int));
- memcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
{
@@ -4724,8 +4724,8 @@ hsize_t diff_uint(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uint, mem1, sizeof(unsigned int));
- memcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
PER_UNSIGN(signed int,temp1_uint,temp2_uint);
@@ -4769,8 +4769,8 @@ hsize_t diff_uint(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uint, mem1, sizeof(unsigned int));
- memcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
PER_UNSIGN(signed int,temp1_uint,temp2_uint);
@@ -4811,8 +4811,8 @@ hsize_t diff_uint(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_uint, mem1, sizeof(unsigned int));
- memcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
if (temp1_uint != temp2_uint)
{
@@ -4877,8 +4877,8 @@ hsize_t diff_long(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_long, mem1, sizeof(long));
- memcpy(&temp2_long, mem2, sizeof(long));
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
if (ABS(temp1_long-temp2_long) > options->delta)
{
@@ -4904,8 +4904,8 @@ hsize_t diff_long(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_long, mem1, sizeof(long));
- memcpy(&temp2_long, mem2, sizeof(long));
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
PER(temp1_long,temp2_long);
@@ -4950,8 +4950,8 @@ hsize_t diff_long(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_long, mem1, sizeof(long));
- memcpy(&temp2_long, mem2, sizeof(long));
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
PER(temp1_long,temp2_long);
@@ -4993,8 +4993,8 @@ hsize_t diff_long(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_long, mem1, sizeof(long));
- memcpy(&temp2_long, mem2, sizeof(long));
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
if (temp1_long != temp2_long)
{
@@ -5061,8 +5061,8 @@ hsize_t diff_ulong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- memcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
{
@@ -5090,8 +5090,8 @@ hsize_t diff_ulong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- memcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
@@ -5135,8 +5135,8 @@ hsize_t diff_ulong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- memcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
@@ -5177,8 +5177,8 @@ hsize_t diff_ulong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- memcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
if (temp1_ulong != temp2_ulong)
{
@@ -5240,8 +5240,8 @@ hsize_t diff_llong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_llong, mem1, sizeof(long long));
- memcpy(&temp2_llong, mem2, sizeof(long long));
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
if (ABS( temp1_llong-temp2_llong) > options->delta)
{
@@ -5267,8 +5267,8 @@ hsize_t diff_llong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_llong, mem1, sizeof(long long));
- memcpy(&temp2_llong, mem2, sizeof(long long));
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
PER(temp1_llong,temp2_llong);
@@ -5310,8 +5310,8 @@ hsize_t diff_llong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_llong, mem1, sizeof(long long));
- memcpy(&temp2_llong, mem2, sizeof(long long));
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
PER(temp1_llong,temp2_llong);
@@ -5350,8 +5350,8 @@ hsize_t diff_llong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_llong, mem1, sizeof(long long));
- memcpy(&temp2_llong, mem2, sizeof(long long));
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
if (temp1_llong != temp2_llong)
{
@@ -5414,8 +5414,8 @@ hsize_t diff_ullong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- memcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) options->delta)
{
@@ -5441,8 +5441,8 @@ hsize_t diff_ullong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- memcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
ull2float(temp1_ullong,&f1);
ull2float(temp2_ullong,&f2);
@@ -5486,8 +5486,8 @@ hsize_t diff_ullong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- memcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
ull2float(temp1_ullong,&f1);
ull2float(temp2_ullong,&f2);
@@ -5528,8 +5528,8 @@ hsize_t diff_ullong(unsigned char *mem1,
for ( i = 0; i < nelmts; i++)
{
- memcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- memcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
if (temp1_ullong != temp2_ullong)
{
@@ -5580,15 +5580,15 @@ int ull2float(unsigned long long ull_value, float *f_value)
src_size = H5Tget_size(H5T_NATIVE_ULLONG);
dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
- buf = (unsigned char*)calloc(1, MAX(src_size, dst_size));
+ buf = (unsigned char*)HDcalloc(1, MAX(src_size, dst_size));
- memcpy(buf, &ull_value, src_size);
+ HDmemcpy(buf, &ull_value, src_size);
/* do conversion */
if(H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, 1, buf, NULL, dxpl_id)<0)
goto error;
- memcpy(f_value, buf, dst_size);
+ HDmemcpy(f_value, buf, dst_size);
if(buf)
HDfree(buf);
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index bfb8429..c1ed429 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -409,7 +409,7 @@ hsize_t diff_datasetid( hid_t did1,
options, name1, name2, m_tid1, did1, did2);
/* reclaim any VL memory, if necessary */
- if(vl_data) {
+ if(vl_data) {
H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
} /* end if */
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index dfdc8b3..0d476b6 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -183,7 +183,7 @@ diff_basename(const char *name)
return NULL;
/* Find the end of the base name */
- i = strlen(name);
+ i = HDstrlen(name);
while (i>0 && '/'==name[i-1])
--i;
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index ef32cde..17639bc 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -35,11 +35,14 @@
#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z))
/* global variables */
+hid_t H5tools_ERR_STACK_g = 0;
hid_t H5tools_ERR_CLS_g = -1;
hid_t H5E_tools_g = -1;
hid_t H5E_tools_min_id_g = -1;
int compound_data;
FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */
+FILE *rawoutstream; /* should initialize to stdout but gcc moans about it */
+FILE *rawerrorstream; /* should initialize to stderr but gcc moans about it */
int bin_output; /* binary output */
int bin_form; /* binary form */
int region_output; /* region output */
@@ -113,10 +116,15 @@ h5tools_init(void)
/* register the error class */
HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d",H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
+ H5tools_ERR_STACK_g = H5Ecreate_stack();
H5TOOLS_INIT_ERROR()
if (!rawdatastream)
rawdatastream = stdout;
+ if (!rawoutstream)
+ rawoutstream = stdout;
+ if (!rawerrorstream)
+ rawerrorstream = stderr;
h5tools_dump_init();
@@ -143,19 +151,36 @@ h5tools_init(void)
void
h5tools_close(void)
{
+ H5E_auto2_t tools_func;
+ void *tools_edata;
if (h5tools_init_g) {
+ H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
+ if(tools_func!=NULL)
+ H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
if (rawdatastream && rawdatastream != stdout) {
if (fclose(rawdatastream))
perror("closing rawdatastream");
else
rawdatastream = NULL;
}
+ if (rawoutstream && rawoutstream != stdout) {
+ if (fclose(rawoutstream))
+ perror("closing rawoutstream");
+ else
+ rawoutstream = NULL;
+ }
+ if (rawerrorstream && rawerrorstream != stderr) {
+ if (fclose(rawerrorstream))
+ perror("closing rawerrorstream");
+ else
+ rawerrorstream = NULL;
+ }
/* Clean up the reference path table, if it's been used */
term_ref_path_table();
H5TOOLS_CLOSE_ERROR()
-
+ H5Eclose_stack(H5tools_ERR_STACK_g);
/* Shut down the library */
H5close();
@@ -1047,7 +1072,7 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
*-------------------------------------------------------------------------
*/
int
-do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem)
+do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem)
{
HERR_INIT(int, SUCCEED)
unsigned char *mem = (unsigned char*)_mem;
@@ -1059,7 +1084,7 @@ do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_m
for (i = 0; i < nelmts; i++) {
if (render_bin_output(stream, container, tid, mem + i * size) < 0) {
- printf("\nError in writing binary stream\n");
+ HDfprintf(err_stream,"\nError in writing binary stream\n");
return FAIL;
}
}
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index a8f43b3..0f4b271 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -525,6 +525,8 @@ H5TOOLS_DLLVAR int packed_data_offset; /* offset of packed bits to display
H5TOOLS_DLLVAR int packed_data_length; /* lengtht of packed bits to display */
H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */
H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */
+H5TOOLS_DLLVAR FILE *rawoutstream; /* output stream for raw output */
+H5TOOLS_DLLVAR FILE *rawerrorstream; /* output stream for raw error */
H5TOOLS_DLLVAR int bin_output; /* binary output */
H5TOOLS_DLLVAR int bin_form; /* binary form */
H5TOOLS_DLLVAR int region_output; /* region output */
@@ -558,7 +560,7 @@ H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *i
H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum);
-H5TOOLS_DLL int do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem);
+H5TOOLS_DLL int do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem);
H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem);
H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 98945aa..9188225 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -189,22 +189,6 @@ const h5tools_dump_header_t* h5tools_dump_header_format;
table_t *h5dump_type_table = NULL; /*type table reference for datatype dump */
/* local prototypes */
-
-hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t local_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
-
-hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t *ptdata,
- hsize_t local_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
-
static int h5tools_print_region_data_blocks(hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
h5tools_str_t *buffer/*string into which to render */, size_t ncols,
@@ -248,8 +232,8 @@ h5tools_dump_init(void)
* indicates whether the data supplied in this call falls at the
* beginning or end of the total data to be printed (START_OF_DATA and
* END_OF_DATA).
- * Return:
- * None
+ * Return: Success: SUCCEED
+ * Failure: FAIL
* Programmer:
* Robb Matzke, Monday, April 26, 1999
* Modifications:
@@ -272,11 +256,12 @@ h5tools_dump_init(void)
* new field sm_pos in h5tools_context_t, the current stripmine element position
*-------------------------------------------------------------------------
*/
-void
+int
h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
h5tools_context_t *ctx/*in,out*/, unsigned flags,
hsize_t nelmts, hid_t type, void *_mem)
{
+ HERR_INIT(int, SUCCEED)
unsigned char *mem = (unsigned char*) _mem;
hsize_t i; /*element counter */
size_t size; /*size of each datum */
@@ -297,7 +282,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
/* binary dump */
if (bin_output) {
- do_bin_output(rawdatastream, container, nelmts, type, _mem);
+ do_bin_output(rawdatastream, rawoutstream, container, nelmts, type, _mem);
} /* end if */
else {
/* setup */
@@ -373,8 +358,10 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
} /* if (region_id >= 0) */
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
+ else {
+ /* if (region_id < 0) - could mean that no reference was written do not throw failure */
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
+ }
ctx->need_prefix = TRUE;
@@ -402,6 +389,9 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
h5tools_str_close(&buffer);
}/* else bin */
+
+CATCH
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1242,7 +1232,8 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
ctx->need_prefix = TRUE;
- h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf);
+ if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
if (vl_data)
@@ -1500,7 +1491,8 @@ static int
h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
hid_t dset, hid_t p_type)
{
- hid_t f_space; /* file data space */
+ HERR_INIT(herr_t, SUCCEED)
+ hid_t f_space = -1; /* file data space */
hsize_t elmtno; /* counter */
size_t i; /* counter */
int carry; /* counter carry value */
@@ -1517,7 +1509,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
hsize_t sm_nbytes; /* bytes per stripmine */
hsize_t sm_nelmts; /* elements per stripmine*/
unsigned char *sm_buf = NULL; /* buffer for raw data */
- hid_t sm_space; /* stripmine data space */
+ hid_t sm_space = -1; /* stripmine data space */
/* Hyperslab info */
hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
@@ -1530,13 +1522,12 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
f_space = H5Dget_space(dset);
if (f_space == FAIL)
- return FAIL;
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
ctx->ndims = H5Sget_simple_extent_ndims(f_space);
if ((size_t)ctx->ndims > NELMTS(sm_size)) {
- H5Sclose(f_space);
- return FAIL;
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(sm_size) failed");
}
/* Assume entire data space to be printed */
@@ -1558,9 +1549,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
ctx->size_last_dim = 0;
if (p_nelmts == 0) {
- /* nothing to print */
- H5Sclose(f_space);
- return SUCCEED;
+ H5_LEAVE(SUCCEED); /* nothing to print */
}
/* Check if we have VL data in the dataset's datatype */
@@ -1622,10 +1611,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
/* Read the data */
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
- H5Sclose(f_space);
- H5Sclose(sm_space);
- HDfree(sm_buf);
- return FAIL;
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
}
/* Print the data */
@@ -1636,7 +1622,8 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
indices */
ctx->sm_pos = elmtno;
- h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf);
+ if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
if (vl_data)
@@ -1656,13 +1643,17 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
ctx->continuation++;
}
- HDfree(sm_buf);
+CATCH
+ if(sm_buf)
+ HDfree(sm_buf);
done:
- H5Sclose(sm_space);
- H5Sclose(f_space);
+ if(sm_space >= 0 && H5Sclose(sm_space) < 0)
+ H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ if(f_space >= 0 && H5Sclose(f_space) < 0)
+ H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- return SUCCEED;
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1680,13 +1671,14 @@ static int
h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id,
hid_t type, hid_t space, void *mem)
{
+ HERR_INIT(herr_t, SUCCEED)
int i; /*counters */
hsize_t nelmts; /*total selected elmts */
ctx->ndims = H5Sget_simple_extent_ndims(space);
if ((size_t) ctx->ndims > NELMTS(ctx->p_min_idx))
- return FAIL;
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
/* Assume entire data space to be printed */
for (i = 0; i < ctx->ndims; i++)
@@ -1698,7 +1690,7 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
nelmts *= ctx->p_max_idx[i] - ctx->p_min_idx[i];
if (nelmts == 0)
- return SUCCEED; /*nothing to print*/
+ H5_LEAVE(SUCCEED); /* nothing to print */
if (ctx->ndims > 0) {
HDassert(ctx->p_max_idx[ctx->ndims - 1] == (hsize_t) ((int) ctx->p_max_idx[ctx->ndims - 1]));
ctx->size_last_dim = (int) (ctx->p_max_idx[ctx->ndims - 1]);
@@ -1709,9 +1701,11 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
if (ctx->ndims > 0)
init_acc_pos(ctx, ctx->p_max_idx);
- h5tools_dump_simple_data(stream, info, obj_id, ctx, START_OF_DATA | END_OF_DATA, nelmts, type, mem);
+ if(h5tools_dump_simple_data(stream, info, obj_id, ctx, START_OF_DATA | END_OF_DATA, nelmts, type, mem) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
- return SUCCEED;
+CATCH
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1754,7 +1748,7 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
h5tool_format_t info_dflt;
/* Use default values */
if (!stream)
- stream = stdout;
+ stream = rawoutstream;
if (!info) {
HDmemset(&info_dflt, 0, sizeof info_dflt);
@@ -1826,7 +1820,7 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c
/* Use default values */
if (!stream)
- stream = stdout;
+ stream = rawoutstream;
if (!info) {
HDmemset(&info_dflt, 0, sizeof(info_dflt));
@@ -3069,7 +3063,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer,"OFFSET %u", ioffset);
+ h5tools_str_append(&buffer,"OFFSET "H5_PRINTF_HADDR_FMT, ioffset);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
ctx->indent_level--;
diff --git a/tools/lib/h5tools_dump.h b/tools/lib/h5tools_dump.h
index c94d0e1..55e046b 100644
--- a/tools/lib/h5tools_dump.h
+++ b/tools/lib/h5tools_dump.h
@@ -44,10 +44,10 @@ H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info,
H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx/*in,out*/, hid_t obj_id,
hid_t type, hid_t space, void *mem);
-H5TOOLS_DLL void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
+H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
h5tools_context_t *ctx/*in,out*/, unsigned flags,
hsize_t nelmts, hid_t type, void *_mem);
-H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
+H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx/*in,out*/, hid_t type);
H5TOOLS_DLL void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx/*in,out*/, hid_t space);
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index 207218e..ae549fd 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -22,6 +22,7 @@
#include "H5Epublic.h"
/* tools-HDF5 Error variables */
+H5TOOLS_DLLVAR hid_t H5tools_ERR_STACK_g;
H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g;
H5TOOLS_DLLVAR hid_t H5E_tools_g;
H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
@@ -66,7 +67,11 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
* HERROR macro, used to facilitate error reporting . The arguments are the major
* error number, the minor error number, and a description of the error.
*/
-#define HERROR(maj_id, min_id, str) H5Epush2(H5E_DEFAULT, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, str)
+#define HERROR(maj_id, min_id, str) { \
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, str); \
+ ret_value = FAIL; \
+}
+
/* Macro for "catching" flow of control when an error occurs. Note that the
* H5_LEAVE macro won't jump back here once it's past this point.
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index c3fbb1b..0de126d 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -157,7 +157,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
*/
if (nchars < 0
#ifndef H5_VSNPRINTF_WORKS
- && (strlen(str->s) < str->nalloc)
+ && (HDstrlen(str->s) < str->nalloc)
#endif
) {
/* failure, such as bad format */
@@ -173,7 +173,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
*/
size_t newsize = MAX(str->len + nchars + 1, 2 * str->nalloc);
HDassert(newsize > str->nalloc); /*overflow*/
- str->s = HDrealloc(str->s, newsize);
+ str->s = (char*)HDrealloc(str->s, newsize);
HDassert(str->s);
str->nalloc = newsize;
}
@@ -209,7 +209,7 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/)
{
if (!str->s || str->nalloc <= 0) {
str->nalloc = STR_INIT_LEN;
- str->s = HDmalloc(str->nalloc);
+ str->s = (char*)HDmalloc(str->nalloc);
HDassert(str->s);
}
@@ -282,7 +282,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
size_t n = sizeof(_temp);
if (str->len - start + 1 > n) {
n = str->len - start + 1;
- temp = HDmalloc(n);
+ temp = (char*)HDmalloc(n);
HDassert(temp);
}
@@ -1114,8 +1114,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) {
- int x;
-
h5tools_str_append(str, "%s", "\n");
h5tools_str_indent(str, info, ctx);
@@ -1123,7 +1121,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
else if (i && info->arr_sep) {
/* if next element begin, add next line with indent */
if (is_next_arry_elmt) {
- int x;
is_next_arry_elmt = 0;
h5tools_str_append(str, "%s", "\n ");
@@ -1366,3 +1363,52 @@ h5tools_str_is_zero(const void *_mem, size_t size)
return TRUE;
}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_str_replace
+ *
+ * Purpose: replace all occurrences of substring.
+ *
+ * Return: char *
+ *
+ * Programmer: Peter Cao
+ * March 8, 2012
+ *
+ * Notes:
+ * Applications need to call free() to free the memoery allocated for
+ * the return string
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+h5tools_str_replace ( const char *string, const char *substr, const char *replacement )
+{
+ char *tok = NULL;
+ char *newstr = NULL;
+ char *oldstr = NULL;
+ char *head = NULL;
+
+ if ( substr == NULL || replacement == NULL )
+ return strdup (string);
+
+ newstr = strdup (string);
+ head = newstr;
+ while ( (tok = strstr ( head, substr ))){
+ oldstr = newstr;
+ newstr = HDmalloc ( strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ) + 1 );
+
+ if ( newstr == NULL ){
+ HDfree (oldstr);
+ return NULL;
+ }
+ memcpy ( newstr, oldstr, tok - oldstr );
+ memcpy ( newstr + (tok - oldstr), replacement, strlen ( replacement ) );
+ memcpy ( newstr + (tok - oldstr) + strlen( replacement ), tok + strlen ( substr ), strlen ( oldstr ) - strlen ( substr ) - ( tok - oldstr ) );
+ memset ( newstr + strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ) , 0, 1 );
+ /* move back head right after the last replacement */
+ head = newstr + (tok - oldstr) + strlen( replacement );
+ HDfree (oldstr);
+ }
+
+ return newstr;
+}
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index 9527a56..38697c6 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -47,5 +47,7 @@ H5TOOLS_DLL void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_
H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info,
hid_t container, hid_t type, void *vp,
h5tools_context_t *ctx);
+H5TOOLS_DLL char *h5tools_str_replace ( const char *string, const char *substr,
+ const char *replacement );
#endif /* H5TOOLS_STR_H__ */
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index a1fe7c6..11ab5f3 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "h5tools.h"
#include "h5tools_utils.h"
#include "H5private.h"
#include "h5trav.h"
@@ -48,9 +49,9 @@ static const char *h5tools_progname = "h5tools";
* largest value suitable for your machine (for testing use a small value).
*/
/* Maximum size used in a call to malloc for a dataset */
-hsize_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024);
+hsize_t H5TOOLS_MALLOCSIZE = (256 * 1024 * 1024); /* 256 MB */
/* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */
-hsize_t H5TOOLS_BUFSIZE = (1024 * 1024);
+hsize_t H5TOOLS_BUFSIZE = ( 32 * 1024 * 1024); /* 32 MB */
/* ``parallel_print'' variables */
@@ -115,7 +116,7 @@ void parallel_print(const char* format, ...)
overflow_file = HDtmpfile();
if(overflow_file == NULL)
- HDfprintf(stderr, "warning: could not create overflow file. Output may be truncated.\n");
+ HDfprintf(rawerrorstream, "warning: could not create overflow file. Output may be truncated.\n");
else
bytes_written = HDvfprintf(overflow_file, format, ap);
}
@@ -151,9 +152,10 @@ error_msg(const char *fmt, ...)
va_list ap;
HDva_start(ap, fmt);
- HDfflush(stdout);
- HDfprintf(stderr, "%s error: ", h5tools_getprogname());
- HDvfprintf(stderr, fmt, ap);
+ HDfflush(rawdatastream);
+ HDfflush(rawoutstream);
+ HDfprintf(rawerrorstream, "%s error: ", h5tools_getprogname());
+ HDvfprintf(rawerrorstream, fmt, ap);
HDva_end(ap);
}
@@ -180,9 +182,10 @@ warn_msg(const char *fmt, ...)
va_list ap;
HDva_start(ap, fmt);
- HDfflush(stdout);
- HDfprintf(stderr, "%s warning: ", h5tools_getprogname());
- HDvfprintf(stderr, fmt, ap);
+ HDfflush(rawdatastream);
+ HDfflush(rawoutstream);
+ HDfprintf(rawerrorstream, "%s warning: ", h5tools_getprogname());
+ HDvfprintf(rawerrorstream, fmt, ap);
HDva_end(ap);
}
@@ -266,7 +269,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
}
else if (l_opts[i].has_arg == require_arg) {
if (opt_err)
- HDfprintf(stderr,
+ HDfprintf(rawerrorstream,
"%s: option required for \"--%s\" flag\n",
argv[0], arg);
@@ -276,7 +279,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
else {
if (arg[len] == '=') {
if (opt_err)
- HDfprintf(stderr,
+ HDfprintf(rawerrorstream,
"%s: no option required for \"%s\" flag\n",
argv[0], arg);
@@ -291,7 +294,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
if (l_opts[i].name == NULL) {
/* exhausted all of the l_opts we have and still didn't match */
if (opt_err)
- HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
+ HDfprintf(rawerrorstream, "%s: unknown option \"%s\"\n", argv[0], arg);
opt_opt = '?';
}
@@ -307,7 +310,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
if (opt_opt == ':' || (cp = HDstrchr(opts, opt_opt)) == 0) {
if (opt_err)
- HDfprintf(stderr, "%s: unknown option \"%c\"\n",
+ HDfprintf(rawerrorstream, "%s: unknown option \"%c\"\n",
argv[0], opt_opt);
/* if no chars left in this token, move to next token */
@@ -326,7 +329,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
}
else if (++opt_ind >= argc) {
if (opt_err)
- HDfprintf(stderr,
+ HDfprintf(rawerrorstream,
"%s: value expected for option \"%c\"\n",
argv[0], opt_opt);
@@ -385,11 +388,11 @@ indentation(int x)
{
if (x < h5tools_nCols) {
while (x-- > 0)
- printf(" ");
+ HDfprintf(rawoutstream, " ");
}
else {
- HDfprintf(stderr, "error: the indentation exceeds the number of cols.\n");
- exit(1);
+ HDfprintf(rawerrorstream, "error: the indentation exceeds the number of cols.\n");
+ HDexit(1);
}
}
@@ -411,7 +414,7 @@ indentation(int x)
void
print_version(const char *progname)
{
- printf("%s: Version %u.%u.%u%s%s\n",
+ HDfprintf(rawoutstream, "%s: Version %u.%u.%u%s%s\n",
progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE,
((char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE);
}
@@ -491,9 +494,9 @@ dump_table(char* tablename, table_t *table)
{
unsigned u;
- printf("%s: # of entries = %d\n", tablename,table->nobjs);
+ HDfprintf(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs);
for (u = 0; u < table->nobjs; u++)
- HDfprintf(stdout,"%a %s %d %d\n", table->objs[u].objno,
+ HDfprintf(rawoutstream,"%a %s %d %d\n", table->objs[u].objno,
table->objs[u].objname,
table->objs[u].displayed, table->objs[u].recorded);
}
@@ -914,7 +917,7 @@ int h5tools_getenv_update_hyperslab_bufsize(void)
{
/* TODO: later when pubilshed
- printf("Error: Invalid environment variable \"H5TOOLS_BUFSIZE\" : %s\n", env_str);
+ HDfprintf(rawerrorstream,"Error: Invalid environment variable \"H5TOOLS_BUFSIZE\" : %s\n", env_str);
*/
goto error;
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 3bb8b3f..ad8b9fe 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -151,7 +151,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
size_t base_len = HDstrlen(udata->base_grp_name);
size_t add_slash = base_len ? ((udata->base_grp_name)[base_len-1] != '/') : 1;
- if(NULL == (new_name = HDmalloc(base_len + add_slash + HDstrlen(path) + 1)))
+ if(NULL == (new_name = (char*)HDmalloc(base_len + add_slash + HDstrlen(path) + 1)))
return(H5_ITER_ERROR);
HDstrcpy(new_name, udata->base_grp_name);
if (add_slash)
@@ -895,7 +895,7 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
switch(linfo->type) {
case H5L_TYPE_SOFT:
if(linfo->u.val_size > 0) {
- char *targbuf = HDmalloc(linfo->u.val_size + 1);
+ char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
HDassert(targbuf);
H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT);
@@ -912,7 +912,7 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
const char *filename;
const char *objname;
- targbuf = HDmalloc(linfo->u.val_size + 1);
+ targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
HDassert(targbuf);
H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT);