Changeset 625 for CMT


Ignore:
Timestamp:
Nov 7, 2012, 3:13:05 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 496

Location:
CMT/HEAD
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r624 r625  
     12012-11-07    <rybkin@lal.in2p3.fr> 496
     2
     3        * source/cmt_symbol.cxx: Introduce helper function process_cmd_output to
     4        process command output similar to `shell' function of GNU Make. Make use of
     5        this function in functions resolve_value, resolve_value_for_macros,
     6        suppress_OS_delimiters in order to allow for possibly multi-line output of
     7        commands in command substitution (introduced with backquotes)
     8       
    192012-09-21    <rybkin@lal.in2p3.fr> 495
    210
  • CMT/HEAD/source/cmt_symbol.cxx

    r612 r625  
    223223#endif
    224224}
     225/**
     226 * similar to processing
     227 * `shell' function of GNU Make does
     228 *  on command output
     229 */
     230static void process_cmd_output (cmt_string& text)
     231{
     232  //cerr << "process_cmd_output (begin): [" << text << "]" << endl;
     233  // remove trailing (carriage-return and) newline(s)
     234  int nl = text.size ();
     235  while (nl > 0 && text[nl - 1] == '\n')
     236    {
     237      nl--;
     238      if (nl > 0 && text[nl - 1] == '\r')
     239        nl--;
     240    }
     241  if (nl != text.size ())
     242    text.erase (nl);
     243
     244  // convert each newline (or carriage-return / newline pair) to a single space
     245  text.replace_all ("\r\n", " ");
     246  text.replace_all ("\n", " ");
     247  //cerr << "process_cmd_output (end): [" << text << "]" << endl;
     248}
    225249
    226250/**
     
    318342          CmtSystem::execute (command, result);
    319343         
     344          /*
    320345          int pos;
    321346          pos = result.find ('\n');
     
    323348          pos = result.find ('\r');
    324349          if (pos != cmt_string::npos) result.erase (pos);
    325          
     350          */         
     351          process_cmd_output (result);
     352
    326353          if (Cmt::get_debug ())
    327354            {
    328               cout << "  Executing [" << command << "] to expand a symbol value =>["
     355              cout << "resolve_value: Executing [" << command << "] to expand a symbol value =>["
    329356                   << result << "]" << endl;
    330357            }
     
    462489          CmtSystem::execute (command, result);
    463490         
     491          /*
    464492          int pos;
    465493          pos = result.find ('\n');
     
    467495          pos = result.find ('\r');
    468496          if (pos != cmt_string::npos) result.erase (pos);
     497          */
     498          process_cmd_output (result);
    469499         
    470500          if (Cmt::get_debug ())
     
    596626          CmtSystem::execute (command, result);
    597627         
     628          /*
    598629          int pos;
    599630          pos = result.find ('\n');
     
    601632          pos = result.find ('\r');
    602633          if (pos != cmt_string::npos) result.erase (pos);
     634          */         
     635          process_cmd_output (result);
    603636         
    604637          if (Cmt::get_debug ())
Note: See TracChangeset for help on using the changeset viewer.