diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2006-05-23 20:51:37 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2006-05-23 20:51:37 (GMT) |
commit | ab9ac4264e7188c89fcf327c8170d255f35a03c3 (patch) | |
tree | dcfa3353710963eb95cf44561a906f84c8eb717d /hl/src/H5LTparse.y | |
parent | 51c7d9eb39f5413a690f9a1d76e27a2edf16bc67 (diff) | |
download | hdf5-ab9ac4264e7188c89fcf327c8170d255f35a03c3.zip hdf5-ab9ac4264e7188c89fcf327c8170d255f35a03c3.tar.gz hdf5-ab9ac4264e7188c89fcf327c8170d255f35a03c3.tar.bz2 |
[svn-r12370] Purpose: Bug fix.
Description: The current code in Yacc parser doesn't handle big-endian
machine for enum type correctly.
Solution: Depending on the super type of enum, use appropriate integer
type to pass in enum value.
Platforms tested: h5committest and fuss.
Diffstat (limited to 'hl/src/H5LTparse.y')
-rw-r--r-- | hl/src/H5LTparse.y | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y index 50e8f6d..c67f0e5 100644 --- a/hl/src/H5LTparse.y +++ b/hl/src/H5LTparse.y @@ -332,12 +332,33 @@ enum_def : '"' enum_symbol '"' { } enum_val ';' { - int memb_val; + char char_val=(char)yylval.ival; + short short_val=(short)yylval.ival; + int int_val=(int)yylval.ival; + long long_val=(long)yylval.ival; + long long llong_val=(long long)yylval.ival; + hid_t super = H5Tget_super(enum_id); + hid_t native = H5Tget_native_type(super, H5T_DIR_ASCEND); + if(is_enum && is_enum_memb) { /*if it's an enum member*/ - H5Tenum_insert(enum_id, enum_memb_symbol, (memb_val=yylval.ival,&memb_val)); + /*To handle machines of different endianness*/ + if(H5Tequal(native, H5T_NATIVE_SCHAR) || H5Tequal(native, H5T_NATIVE_UCHAR)) + H5Tenum_insert(enum_id, enum_memb_symbol, &char_val); + else if(H5Tequal(native, H5T_NATIVE_SHORT) || H5Tequal(native, H5T_NATIVE_USHORT)) + H5Tenum_insert(enum_id, enum_memb_symbol, &short_val); + else if(H5Tequal(native, H5T_NATIVE_INT) || H5Tequal(native, H5T_NATIVE_UINT)) + H5Tenum_insert(enum_id, enum_memb_symbol, &int_val); + else if(H5Tequal(native, H5T_NATIVE_LONG) || H5Tequal(native, H5T_NATIVE_ULONG)) + H5Tenum_insert(enum_id, enum_memb_symbol, &long_val); + else if(H5Tequal(native, H5T_NATIVE_LLONG) || H5Tequal(native, H5T_NATIVE_ULLONG)) + H5Tenum_insert(enum_id, enum_memb_symbol, &llong_val); + is_enum_memb = 0; if(enum_memb_symbol) free(enum_memb_symbol); } + + H5Tclose(super); + H5Tclose(native); } ; enum_symbol : STRING |