summaryrefslogtreecommitdiffstats
path: root/hl/src/H5LTparse.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2009-04-28 21:42:33 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2009-04-28 21:42:33 (GMT)
commit71b49b0f9bd3cd5ac7d9a331260f3d5bfb3eb6d8 (patch)
treefd6ed60dd18d7838bb68552133e36d580739457c /hl/src/H5LTparse.c
parent4d6fcb288ac03d577335e115268bc7bc6397b2dd (diff)
downloadhdf5-71b49b0f9bd3cd5ac7d9a331260f3d5bfb3eb6d8.zip
hdf5-71b49b0f9bd3cd5ac7d9a331260f3d5bfb3eb6d8.tar.gz
hdf5-71b49b0f9bd3cd5ac7d9a331260f3d5bfb3eb6d8.tar.bz2
[svn-r16880] Fixed a bug in H5LTtext_to_dtype. When the data type is enumerate and the super type is different from
the native integer, the value wasn't converted. I fixed it and corrected the test, too. Tested with h5committest.
Diffstat (limited to 'hl/src/H5LTparse.c')
-rw-r--r--hl/src/H5LTparse.c78
1 files changed, 45 insertions, 33 deletions
diff --git a/hl/src/H5LTparse.c b/hl/src/H5LTparse.c
index 6e5e08b..98dcbd5 100644
--- a/hl/src/H5LTparse.c
+++ b/hl/src/H5LTparse.c
@@ -14,11 +14,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This file was generated by Yacc with the command "yacc -pH5LTyy -o H5LTparse.c -d H5LTparse.y"
- * Do NOT modify it by hand.
+ * on jam. Do NOT modify it by hand.
*/
-
#ifndef lint
-static char const
+static char const
yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
#endif
#include <stdlib.h>
@@ -92,7 +91,7 @@ struct arr_info {
};
/*stack for nested array type*/
struct arr_info arr_stack[STACK_SIZE];
-int asindex = -1; /*pointer to the top of array stack*/
+int asindex = -1; /*pointer to the top of array stack*/
hbool_t is_str_size = 0; /*flag to lexer for string size*/
hbool_t is_str_pad = 0; /*flag to lexer for string padding*/
@@ -100,7 +99,7 @@ H5T_pad_t str_pad; /*variable for string padding*/
H5T_cset_t str_cset; /*variable for string character set*/
hbool_t is_variable = 0; /*variable for variable-length string*/
size_t str_size; /*variable for string size*/
-
+
hid_t enum_id; /*type ID*/
hbool_t is_enum = 0; /*flag to lexer for enum type*/
hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/
@@ -823,9 +822,9 @@ case 46:
break;
case 47:
#line 156 "H5LTparse.y"
-{ yyval.ival = cmpd_stack[csindex].id;
+{ yyval.ival = cmpd_stack[csindex].id;
cmpd_stack[csindex].id = 0;
- cmpd_stack[csindex].first_memb = 1;
+ cmpd_stack[csindex].first_memb = 1;
csindex--;
}
break;
@@ -835,7 +834,7 @@ case 50:
break;
case 51:
#line 167 "H5LTparse.y"
-{
+{
size_t origin_size, new_size;
hid_t dtype_id = cmpd_stack[csindex].id;
@@ -849,7 +848,7 @@ case 51:
cmpd_stack[csindex].first_memb = 0;
} else {
origin_size = H5Tget_size(dtype_id);
-
+
if(yyvsp[-1].ival == 0) {
new_size = origin_size + H5Tget_size(yyvsp[-6].ival);
H5Tset_size(dtype_id, new_size);
@@ -860,10 +859,10 @@ case 51:
H5Tinsert(dtype_id, yyvsp[-3].sval, yyvsp[-1].ival, yyvsp[-6].ival);
}
}
-
+
cmpd_stack[csindex].is_field = 0;
H5Tclose(yyvsp[-6].ival);
-
+
new_size = H5Tget_size(dtype_id);
}
break;
@@ -887,7 +886,7 @@ case 56:
break;
case 57:
#line 213 "H5LTparse.y"
-{
+{
yyval.ival = H5Tarray_create2(yyvsp[-1].ival, arr_stack[asindex].ndims, arr_stack[asindex].dims);
arr_stack[asindex].ndims = 0;
asindex--;
@@ -901,9 +900,9 @@ break;
case 61:
#line 224 "H5LTparse.y"
{ unsigned ndims = arr_stack[asindex].ndims;
- arr_stack[asindex].dims[ndims] = (hsize_t)yylval.ival;
+ arr_stack[asindex].dims[ndims] = (hsize_t)yylval.ival;
arr_stack[asindex].ndims++;
- arr_stack[asindex].is_dim = 0;
+ arr_stack[asindex].is_dim = 0;
}
break;
case 64:
@@ -916,10 +915,10 @@ case 65:
break;
case 66:
#line 241 "H5LTparse.y"
-{
+{
size_t size = (size_t)yylval.ival;
yyval.ival = H5Tcreate(H5T_OPAQUE, size);
- is_opq_size = 0;
+ is_opq_size = 0;
}
break;
case 67:
@@ -928,7 +927,7 @@ case 67:
break;
case 68:
#line 247 "H5LTparse.y"
-{
+{
H5Tset_tag(yyvsp[-6].ival, yylval.sval);
is_opq_tag = 0;
}
@@ -943,12 +942,12 @@ case 72:
break;
case 73:
#line 260 "H5LTparse.y"
-{
+{
if(yyvsp[-1].ival == H5T_VARIABLE_TOKEN)
is_variable = 1;
- else
+ else
str_size = yylval.ival;
- is_str_size = 0;
+ is_str_size = 0;
}
break;
case 74:
@@ -964,7 +963,7 @@ case 74:
break;
case 75:
#line 277 "H5LTparse.y"
-{
+{
if(yyvsp[-1].ival == H5T_CSET_ASCII_TOKEN)
str_cset = H5T_CSET_ASCII;
else if(yyvsp[-1].ival == H5T_CSET_UTF8_TOKEN)
@@ -982,7 +981,7 @@ case 76:
break;
case 77:
#line 291 "H5LTparse.y"
-{
+{
hid_t str_id = yyvsp[-1].ival;
/*set string size*/
@@ -991,12 +990,12 @@ case 77:
is_variable = 0;
} else
H5Tset_size(str_id, str_size);
-
+
/*set string padding and character set*/
H5Tset_strpad(str_id, str_pad);
H5Tset_cset(str_id, str_cset);
- yyval.ival = str_id;
+ yyval.ival = str_id;
}
break;
case 78:
@@ -1043,7 +1042,7 @@ case 91:
#line 330 "H5LTparse.y"
{
is_enum_memb = 1; /*indicate member of enum*/
- enum_memb_symbol = strdup(yylval.sval);
+ enum_memb_symbol = strdup(yylval.sval);
}
break;
case 92:
@@ -1056,21 +1055,34 @@ case 92:
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);
-
+ H5T_order_t super_order = H5Tget_order(super);
+ H5T_order_t native_order = H5Tget_order(native);
+
if(is_enum && is_enum_memb) { /*if it's an enum member*/
/*To handle machines of different endianness*/
- if(H5Tequal(native, H5T_NATIVE_SCHAR) || H5Tequal(native, H5T_NATIVE_UCHAR))
+ if(H5Tequal(native, H5T_NATIVE_SCHAR) || H5Tequal(native, H5T_NATIVE_UCHAR)) {
+ if(super_order != native_order)
+ H5Tconvert(native, super, 1, &char_val, NULL, H5P_DEFAULT);
H5Tenum_insert(enum_id, enum_memb_symbol, &char_val);
- else if(H5Tequal(native, H5T_NATIVE_SHORT) || H5Tequal(native, H5T_NATIVE_USHORT))
+ } else if(H5Tequal(native, H5T_NATIVE_SHORT) || H5Tequal(native, H5T_NATIVE_USHORT)) {
+ if(super_order != native_order)
+ H5Tconvert(native, super, 1, &short_val, NULL, H5P_DEFAULT);
H5Tenum_insert(enum_id, enum_memb_symbol, &short_val);
- else if(H5Tequal(native, H5T_NATIVE_INT) || H5Tequal(native, H5T_NATIVE_UINT))
+ } else if(H5Tequal(native, H5T_NATIVE_INT) || H5Tequal(native, H5T_NATIVE_UINT)) {
+ if(super_order != native_order)
+ H5Tconvert(native, super, 1, &int_val, NULL, H5P_DEFAULT);
H5Tenum_insert(enum_id, enum_memb_symbol, &int_val);
- else if(H5Tequal(native, H5T_NATIVE_LONG) || H5Tequal(native, H5T_NATIVE_ULONG))
+ } else if(H5Tequal(native, H5T_NATIVE_LONG) || H5Tequal(native, H5T_NATIVE_ULONG)) {
+ if(super_order != native_order)
+ H5Tconvert(native, super, 1, &long_val, NULL, H5P_DEFAULT);
H5Tenum_insert(enum_id, enum_memb_symbol, &long_val);
- else if(H5Tequal(native, H5T_NATIVE_LLONG) || H5Tequal(native, H5T_NATIVE_ULLONG))
+ } else if(H5Tequal(native, H5T_NATIVE_LLONG) || H5Tequal(native, H5T_NATIVE_ULLONG)) {
+ if(super_order != native_order)
+ H5Tconvert(native, super, 1, &llong_val, NULL, H5P_DEFAULT);
H5Tenum_insert(enum_id, enum_memb_symbol, &llong_val);
+ }
- is_enum_memb = 0;
+ is_enum_memb = 0;
if(enum_memb_symbol) free(enum_memb_symbol);
}
@@ -1078,7 +1090,7 @@ case 92:
H5Tclose(native);
}
break;
-#line 1063 "H5LTparse.c"
+#line 1076 "H5LTparse.c"
}
yyssp -= yym;
yystate = *yyssp;