From f1d960a769de15644659cc53de237e13f5b8c4c7 Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Thu, 29 Oct 2015 23:10:47 +1000 Subject: [PATCH] Gmt module: Base2Something raise error flag if initialized by pointer of incompatible type. Some small changes. --- modules/gmt/modgmt_func.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/gmt/modgmt_func.cpp b/modules/gmt/modgmt_func.cpp index 30e5b36..11abdc6 100644 --- a/modules/gmt/modgmt_func.cpp +++ b/modules/gmt/modgmt_func.cpp @@ -22,7 +22,11 @@ class Base2Something: public OBTypeM Base2Something(const ObjectBase* arg):OBTypeM(arg) {}; Base2Something(const ObjectList* input, const std::string& name):OBTypeM(input->Get(name)){}; Base2Something(const ObjectList* input, const ObjectList::ListValues::size_type i):OBTypeM((iSize())?input->At(i):0){}; // Check index, because At is not safe - auto operator ()(bool* b) const -> decltype(this->OBTypeM::template operator()(b)) {return OBTypeM::operator ()(b);} + auto operator ()(bool* b) const -> decltype(this->OBTypeM::template operator()(b)) + { + if(!OBTypeM::operator bool()) *b=false; + return OBTypeM::operator ()(b); + } }; // Converting Int, Real or String to double @@ -226,8 +230,7 @@ class ProjConv if(proj) return p=proj->Data(); // Case 1 OBType list(arg); if(list) return p=operator()(list,issuc); // Case 2 - *issuc=false; - return p; // Conversion failed + goto fail; // Conversion failed } // Case 3 @@ -834,8 +837,7 @@ ObjectString can be number or in form "dd:mm[:ss]", where dd is degrees from -36 ObjectBase* GMT_Coord(const ObjectList* input) { if(input->Size()!=1) return 0; - const ObjectBase *arg=input->At(0); - Base2Coord a(arg); + Base2Coord a(input,0); struct gmt_coord c; bool suc=true;