From 7d8b8f129d03569a6af39e22a51fae6c36009e09 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Wed, 14 Apr 2004 11:41:43 -0500 Subject: [svn-r8352] Purpose: bug fix Description: the routine for reading the options from a file had the "old" parse syntax Solution: Platforms tested: linux solaris AIX Misc. update: --- tools/h5repack/h5repack.c | 27 +++++++++++++++++++++------ tools/h5repack/h5repack.sh | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 21166b7..bd89ca0 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -397,14 +397,23 @@ void read_info(const char *filename, FILE *fp; char c; int i, rc=1; + char *srcdir = getenv("srcdir"); /* the source directory */ + char data_file[512]=""; /* buffer to hold name of existing file */ + + /* compose the name of the file to open, using the srcdir, if appropriate */ + if (srcdir){ + strcpy(data_file,srcdir); + strcat(data_file,"/"); + } + strcat(data_file,filename); - if ((fp = fopen(filename, "r")) == (FILE *)NULL) { + if ((fp = fopen(data_file, "r")) == (FILE *)NULL) { printf( "Cannot open options file %s", filename); exit(1); } - /* Cycle until end of file reached */ + /* cycle until end of file reached */ while( 1 ) { rc=fscanf(fp, "%s", stype); @@ -419,17 +428,20 @@ void read_info(const char *filename, /* find begining of info */ i=0; c='0'; - while( c!='"' ) + while( c!=' ' ) { fscanf(fp, "%c", &c); + if (feof(fp)) break; } c='0'; /* go until end */ - while( c!='"' ) + while( c!=' ' ) { fscanf(fp, "%c", &c); comp_info[i]=c; i++; + if (feof(fp)) break; + if (c==10 /*eol*/) break; } comp_info[i-1]='\0'; /*cut the last " */ @@ -446,17 +458,20 @@ void read_info(const char *filename, /* find begining of info */ i=0; c='0'; - while( c!='"' ) + while( c!=' ' ) { fscanf(fp, "%c", &c); + if (feof(fp)) break; } c='0'; /* go until end */ - while( c!='"' ) + while( c!=' ' ) { fscanf(fp, "%c", &c); comp_info[i]=c; i++; + if (feof(fp)) break; + if (c==10 /*eol*/) break; } comp_info[i-1]='\0'; /*cut the last " */ diff --git a/tools/h5repack/h5repack.sh b/tools/h5repack/h5repack.sh index df7a7a3..f1a6281 100644 --- a/tools/h5repack/h5repack.sh +++ b/tools/h5repack/h5repack.sh @@ -169,7 +169,7 @@ TOOLTEST test4.h5 -f dset_all:GZIP=1 TOOLTEST test4.h5 -f GZIP=1 -m 1024 #file -#TOOLTEST test4.h5 -e h5repack_info.txt +TOOLTEST test4.h5 -e ../testfiles/h5repack_info.txt if test $nerrors -eq 0 ; then echo "All $H5REPACK tests passed." -- cgit v0.12