From c89f1741426cd09a80db7d99e0571d83e9b987e5 Mon Sep 17 00:00:00 2001 From: rhaas Date: Thu, 26 Jan 2012 17:16:50 +0000 Subject: 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 --- LORENE.sh | 1 + dist/check_fopen_error.patch | 82 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 dist/check_fopen_error.patch diff --git a/LORENE.sh b/LORENE.sh index d8bdc9f..6cf047b 100644 --- a/LORENE.sh +++ b/LORENE.sh @@ -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 ++#include + #include + ++// C++ headers ++#include ++#include ++ + // 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 ++#include + #include + ++// C++ headers ++#include ++#include ++ + // 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 ++#include + #include + ++// C++ headers ++#include ++#include ++ + // 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) ; -- cgit v1.2.3