summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2006-05-23 20:51:37 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2006-05-23 20:51:37 (GMT)
commitab9ac4264e7188c89fcf327c8170d255f35a03c3 (patch)
treedcfa3353710963eb95cf44561a906f84c8eb717d
parent51c7d9eb39f5413a690f9a1d76e27a2edf16bc67 (diff)
downloadhdf5-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.
-rw-r--r--hl/src/H5LTparse.c206
-rw-r--r--hl/src/H5LTparse.h1
-rw-r--r--hl/src/H5LTparse.y25
3 files changed, 130 insertions, 102 deletions
diff --git a/hl/src/H5LTparse.c b/hl/src/H5LTparse.c
index 5abc136..ed72a31 100644
--- a/hl/src/H5LTparse.c
+++ b/hl/src/H5LTparse.c
@@ -1,21 +1,3 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* This file was generated by Yacc with the command "yacc -o H5LTparse.c -d H5LTparse.y"
- * Do NOT modify it by hand.
- */
-
#ifndef lint
static char const
yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
@@ -31,7 +13,7 @@ yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bd
#define YYRECOVERING() (yyerrflag!=0)
static int yygrowstack();
#define YYPREFIX "yy"
-#line 2 "H5LTparse.y"
+#line 16 "H5LTparse.y"
#include<stdio.h>
#include<string.h>
#include<hdf5.h>
@@ -47,11 +29,14 @@ struct cmpd_info {
hbool_t is_field; /*flag to lexer for compound member*/
hbool_t first_memb; /*flag for first compound member*/
};
+
/*stack for nested compound type*/
-struct cmpd_info cmpd_stack[STACK_SIZE] = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
- 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
- 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
- 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };
+struct cmpd_info cmpd_stack[STACK_SIZE] = {
+ {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1},
+ {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1},
+ {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1},
+ {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1} };
+
int csindex = -1; /*pointer to the top of compound stack*/
/*structure for array type information*/
@@ -79,12 +64,12 @@ char* enum_memb_symbol; /*enum member symbol string*/
hbool_t is_opq_size = 0; /*flag to lexer for opaque type size*/
hbool_t is_opq_tag = 0; /*flag to lexer for opaque type tag*/
-#line 50 "H5LTparse.y"
+#line 67 "H5LTparse.y"
typedef union {
int ival; /*for integer token*/
char *sval; /*for name string*/
} YYSTYPE;
-#line 70 "H5LTparse.c"
+#line 73 "H5LTparse.c"
#define YYERRCODE 256
#define H5T_STD_I8BE_TOKEN 257
#define H5T_STD_I8LE_TOKEN 258
@@ -644,155 +629,155 @@ yyreduce:
switch (yyn)
{
case 1:
-#line 82 "H5LTparse.y"
+#line 99 "H5LTparse.y"
{ memset(arr_stack, 0, STACK_SIZE*sizeof(struct arr_info)); /*initialize here?*/ }
break;
case 2:
-#line 83 "H5LTparse.y"
+#line 100 "H5LTparse.y"
{ return yyval.ival;}
break;
case 12:
-#line 97 "H5LTparse.y"
+#line 114 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I8BE); }
break;
case 13:
-#line 98 "H5LTparse.y"
+#line 115 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I8LE); }
break;
case 14:
-#line 99 "H5LTparse.y"
+#line 116 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I16BE); }
break;
case 15:
-#line 100 "H5LTparse.y"
+#line 117 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I16LE); }
break;
case 16:
-#line 101 "H5LTparse.y"
+#line 118 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I32BE); }
break;
case 17:
-#line 102 "H5LTparse.y"
+#line 119 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I32LE); }
break;
case 18:
-#line 103 "H5LTparse.y"
+#line 120 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I64BE); }
break;
case 19:
-#line 104 "H5LTparse.y"
+#line 121 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_I64LE); }
break;
case 20:
-#line 105 "H5LTparse.y"
+#line 122 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U8BE); }
break;
case 21:
-#line 106 "H5LTparse.y"
+#line 123 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U8LE); }
break;
case 22:
-#line 107 "H5LTparse.y"
+#line 124 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U16BE); }
break;
case 23:
-#line 108 "H5LTparse.y"
+#line 125 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U16LE); }
break;
case 24:
-#line 109 "H5LTparse.y"
+#line 126 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U32BE); }
break;
case 25:
-#line 110 "H5LTparse.y"
+#line 127 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U32LE); }
break;
case 26:
-#line 111 "H5LTparse.y"
+#line 128 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U64BE); }
break;
case 27:
-#line 112 "H5LTparse.y"
+#line 129 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_STD_U64LE); }
break;
case 28:
-#line 113 "H5LTparse.y"
+#line 130 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_CHAR); }
break;
case 29:
-#line 114 "H5LTparse.y"
+#line 131 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_SCHAR); }
break;
case 30:
-#line 115 "H5LTparse.y"
+#line 132 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_UCHAR); }
break;
case 31:
-#line 116 "H5LTparse.y"
+#line 133 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_SHORT); }
break;
case 32:
-#line 117 "H5LTparse.y"
+#line 134 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_USHORT); }
break;
case 33:
-#line 118 "H5LTparse.y"
+#line 135 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_INT); }
break;
case 34:
-#line 119 "H5LTparse.y"
+#line 136 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_UINT); }
break;
case 35:
-#line 120 "H5LTparse.y"
+#line 137 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_LONG); }
break;
case 36:
-#line 121 "H5LTparse.y"
+#line 138 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_ULONG); }
break;
case 37:
-#line 122 "H5LTparse.y"
+#line 139 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_LLONG); }
break;
case 38:
-#line 123 "H5LTparse.y"
+#line 140 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_ULLONG); }
break;
case 39:
-#line 126 "H5LTparse.y"
+#line 143 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_IEEE_F32BE); }
break;
case 40:
-#line 127 "H5LTparse.y"
+#line 144 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_IEEE_F32LE); }
break;
case 41:
-#line 128 "H5LTparse.y"
+#line 145 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_IEEE_F64BE); }
break;
case 42:
-#line 129 "H5LTparse.y"
+#line 146 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_IEEE_F64LE); }
break;
case 43:
-#line 130 "H5LTparse.y"
+#line 147 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_FLOAT); }
break;
case 44:
-#line 131 "H5LTparse.y"
+#line 148 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_DOUBLE); }
break;
case 45:
-#line 132 "H5LTparse.y"
+#line 149 "H5LTparse.y"
{ yyval.ival = H5Tcopy(H5T_NATIVE_LDOUBLE); }
break;
case 46:
-#line 136 "H5LTparse.y"
+#line 153 "H5LTparse.y"
{ csindex++; cmpd_stack[csindex].id = H5Tcreate(H5T_COMPOUND, 1); /*temporarily set size to 1*/ }
break;
case 47:
-#line 138 "H5LTparse.y"
+#line 155 "H5LTparse.y"
{ yyval.ival = cmpd_stack[csindex].id;
cmpd_stack[csindex].id = 0;
cmpd_stack[csindex].first_memb = 1;
@@ -800,13 +785,13 @@ case 47:
}
break;
case 50:
-#line 147 "H5LTparse.y"
+#line 164 "H5LTparse.y"
{ cmpd_stack[csindex].is_field = 1; /*notify lexer a compound member is parsed*/ }
break;
case 51:
-#line 149 "H5LTparse.y"
+#line 166 "H5LTparse.y"
{
- int origin_size, new_size;
+ size_t origin_size, new_size;
hid_t dtype_id = cmpd_stack[csindex].id;
/*Adjust size and insert member, consider both member size and offset.*/
@@ -838,25 +823,25 @@ case 51:
}
break;
case 52:
-#line 182 "H5LTparse.y"
+#line 199 "H5LTparse.y"
{
yyval.sval = yylval.sval;
}
break;
case 53:
-#line 187 "H5LTparse.y"
+#line 204 "H5LTparse.y"
{ yyval.ival = 0; }
break;
case 54:
-#line 189 "H5LTparse.y"
+#line 206 "H5LTparse.y"
{ yyval.ival = yylval.ival; }
break;
case 56:
-#line 193 "H5LTparse.y"
+#line 210 "H5LTparse.y"
{ asindex++; /*pushd onto the stack*/ }
break;
case 57:
-#line 195 "H5LTparse.y"
+#line 212 "H5LTparse.y"
{
yyval.ival = H5Tarray_create(yyvsp[-1].ival, arr_stack[asindex].ndims, arr_stack[asindex].dims, NULL);
arr_stack[asindex].ndims = 0;
@@ -865,11 +850,11 @@ case 57:
}
break;
case 60:
-#line 205 "H5LTparse.y"
+#line 222 "H5LTparse.y"
{ arr_stack[asindex].is_dim = 1; /*notice lexer of dimension size*/ }
break;
case 61:
-#line 206 "H5LTparse.y"
+#line 223 "H5LTparse.y"
{ int ndims = arr_stack[asindex].ndims;
arr_stack[asindex].dims[ndims] = (hsize_t)yylval.ival;
arr_stack[asindex].ndims++;
@@ -877,15 +862,15 @@ case 61:
}
break;
case 64:
-#line 217 "H5LTparse.y"
+#line 234 "H5LTparse.y"
{ yyval.ival = H5Tvlen_create(yyvsp[-1].ival); H5Tclose(yyvsp[-1].ival); }
break;
case 65:
-#line 222 "H5LTparse.y"
+#line 239 "H5LTparse.y"
{ is_opq_size = 1; }
break;
case 66:
-#line 223 "H5LTparse.y"
+#line 240 "H5LTparse.y"
{
size_t size = (size_t)yylval.ival;
yyval.ival = H5Tcreate(H5T_OPAQUE, size);
@@ -893,26 +878,26 @@ case 66:
}
break;
case 67:
-#line 228 "H5LTparse.y"
+#line 245 "H5LTparse.y"
{ is_opq_tag = 1; }
break;
case 68:
-#line 229 "H5LTparse.y"
+#line 246 "H5LTparse.y"
{
H5Tset_tag(yyvsp[-6].ival, yylval.sval);
is_opq_tag = 0;
}
break;
case 69:
-#line 233 "H5LTparse.y"
+#line 250 "H5LTparse.y"
{ yyval.ival = yyvsp[-8].ival; }
break;
case 72:
-#line 241 "H5LTparse.y"
+#line 258 "H5LTparse.y"
{ is_str_size = 1; }
break;
case 73:
-#line 242 "H5LTparse.y"
+#line 259 "H5LTparse.y"
{
if(yyvsp[-1].ival == H5T_VARIABLE_TOKEN)
is_variable = 1;
@@ -922,7 +907,7 @@ case 73:
}
break;
case 74:
-#line 250 "H5LTparse.y"
+#line 267 "H5LTparse.y"
{
if(yyvsp[-1].ival == H5T_STR_NULLTERM_TOKEN)
str_pad = H5T_STR_NULLTERM;
@@ -933,7 +918,7 @@ case 74:
}
break;
case 75:
-#line 259 "H5LTparse.y"
+#line 276 "H5LTparse.y"
{
if(yyvsp[-1].ival == H5T_CSET_ASCII_TOKEN)
str_cset = H5T_CSET_ASCII;
@@ -942,7 +927,7 @@ case 75:
}
break;
case 76:
-#line 266 "H5LTparse.y"
+#line 283 "H5LTparse.y"
{
if(yyvsp[-1].ival == H5T_C_S1_TOKEN)
yyval.ival = H5Tcopy(H5T_C_S1);
@@ -951,7 +936,7 @@ case 76:
}
break;
case 77:
-#line 273 "H5LTparse.y"
+#line 290 "H5LTparse.y"
{
hid_t str_id = yyvsp[-1].ival;
@@ -970,64 +955,85 @@ case 77:
}
break;
case 78:
-#line 290 "H5LTparse.y"
+#line 307 "H5LTparse.y"
{yyval.ival = H5T_VARIABLE_TOKEN;}
break;
case 80:
-#line 293 "H5LTparse.y"
+#line 310 "H5LTparse.y"
{yyval.ival = H5T_STR_NULLTERM_TOKEN;}
break;
case 81:
-#line 294 "H5LTparse.y"
+#line 311 "H5LTparse.y"
{yyval.ival = H5T_STR_NULLPAD_TOKEN;}
break;
case 82:
-#line 295 "H5LTparse.y"
+#line 312 "H5LTparse.y"
{yyval.ival = H5T_STR_SPACEPAD_TOKEN;}
break;
case 83:
-#line 297 "H5LTparse.y"
+#line 314 "H5LTparse.y"
{yyval.ival = H5T_CSET_ASCII_TOKEN;}
break;
case 84:
-#line 298 "H5LTparse.y"
+#line 315 "H5LTparse.y"
{yyval.ival = H5T_CSET_UTF8_TOKEN;}
break;
case 85:
-#line 300 "H5LTparse.y"
+#line 317 "H5LTparse.y"
{yyval.ival = H5T_C_S1_TOKEN;}
break;
case 86:
-#line 301 "H5LTparse.y"
+#line 318 "H5LTparse.y"
{yyval.ival = H5T_FORTRAN_S1_TOKEN;}
break;
case 87:
-#line 305 "H5LTparse.y"
+#line 322 "H5LTparse.y"
{ is_enum = 1; enum_id = H5Tenum_create(yyvsp[-1].ival); H5Tclose(yyvsp[-1].ival); }
break;
case 88:
-#line 307 "H5LTparse.y"
+#line 324 "H5LTparse.y"
{ is_enum = 0; /*reset*/ yyval.ival = enum_id; }
break;
case 91:
-#line 312 "H5LTparse.y"
+#line 329 "H5LTparse.y"
{
is_enum_memb = 1; /*indicate member of enum*/
enum_memb_symbol = strdup(yylval.sval);
}
break;
case 92:
-#line 317 "H5LTparse.y"
+#line 334 "H5LTparse.y"
{
- 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);
}
break;
-#line 1013 "H5LTparse.c"
+#line 1037 "H5LTparse.c"
}
yyssp -= yym;
yystate = *yyssp;
diff --git a/hl/src/H5LTparse.h b/hl/src/H5LTparse.h
index 5210d7e..a038cb1 100644
--- a/hl/src/H5LTparse.h
+++ b/hl/src/H5LTparse.h
@@ -15,6 +15,7 @@
/* This file was generated by Yacc with the command "yacc -o H5LTparse.c -d H5LTparse.y"
* Do NOT modify it by hand.
*/
+
#ifndef YYERRCODE
#define YYERRCODE 256
#endif
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