summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff_array.c9
-rw-r--r--tools/lib/h5tools.c2
-rw-r--r--tools/lib/h5tools_str.c117
-rw-r--r--tools/lib/h5tools_str.h1
-rw-r--r--tools/lib/talign.c255
5 files changed, 194 insertions, 190 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 62975d9..9929b05 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -1915,15 +1915,18 @@ hsize_t diff_region(hid_t obj1_id,
for (i = 0; i < npoints1; i++)
{
hsize_t pt1, pt2;
- int diff=0;
+ int diff_data = 0;
for (j = 0; j < ndims1; j++)
{
pt1 = ptdata1[i * ndims1 + j];
pt2 = ptdata2[i * ndims1 + j];
if (pt1 != pt2)
- diff=1;
+ {
+ diff_data = 1;
+ break;
+ }
}
- if (diff)
+ if (diff_data)
{
parallel_print("point #%d", i);
print_points(i, ptdata1, ndims1);
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 013cecf..362b070 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1434,7 +1434,7 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
}
else
{
- s = mem;
+ s = (char *)mem;
size = H5Tget_size(tid);
}
for (i=0; i<size && (s[i] || pad!=H5T_STR_NULLTERM); i++)
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 7ad5db7..76bb81f 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -46,6 +46,7 @@
static char *h5tools_escape(char *s, size_t size);
static hbool_t h5tools_is_zero(const void *_mem, size_t size);
+static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch);
/*-------------------------------------------------------------------------
* Function: h5tools_str_close
@@ -460,69 +461,69 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t
*
*-------------------------------------------------------------------------
*/
-void
-h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned char ch)
+static void
+h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch)
{
if (info->str_locale == ESCAPE_HTML) {
if (ch <= ' ' || ch > '~')
h5tools_str_append(str, "%%%02x", ch);
else
- h5tools_str_append(str, "%c", (char)ch);
+ h5tools_str_append(str, "%c", ch);
} else {
switch (ch) {
- case '"':
- if (!info->do_escape)
- h5tools_str_append(str, "\"");
- else
- h5tools_str_append(str, "\\\"");
- break;
- case '\\':
- if (!info->do_escape)
- h5tools_str_append(str, "\\");
- else
- h5tools_str_append(str, "\\\\");
- break;
- case '\b':
- if (!info->do_escape)
- h5tools_str_append(str, "\b");
- else
- h5tools_str_append(str, "\\b");
- break;
- case '\f':
- if (!info->do_escape)
- h5tools_str_append(str, "\f");
- else
- h5tools_str_append(str, "\\f");
- break;
- case '\n':
- if (!info->do_escape) {
- h5tools_str_append(str, "\n");
- h5tools_str_append(str, " ");
- }
- else
- h5tools_str_append(str, "\\n");
- break;
- case '\r':
- if (!info->do_escape) {
- h5tools_str_append(str, "\r");
- h5tools_str_append(str, " ");
- }
- else
- h5tools_str_append(str, "\\r");
- break;
- case '\t':
- if (!info->do_escape)
- h5tools_str_append(str, "\t");
- else
- h5tools_str_append(str, "\\t");
- break;
- default:
- if (isprint(ch))
- h5tools_str_append(str, "%c", (char)ch);
- else
- h5tools_str_append(str, "\\%03o", ch);
-
- break;
+ case '"':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\"");
+ else
+ h5tools_str_append(str, "\\\"");
+ break;
+ case '\\':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\\");
+ else
+ h5tools_str_append(str, "\\\\");
+ break;
+ case '\b':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\b");
+ else
+ h5tools_str_append(str, "\\b");
+ break;
+ case '\f':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\f");
+ else
+ h5tools_str_append(str, "\\f");
+ break;
+ case '\n':
+ if (!info->do_escape) {
+ h5tools_str_append(str, "\n");
+ h5tools_str_append(str, " ");
+ }
+ else
+ h5tools_str_append(str, "\\n");
+ break;
+ case '\r':
+ if (!info->do_escape) {
+ h5tools_str_append(str, "\r");
+ h5tools_str_append(str, " ");
+ }
+ else
+ h5tools_str_append(str, "\\r");
+ break;
+ case '\t':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\t");
+ else
+ h5tools_str_append(str, "\\t");
+ break;
+ default:
+ if (isprint(ch))
+ h5tools_str_append(str, "%c", ch);
+ else
+ h5tools_str_append(str, "\\%03o", ch);
+
+ break;
}
}
}
@@ -632,7 +633,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
#endif
} else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) ||
H5Tequal(type, H5T_NATIVE_UCHAR))) {
- h5tools_print_char(str, info, (unsigned char)(*ucp_vp));
+ h5tools_print_char(str, info, (char)(*ucp_vp));
} else if (H5T_STRING == H5Tget_class(type)) {
unsigned int i;
char quote = '\0';
@@ -686,7 +687,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
}
/* Print the character */
- h5tools_print_char(str, info, (unsigned char)(s[i]));
+ h5tools_print_char(str, info, s[i]);
/* Print the repeat count */
if (info->str_repeat && j > info->str_repeat) {
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index 19872a1..b2d1c37 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -35,7 +35,6 @@ extern char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *in
hsize_t elmtno, int ndims, hsize_t min_idx[],
hsize_t max_idx[], h5tools_context_t *ctx);
extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5tool_format_t *);
-extern void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned char ch);
extern 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);
diff --git a/tools/lib/talign.c b/tools/lib/talign.c
index f8b5c87..80e83b4 100644
--- a/tools/lib/talign.c
+++ b/tools/lib/talign.c
@@ -36,154 +36,155 @@ const char *setname = "align";
int main(void)
{
- hid_t fil,spc,set;
- hid_t cs6, cmp, fix;
- hid_t cmp1, cmp2, cmp3;
- hid_t plist;
- hid_t array_dt;
+ hid_t fil,spc,set;
+ hid_t cs6, cmp, fix;
+ hid_t cmp1, cmp2, cmp3;
+ hid_t plist;
+ hid_t array_dt;
- hsize_t dim[2];
- hsize_t cdim[4];
+ hsize_t dim[2];
+ hsize_t cdim[4];
- char string5[5];
- float fok[2] = {1234., 2341.};
- float fnok[2] = {5678., 6785.};
- float *fptr;
+ char string5[5];
+ float fok[2] = {1234., 2341.};
+ float fnok[2] = {5678., 6785.};
+ float *fptr;
- char *data;
- char *mname;
+ char *data;
+ char *mname;
- int result = 0;
+ int result = 0;
- printf("%-70s", "Testing alignment in compound datatypes");
+ printf("%-70s", "Testing alignment in compound datatypes");
- strcpy(string5, "Hi!");
- HDunlink(fname);
- fil = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ strcpy(string5, "Hi!");
+ HDunlink(fname);
+ fil = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (fil < 0) {
- puts("*FAILED*");
- return 1;
- }
+ if (fil < 0) {
+ puts("*FAILED*");
+ return 1;
+ }
- H5E_BEGIN_TRY {
- H5Gunlink(fil, setname);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY {
+ H5Gunlink(fil, setname);
+ } H5E_END_TRY;
- cs6 = H5Tcopy(H5T_C_S1);
- H5Tset_size(cs6, sizeof(string5));
- H5Tset_strpad(cs6, H5T_STR_NULLPAD);
+ cs6 = H5Tcopy(H5T_C_S1);
+ H5Tset_size(cs6, sizeof(string5));
+ H5Tset_strpad(cs6, H5T_STR_NULLPAD);
- cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok));
- H5Tinsert(cmp, "Awkward length", 0, cs6);
+ cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok));
+ H5Tinsert(cmp, "Awkward length", 0, cs6);
- cdim[0] = sizeof(fok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp, "Ok", sizeof(string5), array_dt);
+ cdim[0] = sizeof(fok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp, "Ok", sizeof(string5), array_dt);
H5Tclose(array_dt);
- cdim[0] = sizeof(fnok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
+ cdim[0] = sizeof(fnok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
H5Tclose(array_dt);
- fix=h5tools_get_native_type(cmp);
+ fix=h5tools_get_native_type(cmp);
- cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));
+ cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));
- cdim[0] = sizeof(fok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp1, "Ok", 0, array_dt);
+ cdim[0] = sizeof(fok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp1, "Ok", 0, array_dt);
H5Tclose(array_dt);
- cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5));
- H5Tinsert(cmp2, "Awkward length", 0, cs6);
+ cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5));
+ H5Tinsert(cmp2, "Awkward length", 0, cs6);
- cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok));
+ cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok));
- cdim[0] = sizeof(fnok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp3, "Not Ok", 0, array_dt);
+ cdim[0] = sizeof(fnok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp3, "Not Ok", 0, array_dt);
H5Tclose(array_dt);
- plist = H5Pcreate(H5P_DATASET_XFER);
- H5Pset_preserve(plist, 1);
-
- /*
- * Create a small dataset, and write data into it we write each field
- * in turn so that we are avoid alignment issues at this point
- */
- dim[0] = 1;
- spc = H5Screate_simple(1, dim, NULL);
- set = H5Dcreate(fil, setname, cmp, spc, H5P_DEFAULT);
-
- H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok);
- H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5);
- H5Dwrite(set, cmp3, spc, H5S_ALL, plist, fnok);
-
- H5Dclose(set);
-
- /* Now open the set, and read it back in */
- data = malloc(H5Tget_size(fix));
-
- if (!data) {
- perror("malloc() failed");
- abort();
- }
-
- set = H5Dopen(fil, setname);
-
- H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data);
- fptr = (float *)(data + H5Tget_member_offset(fix, 1));
-
- if (fok[0] != fptr[0] || fok[1] != fptr[1]
- || fnok[0] != fptr[2] || fnok[1] != fptr[3]) {
- result = 1;
- printf("%14s (%2d) %6s = %s\n",
- mname = H5Tget_member_name(fix, 0), (int)H5Tget_member_offset(fix,0),
- string5, (char *)(data + H5Tget_member_offset(fix, 0)));
- free(mname);
- fptr = (float *)(data + H5Tget_member_offset(fix, 1));
- printf("Data comparison:\n"
- "%14s (%2d) %6f = %f\n"
- " %6f = %f\n",
- mname = H5Tget_member_name(fix, 1), (int)H5Tget_member_offset(fix,1),
- fok[0], fptr[0],
- fok[1], fptr[1]);
- free(mname);
- fptr = (float *)(data + H5Tget_member_offset(fix, 2));
- printf("%14s (%2d) %6f = %f\n"
- " %6f = %6f\n",
- mname = H5Tget_member_name(fix, 2), (int)H5Tget_member_offset(fix,2),
- fnok[0], fptr[0],
- fnok[1], fptr[1]);
- free(mname);
-
- fptr = (float *)(data + H5Tget_member_offset(fix, 1));
- printf("\n"
- "Short circuit\n"
- " %6f = %f\n"
- " %6f = %f\n"
- " %6f = %f\n"
- " %6f = %f\n",
- fok[0], fptr[0],
- fok[1], fptr[1],
- fnok[0], fptr[2],
- fnok[1], fptr[3]);
- puts("*FAILED*");
- } else {
- puts(" PASSED");
- }
-
- free(data);
- H5Sclose(spc);
- H5Tclose(cmp);
- H5Tclose(cmp1);
- H5Tclose(cmp2);
- H5Tclose(cmp3);
- H5Pclose(plist);
- H5Fclose(fil);
- unlink(fname);
- fflush(stdout);
- return result;
+ plist = H5Pcreate(H5P_DATASET_XFER);
+ H5Pset_preserve(plist, 1);
+
+ /*
+ * Create a small dataset, and write data into it we write each field
+ * in turn so that we are avoid alignment issues at this point
+ */
+ dim[0] = 1;
+ spc = H5Screate_simple(1, dim, NULL);
+ set = H5Dcreate(fil, setname, cmp, spc, H5P_DEFAULT);
+
+ H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok);
+ H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5);
+ H5Dwrite(set, cmp3, spc, H5S_ALL, plist, fnok);
+
+ H5Dclose(set);
+
+ /* Now open the set, and read it back in */
+ data = malloc(H5Tget_size(fix));
+
+ if (!data) {
+ perror("malloc() failed");
+ abort();
+ }
+
+ set = H5Dopen(fil, setname);
+
+ H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data);
+ fptr = (float *)(data + H5Tget_member_offset(fix, 1));
+
+ if (fok[0] != fptr[0] || fok[1] != fptr[1]
+ || fnok[0] != fptr[2] || fnok[1] != fptr[3]) {
+ result = 1;
+ printf("%14s (%2d) %6s = %s\n",
+ mname = H5Tget_member_name(fix, 0), (int)H5Tget_member_offset(fix,0),
+ string5, (char *)(data + H5Tget_member_offset(fix, 0)));
+ free(mname);
+ fptr = (float *)(data + H5Tget_member_offset(fix, 1));
+ printf("Data comparison:\n"
+ "%14s (%2d) %6f = %f\n"
+ " %6f = %f\n",
+ mname = H5Tget_member_name(fix, 1), (int)H5Tget_member_offset(fix,1),
+ fok[0], fptr[0],
+ fok[1], fptr[1]);
+ free(mname);
+ fptr = (float *)(data + H5Tget_member_offset(fix, 2));
+ printf("%14s (%2d) %6f = %f\n"
+ " %6f = %6f\n",
+ mname = H5Tget_member_name(fix, 2), (int)H5Tget_member_offset(fix,2),
+ fnok[0], fptr[0],
+ fnok[1], fptr[1]);
+ free(mname);
+
+ fptr = (float *)(data + H5Tget_member_offset(fix, 1));
+ printf("\n"
+ "Short circuit\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n",
+ fok[0], fptr[0],
+ fok[1], fptr[1],
+ fnok[0], fptr[2],
+ fnok[1], fptr[3]);
+ puts("*FAILED*");
+ } else {
+ puts(" PASSED");
+ }
+
+ free(data);
+ H5Sclose(spc);
+ H5Tclose(cmp);
+ H5Tclose(cmp1);
+ H5Tclose(cmp2);
+ H5Tclose(cmp3);
+ H5Pclose(plist);
+ H5Fclose(fil);
+ unlink(fname);
+ fflush(stdout);
+ return result;
}
+