From fb4178612a6d5b670bb5991d4427ddd7b7bcd6ae Mon Sep 17 00:00:00 2001 From: jean-pierre roux Date: Mon, 28 Jan 2008 10:50:54 +0000 Subject: [PATCH] Allow user to always forget .bbs --- kernel/src/bbtkInterpreter.cxx | 23 ++++++++++++++++++----- kernel/src/bbtkInterpreter.h | 28 ++++++++++++---------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index 18b3b76..921c278 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ $ Language: C++ - Date: $Date: 2008/01/28 09:12:49 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008/01/28 10:50:54 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -31,6 +31,7 @@ #define BBTK_USE_TERMIOS_BASED_PROMPT #endif +#include namespace bbtk { @@ -696,7 +697,6 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& // =================================================================================== - void Interpreter::SwitchToFile( const std::string& name, bool use_configuration_file, bool verbose) { @@ -715,7 +715,6 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& std::string pkgname; // e.g. .bbs pkgname = Utilities::ExtractScriptName(name); -std::cout << "pkgname [" << pkgname << "] name [" << name << "]" << std::endl; if (use_configuration_file) { if (verbose) @@ -731,6 +730,21 @@ std::cout << "pkgname [" << pkgname << "] name [" << name << "]" << std::endl; { // ------------------------------------- check user supplied location fullnameGiven = true; libname = Utilities::ExpandLibName(name, verbose); + + // allow user to always forget ".bbs" + int l = libname.size(); + if (l>4) + { + if (libname.substr(l-4, 4) != ".bbs") + { + libname = libname + ".bbs"; + } + } + else + { + libname = libname + ".bbs"; + } + if (libname != "") { if ( Utilities::FileExists(libname)) { @@ -755,7 +769,6 @@ std::cout << "pkgname [" << pkgname << "] name [" << name << "]" << std::endl; } libname = Utilities::MakePkgnameFromPath(path, pkgname); - // Check if library exists if ( ! Utilities::FileExists(libname) ) { diff --git a/kernel/src/bbtkInterpreter.h b/kernel/src/bbtkInterpreter.h index 4d81c65..bc60dd3 100644 --- a/kernel/src/bbtkInterpreter.h +++ b/kernel/src/bbtkInterpreter.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.h,v $ $ Language: C++ - Date: $Date: 2008/01/22 16:55:04 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008/01/28 10:50:54 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,7 +36,6 @@ namespace bbtk { - class BBTK_EXPORT Interpreter { @@ -156,28 +155,27 @@ namespace bbtk void FindCommandsWithPrefix( char* buf, int n, std::vector& commands ); - + /// Sets the bool that indicates wether we are in command line context void SetCommandLine(bool v = true) { mCommandLine = v; } private: - + private: - + //================================================================== // ATTRIBUTES /// The factory // bbtk::Factory* mFactory; - /// The command executer - // bbtk::Executer* mExecuter; + /// The command executer bbtk::VirtualExec* mExecuter; - /// Vector of opened files + /// Vector of opened files std::vector mFile; - /// Vector of names of open files + /// Vector of names of open files std::vector mFileName; /// Stores the current line number in each open file @@ -188,10 +186,10 @@ namespace bbtk /// Are we in a command line context ? bool mCommandLine; - - /// The history of commands - std::deque< char* > mHistory; - + + /// The history of commands + std::deque< char* > mHistory; + bool verbose; // true -> displays the search results (for packages) }; @@ -202,7 +200,5 @@ namespace bbtk QuitException() : bbtk::Exception("","","") {} }; - - } #endif -- 2.47.1