summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5detect.c26
-rw-r--r--tools/h5dump/h5dump.c55
-rw-r--r--tools/h5repack/testh5repack_dset.c2
-rw-r--r--tools/testfiles/tcomp-4.ddl2
-rw-r--r--tools/testfiles/tcompound_complex.h5bin8192 -> 8192 bytes
-rw-r--r--tools/testfiles/tcompound_complex.h5.xml2
-rw-r--r--tools/testfiles/test1.h5bin20944 -> 20944 bytes
-rw-r--r--tools/testfiles/tstr3.h5bin8736 -> 8736 bytes
-rw-r--r--tools/testfiles/tstring.ddl4
-rw-r--r--tools/testfiles/tstring2.ddl2
-rw-r--r--tools/testfiles/tstringe.ddl4
-rw-r--r--tools/testfiles/tvlstr.h5bin8192 -> 8192 bytes
12 files changed, 72 insertions, 25 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index b79911d..73ded41 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -195,17 +195,31 @@ precision (detected_t *d)
*/
#define DETECT_I(TYPE,VAR,INFO) { \
TYPE _v; \
+ int _int_v; \
int _i, _j; \
unsigned char *_x; \
+ \
memset (&INFO, 0, sizeof(INFO)); \
INFO.varname = #VAR; \
INFO.size = sizeof(TYPE); \
- for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
- for (_i=0,_x=(unsigned char *)&_v; _i<(signed)sizeof(TYPE); _i++) { \
- _j = (*_x++)-1; \
- assert (_j<(signed)sizeof(TYPE)); \
- INFO.perm[_i] = _j; \
- } \
+ \
+ if(sizeof(TYPE)!=1) { \
+ for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
+ for (_i=0,_x=(unsigned char *)&_v; _i<(signed)sizeof(TYPE); _i++) { \
+ _j = (*_x++)-1; \
+ assert (_j<(signed)sizeof(TYPE)); \
+ INFO.perm[_i] = _j; \
+ } \
+ } else { /*Not able to detect order if type size is 1 byte. Use native int \
+ *instead. No effect on data, just make it look correct. */ \
+ for (_i=sizeof(int),_int_v=0; _i>0; --_i) _int_v = (_int_v<<8) + _i; \
+ for (_i=0,_x=(unsigned char *)&_int_v; _i<(signed)sizeof(int); _i++) { \
+ _j = (*_x++)-1; \
+ assert (_j<(signed)sizeof(int)); \
+ INFO.perm[_i] = _j; \
+ } \
+ } \
+ \
INFO.sign = ('U'!=*(#VAR)); \
precision (&(INFO)); \
ALIGNMENT(TYPE, INFO); \
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index ba3e4ae..242ab67 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -654,6 +654,7 @@ print_datatype(hid_t type,unsigned in_group)
hsize_t dims[H5DUMP_MAX_RANK];
H5T_str_t str_pad;
H5T_cset_t cset;
+ H5T_order_t order;
H5G_stat_t statbuf;
hid_t super;
hid_t tmp_type;
@@ -809,26 +810,58 @@ print_datatype(hid_t type,unsigned in_group)
indentation(indent + COL);
printf("%s ", CTYPE);
+ /* Check C variable-length string first. Are the two types equal? */
if (H5Tequal(tmp_type, str_type)) {
printf("H5T_C_S1;\n");
H5Tclose(str_type);
- } else {
+ goto done;
+ }
+
+ /* Change the endianness and see if they're equal. */
+ order = H5Tget_order(tmp_type);
+ if(order==H5T_ORDER_LE)
+ H5Tset_order(str_type, H5T_ORDER_LE);
+ else if(order==H5T_ORDER_BE)
+ H5Tset_order(str_type, H5T_ORDER_BE);
+
+ if (H5Tequal(tmp_type, str_type)) {
+ printf("H5T_C_S1;\n");
H5Tclose(str_type);
- str_type = H5Tcopy(H5T_FORTRAN_S1);
- H5Tset_cset(str_type, cset);
- H5Tset_size(str_type, size);
- H5Tset_strpad(str_type, str_pad);
+ goto done;
+ }
- if (H5Tequal(tmp_type, str_type)) {
- printf("H5T_FORTRAN_S1;\n");
- } else {
- printf("unknown_one_character_type;\n ");
- d_status = EXIT_FAILURE;
- }
+ /* If not equal to C variable-length string, check Fortran type. */
+ H5Tclose(str_type);
+ str_type = H5Tcopy(H5T_FORTRAN_S1);
+ H5Tset_cset(str_type, cset);
+ H5Tset_size(str_type, size);
+ H5Tset_strpad(str_type, str_pad);
+
+ /* Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ printf("H5T_FORTRAN_S1;\n");
+ H5Tclose(str_type);
+ goto done;
+ }
+ /* Change the endianness and see if they're equal. */
+ order = H5Tget_order(tmp_type);
+ if(order==H5T_ORDER_LE)
+ H5Tset_order(str_type, H5T_ORDER_LE);
+ else if(order==H5T_ORDER_BE)
+ H5Tset_order(str_type, H5T_ORDER_BE);
+
+ if (H5Tequal(tmp_type, str_type)) {
+ printf("H5T_FORTRAN_S1;\n");
H5Tclose(str_type);
+ goto done;
}
+ printf("unknown_one_character_type;\n ");
+ d_status = EXIT_FAILURE;
+ H5Tclose(str_type);
+
+done:
H5Tclose(tmp_type);
indent -= COL;
diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c
index 299c044..8781ae7 100644
--- a/tools/h5repack/testh5repack_dset.c
+++ b/tools/h5repack/testh5repack_dset.c
@@ -655,7 +655,7 @@ static void make_dset_reg_ref(hid_t loc_id)
sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
/* Create a dataset */
- dset2=H5Dcreate(loc_id,"dsetreg",H5T_STD_U8LE,sid2,H5P_DEFAULT);
+ dset2=H5Dcreate(loc_id,"dsetreg",H5T_NATIVE_UCHAR,sid2,H5P_DEFAULT);
for(i=0; i<SPACE2_DIM1*SPACE2_DIM2; i++)
dwbuf[i]=i*3;
diff --git a/tools/testfiles/tcomp-4.ddl b/tools/testfiles/tcomp-4.ddl
index 32212f0..967b4a6 100644
--- a/tools/testfiles/tcomp-4.ddl
+++ b/tools/testfiles/tcomp-4.ddl
@@ -21,7 +21,7 @@ GROUP "/" {
H5T_ARRAY { [5][6] H5T_STD_I16BE } "d_name";
H5T_IEEE_F32BE "e_name";
H5T_ARRAY { [10] H5T_IEEE_F64BE } "f_name";
- H5T_STD_I8LE "g_name";
+ H5T_STD_I8BE "g_name";
}
DATASPACE SIMPLE { ( 6 ) / ( 6 ) }
DATA {
diff --git a/tools/testfiles/tcompound_complex.h5 b/tools/testfiles/tcompound_complex.h5
index 5eed316..9516371 100644
--- a/tools/testfiles/tcompound_complex.h5
+++ b/tools/testfiles/tcompound_complex.h5
Binary files differ
diff --git a/tools/testfiles/tcompound_complex.h5.xml b/tools/testfiles/tcompound_complex.h5.xml
index 44378dd..e213e8d 100644
--- a/tools/testfiles/tcompound_complex.h5.xml
+++ b/tools/testfiles/tcompound_complex.h5.xml
@@ -84,7 +84,7 @@ Expected output for 'h5dump --xml tcompound_complex.h5'
<hdf5:Field FieldName="g_name">
<hdf5:DataType>
<hdf5:AtomicType>
- <hdf5:IntegerType ByteOrder="LE" Sign="true" Size="1" />
+ <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="1" />
</hdf5:AtomicType>
</hdf5:DataType>
</hdf5:Field>
diff --git a/tools/testfiles/test1.h5 b/tools/testfiles/test1.h5
index 4016565..70cea54 100644
--- a/tools/testfiles/test1.h5
+++ b/tools/testfiles/test1.h5
Binary files differ
diff --git a/tools/testfiles/tstr3.h5 b/tools/testfiles/tstr3.h5
index e44e2b3..dc9a127 100644
--- a/tools/testfiles/tstr3.h5
+++ b/tools/testfiles/tstr3.h5
Binary files differ
diff --git a/tools/testfiles/tstring.ddl b/tools/testfiles/tstring.ddl
index 6510eaa..9189a4f 100644
--- a/tools/testfiles/tstring.ddl
+++ b/tools/testfiles/tstring.ddl
@@ -39,7 +39,7 @@ GROUP "/" {
}
DATASET "str3" {
DATATYPE H5T_COMPOUND {
- H5T_STD_I32LE "a";
+ H5T_STD_I32BE "a";
H5T_STRING {
STRSIZE 255;
STRPAD H5T_STR_NULLTERM;
@@ -57,7 +57,7 @@ GROUP "/" {
}
}
DATASET "str4" {
- DATATYPE H5T_STD_I8LE
+ DATATYPE H5T_STD_I8BE
DATASPACE SIMPLE { ( 93 ) / ( 93 ) }
DATA {
(0): 70, 111, 117, 114, 32, 115, 99, 111, 114, 101, 32, 97, 110, 100,
diff --git a/tools/testfiles/tstring2.ddl b/tools/testfiles/tstring2.ddl
index c3e9844..303d5fc 100644
--- a/tools/testfiles/tstring2.ddl
+++ b/tools/testfiles/tstring2.ddl
@@ -3,7 +3,7 @@ Expected output for 'h5dump -r -d str4 tstr3.h5'
#############################
HDF5 "tstr3.h5" {
DATASET "str4" {
- DATATYPE H5T_STD_I8LE
+ DATATYPE H5T_STD_I8BE
DATASPACE SIMPLE { ( 93 ) / ( 93 ) }
DATA {
"Four score and seven
diff --git a/tools/testfiles/tstringe.ddl b/tools/testfiles/tstringe.ddl
index 1d96dbd..e16e98d 100644
--- a/tools/testfiles/tstringe.ddl
+++ b/tools/testfiles/tstringe.ddl
@@ -32,7 +32,7 @@ GROUP "/" {
}
DATASET "str3" {
DATATYPE H5T_COMPOUND {
- H5T_STD_I32LE "a";
+ H5T_STD_I32BE "a";
H5T_STRING {
STRSIZE 255;
STRPAD H5T_STR_NULLTERM;
@@ -49,7 +49,7 @@ GROUP "/" {
}
}
DATASET "str4" {
- DATATYPE H5T_STD_I8LE
+ DATATYPE H5T_STD_I8BE
DATASPACE SIMPLE { ( 93 ) / ( 93 ) }
DATA {
(0): 70, 111, 117, 114, 32, 115, 99, 111, 114, 101, 32, 97, 110, 100,
diff --git a/tools/testfiles/tvlstr.h5 b/tools/testfiles/tvlstr.h5
index c00defc..076fb3a 100644
--- a/tools/testfiles/tvlstr.h5
+++ b/tools/testfiles/tvlstr.h5
Binary files differ