Changeset 13713 for trunk/FACT++


Ignore:
Timestamp:
05/14/12 13:41:13 (13 years ago)
Author:
tbretz
Message:
Added Uncomment function to tools used to strip off inline comments.
Location:
trunk/FACT++/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Readline.cc

    r13702 r13713  
    11661166//
    11671167//! Process a single line. All lines are added to the history, but only
    1168 //! accepted lines are written to the command log. Inthis case fLine is
     1168//! accepted lines are written to the command log. In this case fLine is
    11691169//! increased by one.
     1170//! Comment (starting with #) are removed from the command-line. A # can be
     1171//! escaped with quotation marks "#"
    11701172//
    11711173void Readline::ProcessLine(const string &str)
    11721174{
    1173     const bool rc = PreProcess(str);
    1174 
    1175     AddToHistory(str);
    1176 
    1177     if (rc)
    1178         return;
    1179 
    1180     fLine++;
     1175    const string cmd = Tools::Uncomment(str);
     1176
     1177    if (!cmd.empty())
     1178    {
     1179        const bool rc = PreProcess(cmd);
     1180
     1181        AddToHistory(cmd);
     1182
     1183        if (rc)
     1184            return;
     1185
     1186        fLine++;
     1187    }
    11811188
    11821189    fCommandLog << str << endl;
  • trunk/FACT++/src/tools.cc

    r13667 r13713  
    192192    return rc;
    193193}
     194
     195// --------------------------------------------------------------------------
     196//
     197//! Returns the string with a comment (introduced by a #) stripped. The
     198//! comment mark can be escaped by either \# or "#"
     199//!
     200string Tools::Uncomment(const string &opt)
     201{
     202    using namespace boost;
     203    typedef escaped_list_separator<char> separator;
     204
     205    return *tokenizer<separator>(opt, separator('\\', '#', '\"')).begin();
     206}
  • trunk/FACT++/src/tools.h

    r13667 r13713  
    1414
    1515    std::map<std::string,std::string> Split(std::string &);
     16    std::string Uncomment(const std::string &opt);
    1617}
    1718
Note: See TracChangeset for help on using the changeset viewer.