- Timestamp:
- Apr 3, 2012, 3:54:50 PM (12 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r606 r607 1 2012-04-03 <rybkin@lal.in2p3.fr> 482 2 3 * source/cmt_syntax.cxx: In class SyntaxParser function 4 do_parse_requirements, check return value of string read function and set 5 error on failure, re-write function do_parse_text in order to optimise 6 * source/cmt_awk.cxx: In class Parser, re-write function parse in order 7 to optimise, in class Awk function run, test CMTTESTAWK environment 8 variable in debug mode only, re-write function run in order to optimise 9 * source/cmt_string.cxx: In class cmt_string, make function resize set size 10 and terminate string with 0, optimise functions substr (int, int), 11 substr (int, int, cmt_string&) 12 * source/cmt_pattern.cxx: In class Pattern functions test CMTTESTPATTERN 13 environment variable in debug mode only 14 * source/cmt_regexp.cxx: In class cmt_and_node function match, class 15 cmt_or_node function match, class cmt_regexp function set, test 16 CMTTESTREGEXP environment variable in debug mode only 17 * source/cmt_parser.cxx: In class Cmt function set_standard_macros, test 18 TAGDEBUG environment variable once 19 * source/cmt_system.cxx: In class CmtSystem, re-write function realpath_ 20 making use of system functions realpath (POSIX) and _fullpath (Windows) 21 * source/cmt_use.cxx: In class Use function get_cmtpath_and_offset, check 22 return value of CmtSystem::realpath_ and set error on failure 23 * source/cmt_project.cxx: In class Project function find_in_cmt_paths check 24 return value of CmtSystem::realpath_ and return on failure, do not test 25 existence of project cmt paths as they must exist 26 * source/cmt_symbol.cxx: In find_path_entry helper function, make use of 27 CmtSystem::realpath_ for paths comparison 28 1 29 2012-03-26 <rybkin@lal.in2p3.fr> 481 2 30 -
CMT/HEAD/source/cmt_awk.cxx
r569 r607 40 40 41 41 cmt_string line; 42 /* 42 43 int pos; 43 44 int max_pos; … … 45 46 pos = 0; 46 47 max_pos = text.size (); 47 48 */ 48 49 m_accumulator.erase (0); 49 50 51 int nl; 52 int begin = 0; 53 int end = text.size (); 54 55 while ((nl = text.find (begin, '\n')) != cmt_string::npos) 56 { 57 if (begin < nl && text[nl - 1] == '\r') 58 { 59 text.substr (begin, nl - 1 - begin, line); 60 } 61 else 62 { 63 text.substr (begin, nl - begin, line); 64 } 65 // cerr << "|Awk::condition parse> [" << line << "]" << endl; 66 begin = nl + 1; 67 if (m_awk != 0) m_awk->inc_line_number (); 68 69 result = parse_line (line); 70 if (result != Awk::ok) return result; 71 } // while ((nl = text.find (begin, '\n')) != cmt_string::npos) 72 73 if (begin < end) 74 { 75 text.substr (begin, end - begin, line); 76 if (m_awk != 0) m_awk->inc_line_number (); 77 78 result = parse_line (line); 79 } 80 81 /* 50 82 for (pos = 0; pos < max_pos;) 51 83 { … … 90 122 if (result != Awk::ok) break; 91 123 } 92 124 */ 93 125 return (result); 94 126 } … … 232 264 if (m_condition != ok) return (m_condition); 233 265 234 if (CmtSystem::testenv ("CMTTESTAWK")) 266 if (Cmt::get_debug () && 267 CmtSystem::testenv ("CMTTESTAWK")) 235 268 { 236 269 Parser p (this, pattern, 0); … … 242 275 { 243 276 cmt_string line; 277 int nl; 278 int begin = 0; 279 int end = text.size (); 280 281 while ((nl = text.find (begin, '\n')) != cmt_string::npos) 282 { 283 if (begin < nl && text[nl - 1] == '\r') 284 { 285 text.substr (begin, nl - 1 - begin, line); 286 } 287 else 288 { 289 text.substr (begin, nl - begin, line); 290 } 291 // cerr << "|Awk::condition run> [" << line << "]" << endl; 292 begin = nl + 1; 293 m_line_number++; 294 295 if (line != "") 296 { 297 if ((pattern == "") || 298 (line.find (pattern) != cmt_string::npos)) 299 { 300 filter (line); 301 if (m_condition != ok) return (m_condition); 302 } 303 } 304 } // while ((nl = text.find (begin, '\n')) != cmt_string::npos) 305 306 if (begin < end) 307 { 308 text.substr (begin, end - begin, line); 309 m_line_number++; 310 311 if (line != "") 312 { 313 if ((pattern == "") || 314 (line.find (pattern) != cmt_string::npos)) 315 { 316 filter (line); 317 if (m_condition != ok) return (m_condition); 318 } 319 } 320 } 321 /* 244 322 int pos = 0; 245 323 int max_pos; … … 315 393 } 316 394 } 395 */ 317 396 } 318 397 -
CMT/HEAD/source/cmt_parser.cxx
r603 r607 9684 9684 */ 9685 9685 9686 bool tag_debug = CmtSystem::testenv ("TAGDEBUG");9686 static bool tag_debug = CmtSystem::testenv ("TAGDEBUG"); 9687 9687 9688 9688 if (tag_debug) cerr << "set_standard_macro0> current_tag=" << Me.m_current_tag << endl; -
CMT/HEAD/source/cmt_pattern.cxx
r542 r607 192 192 add (name, words, start_index, global, use); 193 193 194 if (CmtSystem::testenv ("CMTTESTPATTERN")) 194 if (Cmt::get_debug () && 195 CmtSystem::testenv ("CMTTESTPATTERN")) 195 196 { 196 197 cerr << "Pattern::action> add " << name << endl; … … 736 737 expand (context_use, templates, replacement); 737 738 738 if (CmtSystem::testenv ("CMTTESTPATTERN")) 739 if (Cmt::get_debug () && 740 CmtSystem::testenv ("CMTTESTPATTERN")) 739 741 { 740 742 cerr << "Pattern::apply> replacement=[" << replacement << "]" << endl; … … 754 756 if (context_use == 0) context_use = &(Use::current ()); 755 757 756 if (CmtSystem::testenv ("CMTTESTPATTERN")) 758 if (Cmt::get_debug () && 759 CmtSystem::testenv ("CMTTESTPATTERN")) 757 760 { 758 761 cerr << "Pattern::expand1> line=[" << line << "]" << endl; … … 802 805 } 803 806 804 if (CmtSystem::testenv ("CMTTESTPATTERN")) 807 if (Cmt::get_debug () && 808 CmtSystem::testenv ("CMTTESTPATTERN")) 805 809 { 806 810 cerr << "Pattern::expand2> repl=[" << replacement << "]" << endl; … … 897 901 cmt_string s = words[i]; 898 902 899 if (CmtSystem::testenv ("CMTTESTPATTERN")) 903 if (Cmt::get_debug () && 904 CmtSystem::testenv ("CMTTESTPATTERN")) 900 905 { 901 906 cerr << "ApplyPattern::action> " << name << " s=[" << s << "] state=" << state << endl; … … 921 926 s.substr (pos + 1, tvalue); 922 927 923 if (CmtSystem::testenv ("CMTTESTPATTERN")) 928 if (Cmt::get_debug () && 929 CmtSystem::testenv ("CMTTESTPATTERN")) 924 930 { 925 931 cerr << "ApplyPattern::action-1> n=[" << tname << "] v=[" << tvalue << "]" << endl; … … 994 1000 s.substr (pos + 1, tvalue); 995 1001 996 if (CmtSystem::testenv ("CMTTESTPATTERN")) 1002 if (Cmt::get_debug () && 1003 CmtSystem::testenv ("CMTTESTPATTERN")) 997 1004 { 998 1005 cerr << "ApplyPattern::action-2> n=[" << tname << "] v=[" << tvalue << "]" << endl; … … 1016 1023 state = need_template; 1017 1024 1018 if (CmtSystem::testenv ("CMTTESTPATTERN")) 1025 if (Cmt::get_debug () && 1026 CmtSystem::testenv ("CMTTESTPATTERN")) 1019 1027 { 1020 1028 cerr << "ApplyPattern::action-3> n=[" << tname << "] v=[" << tvalue << "]" << endl; … … 1109 1117 void ApplyPattern::apply () const 1110 1118 { 1111 if (CmtSystem::testenv ("CMTTESTPATTERN")) 1119 if (Cmt::get_debug () && 1120 CmtSystem::testenv ("CMTTESTPATTERN")) 1112 1121 { 1113 1122 cerr << "ApplyPattern::apply> " << name << endl; … … 1117 1126 if (p == 0) 1118 1127 { 1119 if (CmtSystem::testenv ("CMTTESTPATTERN")) 1128 if (Cmt::get_debug () && 1129 CmtSystem::testenv ("CMTTESTPATTERN")) 1120 1130 { 1121 1131 cerr << "ApplyPattern::apply> " << name << " not found" << endl; -
CMT/HEAD/source/cmt_project.cxx
r581 r607 1657 1657 cmt_string path_real; 1658 1658 //cerr << "realpath_: find_in_cmt_paths" << endl; 1659 CmtSystem::realpath_ (path, path_real); 1659 if (!CmtSystem::realpath_ (path, path_real)) 1660 return (""); 1660 1661 1661 1662 static ProjectVector& Projects = projects (); … … 1672 1673 if (s == "default path") continue; 1673 1674 1674 if (CmtSystem::test_directory (p)) 1675 // MUST be directory if project added 1676 // if (CmtSystem::test_directory (p)) 1675 1677 { 1676 1678 // if (path.find (p) != cmt_string::npos) … … 1693 1695 if (p == w) continue; 1694 1696 1695 if (CmtSystem::test_directory (w)) 1697 // MUST be directory if project added 1698 // if (CmtSystem::test_directory (w)) 1696 1699 { 1697 1700 if (path.find (w) != cmt_string::npos) -
CMT/HEAD/source/cmt_regexp.cxx
r581 r607 10 10 #include "cmt_system.h" 11 11 12 #include "cmt.h" 12 13 //---------------------------------------------------------- 13 14 // … … 987 988 int p = pos; 988 989 989 bool dbg = CmtSystem::testenv ("CMTTESTREGEXP"); 990 bool dbg = false; 991 if (Cmt::get_debug ()) dbg = CmtSystem::testenv ("CMTTESTREGEXP"); 990 992 991 993 if (dbg) {tab (); cerr << "match and (" << this << ") pos=" << pos << endl;} … … 1115 1117 if (_nodes.size () == 0) return (cmt_regexp::iterator (pos, 0)); 1116 1118 1117 bool dbg = CmtSystem::testenv ("CMTTESTREGEXP"); 1119 bool dbg = false; 1120 if (Cmt::get_debug ()) dbg = CmtSystem::testenv ("CMTTESTREGEXP"); 1118 1121 1119 1122 if (dbg) {tab (); cerr << "match or (" << this << ") pos=" << pos << endl;} … … 1562 1565 _root = or_root; 1563 1566 1564 bool dbg = CmtSystem::testenv ("CMTTESTREGEXP"); 1567 bool dbg = false; 1568 if (Cmt::get_debug ()) dbg = CmtSystem::testenv ("CMTTESTREGEXP"); 1565 1569 1566 1570 if (dbg) -
CMT/HEAD/source/cmt_string.cxx
r527 r607 244 244 void cmt_string::resize (int n) 245 245 { 246 _size = n; 246 247 allocate (n + 1); 248 _data[n] = 0; 247 249 } 248 250 … … 544 546 if ((_data == 0) || 545 547 (pos < 0) || 546 (pos >= _size)) 548 (pos >= _size) || 549 length == 0) 547 550 { 548 551 return ((cmt_string) ""); … … 550 553 else 551 554 { 555 // cerr << "|cmt_string::substr>: `" << *this << "' pos: " << pos << " length: " << length; 556 557 if ((pos + length) >= _size || 558 length < 0) 559 { 560 // cmt_string result (&_data[pos]); 561 //cerr << " |---> `" << result << "'" << endl; 562 // return (result); 563 return (&_data[pos]); 564 } 565 else 566 { 567 cmt_string result; 568 result.resize (length); 569 for (int i = 0; i < length; i++) 570 result[i] = _data[pos + i]; 571 //cerr << " |---> `" << result << "'" << endl; 572 return (result); 573 } 574 575 /* 552 576 cmt_string result (&_data[pos]); 553 577 result.erase (length); 578 cerr << " |---> `" << result << "'" << endl; 554 579 return (result); 580 */ 555 581 } 556 582 } … … 574 600 if ((_data == 0) || 575 601 (pos < 0) || 576 (pos >= _size)) 602 (pos >= _size) || 603 length == 0) 577 604 { 578 605 dest = ""; … … 580 607 else 581 608 { 609 // cerr << "|void cmt_string::substr>: `" << *this << "' pos: " << pos << " length: " << length; 610 611 if ((pos + length) >= _size || 612 length < 0) 613 { 614 dest = (const char*) &_data[pos]; 615 } 616 else 617 { 618 dest.resize (length); 619 for (int i = 0; i < length; i++) 620 dest[i] = _data[pos + i]; 621 } 622 623 /* 582 624 dest = (const char*) &_data[pos]; 583 625 dest.erase (length); 626 */ 627 // cerr << " |---> `" << dest << "'" << endl; 584 628 } 585 629 } -
CMT/HEAD/source/cmt_symbol.cxx
r603 r607 2224 2224 static const cmt_string path_separator = CmtSystem::path_separator (); 2225 2225 2226 cmt_string here = CmtSystem::pwd ();2226 // cmt_string here = CmtSystem::pwd (); 2227 2227 cmt_string rvalue = value; 2228 2228 2229 /* 2229 2230 if (CmtSystem::cd (value)) 2230 2231 { … … 2232 2233 } 2233 2234 else 2235 */ 2236 if (!CmtSystem::realpath_ (value, rvalue)) 2234 2237 { 2235 2238 CmtSystem::compress_path (rvalue); … … 2245 2248 const cmt_string& item = items[i]; 2246 2249 cmt_string ritem = item; 2250 /* 2247 2251 if (CmtSystem::cd (item)) 2248 2252 { … … 2250 2254 } 2251 2255 else 2256 */ 2257 if (!CmtSystem::realpath_ (item, ritem)) 2252 2258 { 2253 2259 CmtSystem::compress_path (ritem); … … 2261 2267 } 2262 2268 2263 CmtSystem::cd (here);2269 // CmtSystem::cd (here); 2264 2270 return (found); 2265 2271 } -
CMT/HEAD/source/cmt_syntax.cxx
r568 r607 1682 1682 } 1683 1683 1684 text.read (actual_file_name); 1684 if (!text.read (actual_file_name)) 1685 { 1686 CmtError::set (CmtError::file_access_error, actual_file_name); 1687 return; 1688 } 1685 1689 1686 1690 SyntaxParser::parse_requirements_text (text, actual_file_name, use); … … 1694 1698 * Each reformatted line is parsed by filter_line 1695 1699 */ 1700 void SyntaxParser::do_parse_text (const cmt_string& text, 1701 const cmt_string& file_name, 1702 ContextType context, 1703 Use* use, 1704 Project* project) 1705 { 1706 cmt_string line; 1707 int line_number = 1; 1708 1709 if (context == package_context) 1710 { 1711 if (use == 0) use = &(Use::current ()); 1712 } 1713 1714 m_filtered_text.erase (0); 1715 1716 int nl; 1717 int begin = 0; 1718 int end = text.size (); 1719 1720 while ((nl = text.find (begin, '\n')) != cmt_string::npos) 1721 { 1722 if (begin < nl && text[nl - 1] == '\r') 1723 { 1724 text.substr (begin, nl - 1 - begin, line); 1725 } 1726 else 1727 { 1728 text.substr (begin, nl - begin, line); 1729 } 1730 // cerr << "|do_parse_text> [" << line << "]" << endl; 1731 do_parse_line (line, file_name, line_number, context, use, project); 1732 line_number++; 1733 begin = nl + 1; 1734 } // while ((nl = text.find (begin, '\n')) != cmt_string::npos) 1735 1736 if (begin < end) 1737 { 1738 text.substr (begin, end - begin, line); 1739 do_parse_line (line, file_name, line_number, context, use, project); 1740 } 1741 1742 } 1743 /* 1696 1744 void SyntaxParser::do_parse_text (const cmt_string& text, 1697 1745 const cmt_string& file_name, … … 1762 1810 } 1763 1811 } 1812 */ 1764 1813 1765 1814 void SyntaxParser::do_parse_line (const cmt_string& line, … … 1794 1843 bool finished = true; 1795 1844 1796 length = temp_line.size ();1845 // length = temp_line.size (); 1797 1846 1798 1847 back_slash = temp_line.find_last_of ('\\'); -
CMT/HEAD/source/cmt_system.cxx
r599 r607 334 334 } 335 335 336 //-------------------------------------------------- 337 bool CmtSystem::realpath_ (const cmt_string& path, cmt_string& result) 338 { 339 char buffer[PATH_MAX + 1]; 340 #ifndef WIN32 341 if (::realpath (path, buffer)) 342 { 343 result = buffer; 344 // cerr << "path: " << path << " result: " << result << endl; 345 return true; 346 } 347 else 348 { 349 // cerr << "path: " << path << " result: " << result << endl; 350 if (errno != ENOENT 351 && errno != ENOTDIR 352 ) 353 { 354 perror ("cmt: realpath failure: " + get_absolute_path (path)); 355 } 356 return false; 357 } 358 #else 359 if (::_fullpath (buffer, path, PATH_MAX + 1)) 360 { 361 result = buffer; 362 return true; 363 } 364 else 365 { 366 return false; 367 } 368 #endif 369 } 370 371 /* 336 372 //-------------------------------------------------- 337 373 bool CmtSystem::realpath_ (const cmt_string& path, cmt_string& result) … … 359 395 return false; 360 396 } 361 397 */ 362 398 //-------------------------------------------------- 363 399 bool CmtSystem::absolute_path (const cmt_string& name) -
CMT/HEAD/source/cmt_use.cxx
r597 r607 3574 3574 // offset.replace (cmtpath, empty_string); 3575 3575 //cerr << "realpath_: get_cmtpath_and_offset" << endl; 3576 CmtSystem::realpath_ (real_path, offset); 3576 if (!CmtSystem::realpath_ (real_path, offset)) 3577 { 3578 CmtError::set (CmtError::file_access_error, "Cannot compute real path `" + 3579 real_path + "'"); 3580 CmtError::print (); 3581 return; 3582 } 3577 3583 offset.replace (p->get_cmtpath_real (), empty_string); 3578 3584
Note: See TracChangeset
for help on using the changeset viewer.