diff options
author | rhaas <rhaas@5c1b1641-b641-47ec-b3d9-0f93d4c445ee> | 2012-01-26 17:16:50 +0000 |
---|---|---|
committer | rhaas <rhaas@5c1b1641-b641-47ec-b3d9-0f93d4c445ee> | 2012-01-26 17:16:50 +0000 |
commit | c89f1741426cd09a80db7d99e0571d83e9b987e5 (patch) | |
tree | 3652ca677c401b290cea7371839b5f381045aed3 | |
parent | cb168b365c7778e17fa66b1ead251b26b8acada4 (diff) |
throw ios_base::failure(strerror(errno)) exception if fopen fails in Bin_BH,
Bin_NS and Mag_NS
git-svn-id: http://svn.cactuscode.org/projects/ExternalLibraries/LORENE/trunk@35 5c1b1641-b641-47ec-b3d9-0f93d4c445ee
-rw-r--r-- | LORENE.sh | 1 | ||||
-rw-r--r-- | dist/check_fopen_error.patch | 82 |
2 files changed, 83 insertions, 0 deletions
@@ -93,6 +93,7 @@ then ${PATCH} -p0 < ${SRCDIR}/dist/makesystem.patch ${PATCH} -p0 < ${SRCDIR}/dist/pgplot.patch ${PATCH} -p0 < ${SRCDIR}/dist/openmp.patch + ${PATCH} -p0 < ${SRCDIR}/dist/check_fopen_error.patch # Some (ancient but still used) versions of patch don't support the # patch format used here but also don't report an error using the # exit code. So we use this patch to test for this diff --git a/dist/check_fopen_error.patch b/dist/check_fopen_error.patch new file mode 100644 index 0000000..8adec59 --- /dev/null +++ b/dist/check_fopen_error.patch @@ -0,0 +1,82 @@ +diff -ru Lorene/Export/C++/Source/bin_bh_aux.C Lorene/Export/C++/Source/bin_bh_aux.C +--- Lorene/Export/C++/Source/bin_bh_aux.C 2009-09-21 17:01:18.000000000 -0700 ++++ Lorene/Export/C++/Source/bin_bh_aux.C 2012-01-25 11:41:48.000000000 -0800 +@@ -62,8 +62,14 @@ + #include "../Include/bin_bh.h" + + // C headers ++#include <string.h> ++#include <errno.h> + #include <math.h> + ++// C++ headers ++#include <ios> ++#include <string> ++ + // Lorene headers + #include "tenseur.h" + #include "bhole.h" +@@ -82,6 +88,9 @@ + // Reading of data + // --------------- + FILE* fich = fopen(filename, "r") ; ++ if ( NULL == fich ) { ++ throw std::ios_base::failure(strerror(errno)); ++ } + Mg3d* grille_1 = new Mg3d (fich) ; + Mg3d* grille_2 ; + if (mdiff) +diff -ru Lorene/Export/C++/Source/bin_ns_aux.C Lorene/Export/C++/Source/bin_ns_aux.C +--- Lorene/Export/C++/Source/bin_ns_aux.C 2006-09-12 01:04:07.000000000 -0700 ++++ Lorene/Export/C++/Source/bin_ns_aux.C 2012-01-25 11:39:08.000000000 -0800 +@@ -56,8 +56,13 @@ + + // C headers + #include <string.h> ++#include <errno.h> + #include <math.h> + ++// C++ headers ++#include <ios> ++#include <string> ++ + // Lorene headers + #include "tenseur.h" + #include "binaire.h" +@@ -77,6 +82,9 @@ + // Reading of data + // --------------- + FILE* fich = fopen(filename, "r") ; ++ if ( NULL == fich ) { ++ throw std::ios_base::failure(strerror(errno)); ++ } + + int mer ; + fread(&mer, sizeof(int), 1, fich) ; // mer +diff -ru Lorene/Export/C++/Source/mag_ns_aux.C Lorene/Export/C++/Source/mag_ns_aux.C +--- Lorene/Export/C++/Source/mag_ns_aux.C 2009-11-19 08:15:21.000000000 -0800 ++++ Lorene/Export/C++/Source/mag_ns_aux.C 2012-01-25 11:41:59.000000000 -0800 +@@ -43,8 +43,13 @@ + + // C headers + #include <string.h> ++#include <errno.h> + #include <math.h> + ++// C++ headers ++#include <ios> ++#include <string> ++ + // Lorene headers + #include "tenseur.h" + #include "et_rot_mag.h" +@@ -67,6 +72,9 @@ + // Reading of data + // --------------- + FILE* fich = fopen(filename, "r") ; ++ if ( NULL == fich ) { ++ throw std::ios_base::failure(strerror(errno)); ++ } + + Mg3d spectral_grid(fich) ; + int nphi = spectral_grid.get_np(0) ; |