From a6e2a45d15bc066072d01c4792b810ff47bae377 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Thu, 25 Sep 2008 15:38:21 -0500 Subject: [svn-r15699] Bug fix #1281 The TEXTFPE was described in the usage (read floats in scientific notation) but was not implemeneted. Solution: remove TEXTFPE from the help system and have the TEXTFPE input type do the same thing as TEXTPF currently does to support backwards compatibility (the format read for both TEXTFPE and TEXTPF is %f) added a test tested: windows, linux --- MANIFEST | 28 +++------------------------- tools/h5import/h5import.c | 33 +++++++++++++++++++++++++++------ tools/h5import/h5importtestutil.sh | 4 ++++ tools/h5import/testfiles/in64.txt | 2 ++ tools/h5import/testfiles/test15.h5 | Bin 0 -> 2064 bytes tools/h5import/testfiles/textpfe.conf | 11 +++++++++++ 6 files changed, 47 insertions(+), 31 deletions(-) create mode 100644 tools/h5import/testfiles/in64.txt create mode 100644 tools/h5import/testfiles/test15.h5 create mode 100644 tools/h5import/testfiles/textpfe.conf diff --git a/MANIFEST b/MANIFEST index 1996eb9..63a2828 100644 --- a/MANIFEST +++ b/MANIFEST @@ -971,31 +971,9 @@ ./tools/h5import/testfiles/binuin16.h5 ./tools/h5import/testfiles/txtuin32.h5 ./tools/h5import/testfiles/txtuin16.h5 - - - - - - - - - - - - - - - - - - - - - - - - - +./tools/h5import/testfiles/textpfe.conf +./tools/h5import/testfiles/in64.txt +./tools/h5import/testfiles/test15.h5 diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index 6352c52..89d14f9 100755 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -764,8 +764,20 @@ readFloatData(FILE **strm, struct Input *in) fp32 = (H5DT_FLOAT32 *) in->data; break; + /* same as TEXTFP */ case 2: /*TEXTFPE */ - break; + + for (i = 0; i < len; i++, fp32++) + { + if (fscanf(*strm, "%f", fp32) != 1) + { + (void) fprintf(stderr, err1); + return (-1); + } + } + + fp32 = (H5DT_FLOAT32 *) in->data; + break; case 3: /* FP */ for (i = 0; i < len; i++, fp32++) @@ -801,8 +813,20 @@ readFloatData(FILE **strm, struct Input *in) fp64 = (H5DT_FLOAT64 *) in->data; break; + /* same as TEXTFP */ case 2: /*TEXTFPE */ - break; + + for (i = 0; i < len; i++, fp64++) + { + if (fscanf(*strm, "%lf", fp64) != 1) + { + (void) fprintf(stderr, err1); + return (-1); + } + } + + fp64 = (H5DT_FLOAT64 *) in->data; + break; case 3: /* FP */ for (i = 0; i < len; i++, fp64++) @@ -2733,7 +2757,7 @@ help(char *name) (void) fprintf(stdout, "\t to be created.\n\n"); (void) fprintf(stdout, "\t INPUT-CLASS:\n"); (void) fprintf(stdout, "\t String denoting the type of input data.\n"); - (void) fprintf(stdout, "\t (\"TEXTIN\", \"TEXTFP\", \"TEXTFPE\", \"FP\", \"IN\", \n"); + (void) fprintf(stdout, "\t (\"TEXTIN\", \"TEXTFP\", \"FP\", \"IN\", \n"); (void) fprintf(stdout, "\t \"STR\", \"TEXTUIN\", \"UIN\"). \n"); (void) fprintf(stdout, "\t INPUT-CLASS \"TEXTIN\" denotes an ASCII text \n"); (void) fprintf(stdout, "\t file with signed integer data in ASCII form,\n"); @@ -2742,9 +2766,6 @@ help(char *name) (void) fprintf(stdout, "\t \"TEXTFP\" denotes an ASCII text file containing\n"); (void) fprintf(stdout, "\t floating point data in the fixed notation\n"); (void) fprintf(stdout, "\t (325.34),\n"); - (void) fprintf(stdout, "\t \"TEXTFPE\" denotes an ASCII text file containing\n"); - (void) fprintf(stdout, "\t floating point data in the scientific notation\n"); - (void) fprintf(stdout, "\t (3.2534E+02),\n"); (void) fprintf(stdout, "\t \"FP\" denotes a floating point binary file,\n"); (void) fprintf(stdout, "\t \"IN\" denotes a signed integer binary file,\n"); (void) fprintf(stdout, "\t \"UIN\" denotes an unsigned integer binary file,\n"); diff --git a/tools/h5import/h5importtestutil.sh b/tools/h5import/h5importtestutil.sh index ff7dc35..ed0a930 100755 --- a/tools/h5import/h5importtestutil.sh +++ b/tools/h5import/h5importtestutil.sh @@ -124,6 +124,10 @@ TOOLTEST $srcdir/testfiles/txtstr.txt -c $srcdir/testfiles/txtstr.conf -o txtstr TESTING "BINARY I8 CR LF EOF" TOOLTEST binin8w.bin -c $srcdir/testfiles/binin8w.conf -o binin8w.h5 +TESTING "ASCII F64 - rank 1 - INPUT-CLASS TEXTFPE " +TOOLTEST $srcdir/testfiles/in64.txt -c $srcdir/testfiles/textpfe.conf -o test15.h5 + + rm -f *.txt *.bin *.h5 rm -rf tmp_testfiles diff --git a/tools/h5import/testfiles/in64.txt b/tools/h5import/testfiles/in64.txt new file mode 100644 index 0000000..f6dd7f4 --- /dev/null +++ b/tools/h5import/testfiles/in64.txt @@ -0,0 +1,2 @@ +6.02E+24 +3.14159265E+00 diff --git a/tools/h5import/testfiles/test15.h5 b/tools/h5import/testfiles/test15.h5 new file mode 100644 index 0000000..14a9b3e Binary files /dev/null and b/tools/h5import/testfiles/test15.h5 differ diff --git a/tools/h5import/testfiles/textpfe.conf b/tools/h5import/testfiles/textpfe.conf new file mode 100644 index 0000000..69fd8c8 --- /dev/null +++ b/tools/h5import/testfiles/textpfe.conf @@ -0,0 +1,11 @@ +PATH /test +INPUT-CLASS TEXTFPE +INPUT-SIZE 64 +RANK 1 +DIMENSION-SIZES 2 +OUTPUT-CLASS FP +OUTPUT-SIZE 64 + + + + -- cgit v0.12