- Timestamp:
- Nov 7, 2012, 3:13:05 PM (12 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r624 r625 1 2012-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 1 9 2012-09-21 <rybkin@lal.in2p3.fr> 495 2 10 -
CMT/HEAD/source/cmt_symbol.cxx
r612 r625 223 223 #endif 224 224 } 225 /** 226 * similar to processing 227 * `shell' function of GNU Make does 228 * on command output 229 */ 230 static 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 } 225 249 226 250 /** … … 318 342 CmtSystem::execute (command, result); 319 343 344 /* 320 345 int pos; 321 346 pos = result.find ('\n'); … … 323 348 pos = result.find ('\r'); 324 349 if (pos != cmt_string::npos) result.erase (pos); 325 350 */ 351 process_cmd_output (result); 352 326 353 if (Cmt::get_debug ()) 327 354 { 328 cout << " 355 cout << "resolve_value: Executing [" << command << "] to expand a symbol value =>[" 329 356 << result << "]" << endl; 330 357 } … … 462 489 CmtSystem::execute (command, result); 463 490 491 /* 464 492 int pos; 465 493 pos = result.find ('\n'); … … 467 495 pos = result.find ('\r'); 468 496 if (pos != cmt_string::npos) result.erase (pos); 497 */ 498 process_cmd_output (result); 469 499 470 500 if (Cmt::get_debug ()) … … 596 626 CmtSystem::execute (command, result); 597 627 628 /* 598 629 int pos; 599 630 pos = result.find ('\n'); … … 601 632 pos = result.find ('\r'); 602 633 if (pos != cmt_string::npos) result.erase (pos); 634 */ 635 process_cmd_output (result); 603 636 604 637 if (Cmt::get_debug ())
Note: See TracChangeset
for help on using the changeset viewer.