From 42c12344ed245d7c1f8e70ba0b6fa5f278960035 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Thu, 7 Aug 2003 00:16:13 +0000 Subject: [PATCH] Fixed an error in get_CTML_Tree() where the program wouldn't use the path where the file was found, but would assume the file was located in the current directory. This caused an empty ifstream to be send to build(), which then created an infinite loop (probably another error in build() that needs to be fixed). --- Cantera/src/ct2ctml.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Cantera/src/ct2ctml.cpp b/Cantera/src/ct2ctml.cpp index 559cfed6d..2a97448a3 100644 --- a/Cantera/src/ct2ctml.cpp +++ b/Cantera/src/ct2ctml.cpp @@ -1,10 +1,19 @@ +/** + * @file ct2ctml.cpp + * + * $Author$ + * $Revision$ + * $Date$ + */ + +// Copyright 2001 California Institute of Technology + #include "ct_defs.h" #include "ctexceptions.h" #include #include #include #include "ctml.h" -#include "../../include/pypath.h" using namespace Cantera; @@ -85,7 +94,9 @@ namespace ctml { msg += "\nError in Python installation."; else msg += "\nCheck error messages above for syntax errors."; - throw CanteraError("ct2ctml", "could not convert input file to CTML\n command line was: "+msg); + throw CanteraError("ct2ctml", + "could not convert input file to CTML\n " + "command line was: " + msg); } } @@ -95,7 +106,7 @@ namespace ctml { * first. */ void get_CTML_Tree(XML_Node* rootPtr, string file) { - string ff; + string ff, ext = ""; // find the input file on the Cantera search path string inname = findInputFile(file); @@ -106,15 +117,17 @@ namespace ctml { * Check whether or not the file is XML. If not, it will be first * processed with the preprocessor. */ - int idot = file.find('.'); - string ext = file.substr(idot,file.size()); + string::size_type idot = inname.rfind('.'); + if (idot != string::npos) { + ext = inname.substr(idot, inname.size()); + } if (ext != ".xml" && ext != ".ctml") { - ct2ctml(file.c_str()); - ff = file.substr(0,idot)+".xml"; + ct2ctml(inname.c_str()); + ff = inname.substr(0,idot) + ".xml"; } - else - ff = file; - + else { + ff = inname; + } ifstream fin(ff.c_str()); rootPtr->build(fin); fin.close();