- Timestamp:
- Nov 20, 2009, 10:45:54 AM (15 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r526 r527 1 2009-11-20 <rybkin@lal.in2p3.fr> 414 2 3 * source/cmt_system.h: In class CmtSystem, introduce functions 4 close_ostream, close_stdout in order check whether there are file write 5 errors, and exit with an error if that is the case 6 * source/cmt_system.cxx: Implement introduced functions, in function 7 CmtSystem::compare_and_update_files, check file stream status 8 * source/cmt_generators.cxx: Set file_access_error error if file cannot be 9 opened for writing, close file streams on writing making use of 10 close_ostream 11 * source/cmt_generator.cxx: idem 12 * source/cmt_parser.cxx: idem, in setup.[c]sh, cleanup.[c]sh scripts, check 13 CMT command exit status, on failure, print the command and exit, 14 for "cmt filter" command, set path_not_found error, when appropriate 15 * source/cmt.cxx: Close stdout with CmtSystem::close_stdout before exiting 16 the program 17 * source/cmt_string.cxx: In function cmt_string::write, check file stream 18 status 19 * src/Makefile.header: Improve a diagnostic message by using the standard 20 macros 21 * mgr/cmt_dependencies.make: Update 22 1 23 2009-11-13 <rybkin@lal.in2p3.fr> 413 2 24 -
CMT/HEAD/mgr/cmt_dependencies.make
r496 r527 29 29 cmt_cmtpath_pattern_cxx_dependencies = ../source/cmt_cmtpath_pattern.cxx ../source/cmt_vector.h ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_parser.h ../source/cmt_branch.h ../source/cmt_fragment.h ../source/cmt_group.h ../source/cmt_constituent.h ../source/cmt_language.h ../source/cmt_map.h ../source/cmt_pattern.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_awk.h ../source/cmt_project.h ../source/cmt_cmtpath_pattern.h ../source/cmt_database.h ../source/cmt_syntax.h 30 30 cmt_sequence_cxx_dependencies = ../source/cmt_sequence.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_regexp.h ../source/cmt_awk.h ../source/cmt_sequence.h ../source/cmt_vector.h ../source/cmt_system.h 31 cmt_generators_cxx_dependencies = ../source/cmt_generators.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_parser.h ../source/cmt_fragment.h ../source/cmt_group.h ../source/cmt_constituent.h ../source/cmt_language.h ../source/cmt_awk.h ../source/cmt_map.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_pattern.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_deps_builder.h ../source/cmt_generator.h ../source/cmt_generators.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_log.h 31 cmt_generators_cxx_dependencies = ../source/cmt_generators.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_parser.h ../source/cmt_fragment.h ../source/cmt_group.h ../source/cmt_constituent.h ../source/cmt_language.h ../source/cmt_awk.h ../source/cmt_map.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_pattern.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_deps_builder.h ../source/cmt_generator.h ../source/cmt_generators.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_log.h ../source/cmt_error.h 32 32 cmt_scope_section_cxx_dependencies = ../source/cmt_scope_section.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_parser.h ../source/cmt_scope_section.h 33 33 cmt_log_cxx_dependencies = ../source/cmt_log.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_log.h ../source/cmt_vector.h ../source/cmt_parser.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h -
CMT/HEAD/source/cmt.cxx
r400 r527 22 22 } 23 23 24 CmtSystem::close_stdout (); 25 24 26 return (status); 25 27 } -
CMT/HEAD/source/cmt_generator.cxx
r488 r527 312 312 void CmtGenerator::terminate () 313 313 { 314 fclose (m_output_file); 314 CmtSystem::close_ostream (m_output_file, m_output_file_name); 315 // fclose (m_output_file); 315 316 316 317 //--- Complete the operation -------------- -
CMT/HEAD/source/cmt_generators.cxx
r488 r527 10 10 #include "cmt_symbol.h" 11 11 #include "cmt_log.h" 12 #include "cmt_error.h" 12 13 #include <assert.h> 13 14 … … 1324 1325 terminate (); 1325 1326 } 1327 else 1328 { 1329 CmtError::set (CmtError::file_access_error, m_output_file_name); 1330 } 1326 1331 } 1327 1332 … … 1557 1562 */ 1558 1563 s.write (file); 1559 fclose (file); 1564 CmtSystem::close_ostream (file, backup); 1565 // fclose (file); 1560 1566 1561 1567 need_makefile = true; 1562 1568 } 1569 else 1570 { 1571 CmtError::set (CmtError::file_access_error, backup); 1572 } 1563 1573 } 1564 1574 } … … 1570 1580 if (file != NULL) 1571 1581 { 1572 fprintf (file, "include $(CMTROOT)/src/Makefile.header\n"); 1573 fprintf (file, "\n"); 1574 fprintf (file, "include $(CMTROOT)/src/constituents.make\n"); 1575 fprintf (file, "\n"); 1576 fclose (file); 1577 } 1582 fprintf (file, 1583 "include $(CMTROOT)/src/Makefile.header\n" 1584 "\n" 1585 "include $(CMTROOT)/src/constituents.make\n" 1586 "\n"); 1587 CmtSystem::close_ostream (file, makefile); 1588 // fclose (file); 1589 } 1590 else 1591 { 1592 CmtError::set (CmtError::file_access_error, makefile); 1593 } 1578 1594 } 1579 1595 … … 1594 1610 if (file != NULL) 1595 1611 { 1596 fprintf (file, "!include $(CMTROOT)\\src\\NMakefile.header\n"); 1597 fprintf (file, "\n"); 1598 fprintf (file, "!include $(CMTROOT)\\src\\constituents.nmake\n"); 1599 fprintf (file, "\n"); 1600 fclose (file); 1601 } 1612 fprintf (file, 1613 "!include $(CMTROOT)\\src\\NMakefile.header\n" 1614 "\n" 1615 "!include $(CMTROOT)\\src\\constituents.nmake\n" 1616 "\n"); 1617 CmtSystem::close_ostream (file, makefile); 1618 // fclose (file); 1619 } 1620 else 1621 { 1622 CmtError::set (CmtError::file_access_error, makefile); 1623 } 1602 1624 } 1603 1625 … … 1747 1769 terminate (); 1748 1770 } 1771 else 1772 { 1773 CmtError::set (CmtError::file_access_error, m_output_file_name); 1774 } 1749 1775 1750 1776 m_output_file_name = msdevdir + "all.dspnew"; … … 1755 1781 dsp_all_fragment.wincopy (m_output_file, 1, &m_PACKAGE); 1756 1782 terminate (); 1783 } 1784 else 1785 { 1786 CmtError::set (CmtError::file_access_error, m_output_file_name); 1757 1787 } 1758 1788 … … 2429 2459 make_setup_fragment.copy (m_output_file, 1, &m_PACKAGE); 2430 2460 2431 fclose (m_output_file); 2461 CmtSystem::close_ostream (m_output_file, new_file_name); 2462 // fclose (m_output_file); 2432 2463 2433 2464 //--- Complete the operation -------------- 2434 2465 2435 2466 commit (new_file_name); 2467 } 2468 else 2469 { 2470 CmtError::set (CmtError::file_access_error, new_file_name); 2436 2471 } 2437 2472 … … 2637 2672 constituents_trailer_fragment.copy (m_output_file, 0); 2638 2673 2639 fclose (m_output_file); 2674 CmtSystem::close_ostream (m_output_file, new_file_name); 2675 // fclose (m_output_file); 2640 2676 2641 2677 commit (new_file_name); 2678 } 2679 else 2680 { 2681 CmtError::set (CmtError::file_access_error, new_file_name); 2642 2682 } 2643 2683 } … … 2967 3007 FILE* f = fopen (m_output_file_name.c_str (), "wb"); 2968 3008 2969 if (f == 0) 2970 { 2971 CmtMessage::error ("Cannot open " + m_output_file_name + " for write"); 2972 // cerr << "Cannot open " << m_output_file_name << " for write" << endl; 3009 if (f != 0) 3010 { 3011 dependencies.write (f); 3012 CmtSystem::close_ostream (f, m_output_file_name); 3013 // fclose (f); 2973 3014 } 2974 3015 else 2975 3016 { 2976 dependencies.write (f);2977 fclose (f);3017 CmtError::set (CmtError::file_access_error, m_output_file_name); 3018 // CmtMessage::error ("Cannot open " + m_output_file_name + " for write"); 2978 3019 } 2979 3020 -
CMT/HEAD/source/cmt_parser.cxx
r525 r527 2505 2505 // configure_current_package (); 2506 2506 2507 Generator::build_default_makefile ();2507 // Generator::build_default_makefile (); 2508 2508 2509 2509 CmtSystem::cmt_string_vector makes; … … 2581 2581 install_cleanup_scripts (); 2582 2582 install_native_version_file (); 2583 2584 Generator::build_default_makefile (); 2583 2585 2584 2586 CmtSystem::cd (".."); … … 3199 3201 if (!CmtSystem::test_file (input)) 3200 3202 { 3201 Cmt Message::error ("File " + input + " not found");3202 // cerr << "#CMT> File " << input << " not found" << endl;3203 CmtError::set (CmtError::path_not_found, input); 3204 // CmtMessage::error ("File " + input + " not found"); 3203 3205 return; 3204 3206 } … … 3213 3215 3214 3216 FILE* file = fopen (output, "wb"); 3215 if (file == NULL) 3216 { 3217 CmtMessage::error ("Cannot write filtered file " + output); 3218 // cerr << "#CMT> Cannot write filtered file " << output << endl; 3217 if (file != NULL) 3218 { 3219 text.write (file); 3220 CmtSystem::close_ostream (file, output); 3221 // fclose (file); 3219 3222 } 3220 3223 else 3221 3224 { 3222 text.write (file);3223 fclose (file);3225 CmtError::set (CmtError::file_access_error, output); 3226 // CmtMessage::error ("Cannot write filtered file " + output); 3224 3227 } 3225 3228 } … … 4812 4815 fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n"); 4813 4816 fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s " 4814 "-pack=%s -version=%s -path=%s $* >${tempfile}; " 4815 "source ${tempfile}\n", 4817 "-pack=%s -version=%s -path=%s $* >${tempfile}\n", 4816 4818 suffix[i].c_str (), 4817 4819 Me.m_current_package.c_str (), 4818 4820 version.c_str (), 4819 4821 Me.m_current_path.c_str ()); 4820 fprintf (f, "/bin/rm -f ${tempfile}\n"); 4822 fprintf (f, 4823 "if ( $status == 0 ) then\n" 4824 " source ${tempfile}\n" 4825 " /bin/rm -f ${tempfile}\n" 4826 "else\n" 4827 " echo \"${CMTROOT}/mgr/cmt cleanup -%s " 4828 "-pack=%s -version=%s -path=%s $* >${tempfile}\"\n" 4829 " /bin/rm -f ${tempfile}\n" 4830 " false\n" 4831 "endif\n", 4832 suffix[i].c_str (), 4833 Me.m_current_package.c_str (), 4834 version.c_str (), 4835 Me.m_current_path.c_str ()); 4821 4836 } 4822 4837 else if (mode[i] == Sh) … … 4829 4844 fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n"); 4830 4845 fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s " 4831 "-pack=%s -version=%s -path=%s $* >${tempfile}; " 4832 ". ${tempfile}\n", 4846 "-pack=%s -version=%s -path=%s $* >${tempfile}\n", 4833 4847 suffix[i].c_str (), 4834 4848 Me.m_current_package.c_str (), 4835 4849 version.c_str (), 4836 4850 Me.m_current_path.c_str ()); 4837 fprintf (f, "/bin/rm -f ${tempfile}\n"); 4851 fprintf (f, 4852 "if test $? = 0 ; then\n" 4853 " . ${tempfile}\n" 4854 " /bin/rm -f ${tempfile}\n" 4855 "else\n" 4856 " echo >&2 \"${CMTROOT}/mgr/cmt cleanup -%s " 4857 "-pack=%s -version=%s -path=%s $* >${tempfile}\"\n" 4858 " /bin/rm -f ${tempfile}\n" 4859 " false\n" 4860 "fi\n", 4861 suffix[i].c_str (), 4862 Me.m_current_package.c_str (), 4863 version.c_str (), 4864 Me.m_current_path.c_str ()); 4838 4865 } 4839 4866 else if (mode[i] == Bat) … … 4846 4873 fprintf (f, "\n"); 4847 4874 4848 fclose (f); 4875 CmtSystem::close_ostream (f, file_name); 4876 // fclose (f); 4849 4877 4850 4878 cmt_string old_file_name = "cleanup"; … … 4854 4882 CmtSystem::compare_and_update_files (file_name, old_file_name); 4855 4883 } 4884 else 4885 { 4886 CmtError::set (CmtError::file_access_error, file_name); 4887 } 4856 4888 } 4857 4889 } … … 4932 4964 fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n"); 4933 4965 fprintf (f, "${CMTROOT}/mgr/cmt setup -%s " 4934 "-pack=%s -version=%s -path=%s %s $* >${tempfile}; " 4935 "source ${tempfile}\n", 4966 "-pack=%s -version=%s -path=%s %s $* >${tempfile}\n", 4936 4967 suffix[i].c_str (), 4937 4968 Me.m_current_package.c_str (), … … 4939 4970 Me.m_current_path.c_str (), 4940 4971 no_cleanup_opt.c_str ()); 4941 fprintf (f, "/bin/rm -f ${tempfile}\n"); 4972 fprintf (f, 4973 "if ( $status == 0 ) then\n" 4974 " source ${tempfile}\n" 4975 " /bin/rm -f ${tempfile}\n" 4976 "else\n" 4977 " echo \"${CMTROOT}/mgr/cmt setup -%s " 4978 "-pack=%s -version=%s -path=%s %s $* >${tempfile}\"\n" 4979 " /bin/rm -f ${tempfile}\n" 4980 " false\n" 4981 "endif\n", 4982 suffix[i].c_str (), 4983 Me.m_current_package.c_str (), 4984 version.c_str (), 4985 Me.m_current_path.c_str (), 4986 no_cleanup_opt.c_str ()); 4942 4987 } 4943 4988 else if (mode[i] == Sh) … … 4957 5002 fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n"); 4958 5003 fprintf (f, "${CMTROOT}/mgr/cmt setup -%s " 4959 "-pack=%s -version=%s -path=%s %s $* >${tempfile}; " 4960 ". ${tempfile}\n", 5004 "-pack=%s -version=%s -path=%s %s $* >${tempfile}\n", 4961 5005 suffix[i].c_str (), 4962 5006 Me.m_current_package.c_str (), … … 4964 5008 Me.m_current_path.c_str (), 4965 5009 no_cleanup_opt.c_str ()); 4966 fprintf (f, "/bin/rm -f ${tempfile}\n"); 5010 fprintf (f, 5011 "if test $? = 0 ; then\n" 5012 " . ${tempfile}\n" 5013 " /bin/rm -f ${tempfile}\n" 5014 "else\n" 5015 " echo >&2 \"${CMTROOT}/mgr/cmt setup -%s " 5016 "-pack=%s -version=%s -path=%s %s $* >${tempfile}\"\n" 5017 " /bin/rm -f ${tempfile}\n" 5018 " false\n" 5019 "fi\n", 5020 suffix[i].c_str (), 5021 Me.m_current_package.c_str (), 5022 version.c_str (), 5023 Me.m_current_path.c_str (), 5024 no_cleanup_opt.c_str ()); 4967 5025 } 4968 5026 else if (mode[i] == Bat) … … 4978 5036 fprintf (f, "\n"); 4979 5037 4980 fclose (f); 5038 CmtSystem::close_ostream (f, file_name); 5039 // fclose (f); 4981 5040 4982 5041 cmt_string old_file_name = "setup"; … … 4986 5045 CmtSystem::compare_and_update_files (file_name, old_file_name); 4987 5046 } 5047 else 5048 { 5049 CmtError::set (CmtError::file_access_error, file_name); 5050 } 4988 5051 } 4989 5052 } … … 5049 5112 fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n"); 5050 5113 fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n"); 5051 fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}; " 5052 "source ${tempfile}\n", 5114 fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}\n", 5053 5115 suffix[i].c_str (), 5054 5116 Me.m_current_path.c_str ()); 5055 fprintf (f, "/bin/rm -f ${tempfile}\n"); 5117 fprintf (f, 5118 "if ( $status == 0 ) then\n" 5119 " source ${tempfile}\n" 5120 " /bin/rm -f ${tempfile}\n" 5121 "else\n" 5122 " echo \"${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}\"\n" 5123 " /bin/rm -f ${tempfile}\n" 5124 " false\n" 5125 "endif\n", 5126 suffix[i].c_str (), 5127 Me.m_current_path.c_str ()); 5056 5128 } 5057 5129 else if (mode[i] == Sh) … … 5063 5135 fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n"); 5064 5136 fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n"); 5065 fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}; " 5066 ". ${tempfile}\n", 5137 fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}\n", 5067 5138 suffix[i].c_str (), 5068 5139 Me.m_current_path.c_str ()); 5069 fprintf (f, "/bin/rm -f ${tempfile}\n"); 5140 fprintf (f, 5141 "if test $? = 0 ; then\n" 5142 " . ${tempfile}\n" 5143 " /bin/rm -f ${tempfile}\n" 5144 "else\n" 5145 " echo >&2 \"${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}\"\n" 5146 " /bin/rm -f ${tempfile}\n" 5147 " false\n" 5148 "fi\n", 5149 suffix[i].c_str (), 5150 Me.m_current_path.c_str ()); 5070 5151 } 5071 5152 else … … 5078 5159 fprintf (f, "\n"); 5079 5160 5080 fclose (f); 5161 CmtSystem::close_ostream (f, file_name); 5162 // fclose (f); 5081 5163 5082 5164 cmt_string old_file_name = "cleanup"; … … 5086 5168 CmtSystem::compare_and_update_files (file_name, old_file_name); 5087 5169 } 5170 else 5171 { 5172 CmtError::set (CmtError::file_access_error, file_name); 5173 } 5088 5174 } 5089 5175 } … … 5104 5190 cerr << "Creating native_version file." << endl; 5105 5191 5106 FILE* f = fopen ("new.native_version.cmt", "wb");5107 5192 cmt_string file_name ("new.native_version.cmt"); 5193 FILE* f = fopen (file_name.c_str (), "wb"); 5108 5194 if (f != NULL) 5109 5195 { 5110 5196 fprintf (f, "%s\n", value.c_str ()); 5197 CmtSystem::close_ostream (f, file_name); 5198 // fclose (f); 5199 5200 CmtSystem::compare_and_update_files ("new.native_version.cmt", "native_version.cmt"); 5111 5201 } 5112 5113 fclose (f);5114 5115 CmtSystem::compare_and_update_files ("new.native_version.cmt", "native_version.cmt");5202 else 5203 { 5204 CmtError::set (CmtError::file_access_error, file_name); 5205 } 5116 5206 } 5117 5207 } … … 5184 5274 fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n"); 5185 5275 fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n"); 5186 fprintf (f, "${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}; " 5187 "source ${tempfile}\n", 5276 fprintf (f, "${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}\n", 5188 5277 suffix[i].c_str (), 5189 5278 Me.m_current_path.c_str (), 5190 5279 no_cleanup_opt.c_str ()); 5191 fprintf (f, "/bin/rm -f ${tempfile}\n"); 5280 fprintf (f, 5281 "if ( $status == 0 ) then\n" 5282 " source ${tempfile}\n" 5283 " /bin/rm -f ${tempfile}\n" 5284 "else\n" 5285 " echo \"${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}\"\n" 5286 " /bin/rm -f ${tempfile}\n" 5287 " false\n" 5288 "endif\n", 5289 suffix[i].c_str (), 5290 Me.m_current_path.c_str (), 5291 no_cleanup_opt.c_str ()); 5192 5292 } 5193 5293 else if (mode[i] == Sh) … … 5203 5303 fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n"); 5204 5304 fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n"); 5205 fprintf (f, "${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}; " 5206 ". ${tempfile}\n", 5305 fprintf (f, "${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}\n", 5207 5306 suffix[i].c_str (), 5208 5307 Me.m_current_path.c_str (), 5209 5308 no_cleanup_opt.c_str ()); 5210 fprintf (f, "/bin/rm -f ${tempfile}\n"); 5309 fprintf (f, 5310 "if test $? = 0 ; then\n" 5311 " . ${tempfile}\n" 5312 " /bin/rm -f ${tempfile}\n" 5313 "else\n" 5314 " echo >&2 \"${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}\"\n" 5315 " /bin/rm -f ${tempfile}\n" 5316 " false\n" 5317 "fi\n", 5318 suffix[i].c_str (), 5319 Me.m_current_path.c_str (), 5320 no_cleanup_opt.c_str ()); 5211 5321 } 5212 5322 else … … 5220 5330 fprintf (f, "\n"); 5221 5331 5222 fclose (f); 5332 CmtSystem::close_ostream (f, file_name); 5333 // fclose (f); 5223 5334 5224 5335 cmt_string old_file_name = "setup"; … … 5228 5339 CmtSystem::compare_and_update_files (file_name, old_file_name); 5229 5340 } 5341 else 5342 { 5343 CmtError::set (CmtError::file_access_error, file_name); 5344 } 5230 5345 } 5231 5346 } … … 5623 5738 { 5624 5739 int code = CmtError::get_last_error_code (); 5625 if (!Me.m_quiet) CmtError::print (); 5740 CmtError::print (); 5741 // if (!Me.m_quiet) CmtError::print (); 5626 5742 clear (); 5627 5743 … … 6396 6512 } 6397 6513 6398 if (!Me.m_quiet) CmtError::print (); 6514 CmtError::print (); 6515 // if (!Me.m_quiet) CmtError::print (); 6399 6516 clear (); 6400 6517 return (code); -
CMT/HEAD/source/cmt_string.cxx
r11 r527 759 759 { 760 760 write (f); 761 fclose (f); 761 if (ferror (f)) 762 return (false); 763 if (fclose (f)) 764 return (false); 762 765 return (true); 763 766 } -
CMT/HEAD/source/cmt_system.cxx
r515 r527 528 528 { 529 529 s1.write (f); 530 fclose (f); 530 if (ferror (f)) 531 return (false); 532 if (fclose (f)) 533 return (false); 531 534 532 535 unlink (name1); … … 2419 2422 } 2420 2423 2421 2422 2423 2424 //---------------------------------------------------------- 2425 void CmtSystem::close_ostream (FILE *stream, const cmt_string& name) 2426 { 2427 cmt_string msg ("Cannot write"); 2428 cmt_string n = (name != "") ? " " + name : ""; 2429 if (stream == NULL) 2430 { 2431 CmtMessage::error (msg + n); 2432 exit (EXIT_FAILURE); 2433 } 2434 2435 bool prev_fail = ferror (stream); 2436 bool fclose_fail = fclose (stream); 2437 2438 if (prev_fail || fclose_fail) 2439 { 2440 int err = fclose_fail ? errno : 0; 2441 cmt_string e = err ? ": " + cmt_string (strerror (err)) : ""; 2442 CmtMessage::error (msg + n + e); 2443 exit (EXIT_FAILURE); 2444 } 2445 } 2446 2447 //---------------------------------------------------------- 2448 void CmtSystem::close_stdout (void) 2449 { 2450 /* 2451 * The idea and, to some extent, implementation of this function 2452 * was borrowed from the GNU core utilities of the Free Software Foundation 2453 * http://www.gnu.org/software/coreutils/ 2454 */ 2455 close_ostream (stdout, "stdout"); 2456 } 2424 2457 2425 2458 //---------------------------------------------------------- -
CMT/HEAD/source/cmt_system.h
r435 r527 145 145 static cmt_string get_makefile_suffix (); 146 146 147 static void close_ostream (FILE *stream, const cmt_string& name = "" ); 148 static void close_stdout (void); 149 147 150 }; 148 151 -
CMT/HEAD/src/Makefile.header
r487 r527 79 79 retval=$$?; \ 80 80 if test $${retval} != 0; then \ 81 echo "#CMT> Error: $@: Cannot generate" >&2; \ 82 /bin/rm -f $@; fi; \ 81 test -z "$(cmtmsg)" || \ 82 echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot generate $@" >&2; \ 83 \rm -f $@; \ 84 fi; \ 83 85 exit $${retval} 84 86
Note: See TracChangeset
for help on using the changeset viewer.