Changeset 234 for trunk/lib/File.cc
- Timestamp:
- Apr 9, 2007, 2:08:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/File.cc
r232 r234 26 26 #include "html_utility.h" 27 27 #include "Stats.h" 28 #include "SVN .h"28 #include "SVNlog.h" 29 29 30 30 #include <cassert> … … 66 66 std::string html_name(outpath + ".html"); 67 67 std::ofstream os(html_name.c_str()); 68 print_header(os, name(), level_+2, line_type, local_path()+".html");68 print_header(os, name(), level_+2, user, line_type, local_path()+".html"); 69 69 path_anchor(os); 70 70 os << "<p align=center>\n<img src='" … … 72 72 << "' alt='[plot]' border=0>\n</p>"; 73 73 74 os << "<table class=\"listings\">\n"; 75 os << "<thead>"; 76 os << "<tr>\n"; 77 os << "<th>Author</th>\n"; 78 os << "<th>Lines</th>\n"; 79 os << "<th>Code</th>\n"; 80 os << "<th>Comments</th>\n"; 81 os << "</tr>\n</thead>\n"; 82 os << "<tbody>"; 83 84 bool dark=false; 85 os << "<tr class=\"light\">\n"; 86 os << "<td class=\"directory\" colspan=\"5\">"; 87 anchor(os, "index.html", "../"); 88 os << "</td>\n</tr>\n"; 89 dark=!dark; 90 91 // print authors 92 for (std::set<std::string>::const_iterator i=stats_.authors().begin(); 93 i!=stats_.authors().end(); ++i){ 94 if (dark) 95 os << "<tr class=\"dark\"><td>" << *i 96 << "</td><td>" << stats_.lines(*i) 97 << "</td><td>" << stats_.code(*i) 98 << "</td><td>" << stats_.comments(*i) 99 << "</td></tr>\n"; 100 else 101 os << "<tr class=\"light\"><td>" << *i 102 << "</td><td>" << stats_.lines(*i) 103 << "</td><td>" << stats_.code(*i) 104 << "</td><td>" << stats_.comments(*i) 105 << "</td></tr>\n"; 106 dark=!dark; 107 } 108 if (dark) 109 os << "<tr class=\"dark\">\n"; 110 else 111 os << "<tr class=\"light\">\n"; 112 os << "<td>Total</td>\n"; 113 os << "<td>" << stats_.lines() << "</td>\n"; 114 os << "<td>" << stats_.code() << "</td>\n"; 115 os << "<td>" << stats_.comments() << "</td>\n"; 116 os << "</tr>\n"; 117 os << "</table>\n"; 74 print_author_summary(os); 118 75 os << "</p>\n"; 119 76 … … 154 111 155 112 156 void File::print_copyright 157 (const std::vector<std::string>& dates, 158 const std::vector<std::string>& authors, 159 std::map<std::string, std::string>& alias) const 160 { 113 void File::print_copyright (std::map<std::string,std::string>& alias) const{ 161 114 if (ignore()) 162 115 return; 163 assert(dates.size()==authors.size());164 116 using namespace std; 165 SVN* svn=SVN::instance(); 166 vector<size_t> rev=svn->revisions(path());117 118 SVNlog log(path()); 167 119 168 120 typedef map<int, set<string> > Container; 169 121 Container copyright; 170 for (vector<size_t>::iterator i=rev.begin(); i!=rev.end(); ++i) { 171 assert(*i<dates.size()); 172 time_t sec = str2time(dates[*i]); 122 123 124 assert(log.author().size()==log.date().size()); 125 vector<string>::const_iterator author=log.author().begin(); 126 for (vector<string>::const_iterator date=log.date().begin(); 127 date!=log.date().end(); ++date, ++author) { 128 time_t sec = str2time(*date); 173 129 tm* timeinfo = gmtime(&sec); 174 130 175 131 // find username in map of aliases 176 map<string, string>::iterator name = alias.lower_bound( authors[*i]);132 map<string, string>::iterator name = alias.lower_bound(*author); 177 133 // if alias exist insert alias 178 if (name != alias.end() && name->first== authors[*i])134 if (name != alias.end() && name->first==*author) 179 135 copyright[timeinfo->tm_year].insert(name->second); 180 136 else { 181 137 // else insert user name 182 copyright[timeinfo->tm_year].insert( authors[*i]);183 std::cerr << "Warning: no alias found for `" << authors[*i]<< "`\n";138 copyright[timeinfo->tm_year].insert(*author); 139 std::cerr << "Warning: no alias found for `" << *author << "`\n"; 184 140 // insert alias to avoid multiple warnings. 185 alias.insert(name, std::make_pair( authors[*i], authors[*i]));141 alias.insert(name, std::make_pair(*author, *author)); 186 142 } 187 143 } 188 144 145 189 146 // Code copied from Gnuplot -r70 190 147 char tmpname[]="/tmp/svndigestXXXXXX"; … … 197 154 // already open for writing. 198 155 std::ofstream tmp(tmpname); 199 200 201 202 156 203 157 ifstream is(path().c_str()); 158 assert(is.good()); 204 159 string line; 205 160 bool found_copyright = false; … … 223 178 // check whether copyright starts on this line 224 179 string::iterator i = search(line.begin(), line.end(), "Copyright (C)"); 225 226 if (i==line.end()) 180 if (i==line.end()) { 227 181 tmp << line << "\n"; 182 } 228 183 else { 229 184 prefix = line.substr(0, distance(line.begin(), i)); 230 185 found_copyright = true; 231 if (!found_copyright) 232 tmp << line << "\n"; 233 else { 234 // Printing copyright statement 235 for (Container::const_iterator i=copyright.begin(); 236 i!=copyright.end();) { 237 tmp << prefix << "Copyright (C) " 238 << 1900+i->first; 239 Container::const_iterator j = i; 240 while (++j!=copyright.end() && i->second == j->second){ 241 tmp << ", " << 1900+j->first; 242 } 243 // printing authors 244 for (set<string>::iterator a=i->second.begin(); 245 a!=i->second.end(); ++a){ 246 if (a!=i->second.begin()) 247 tmp << ","; 248 tmp << " " << *a; 249 } 250 tmp << "\n"; 251 i = j; 186 // Printing copyright statement 187 for (Container::const_iterator i=copyright.begin(); 188 i!=copyright.end();) { 189 tmp << prefix << "Copyright (C) " 190 << 1900+i->first; 191 Container::const_iterator j = i; 192 assert(i!=copyright.end()); 193 while (++j!=copyright.end() && i->second == j->second){ 194 tmp << ", " << 1900+(j->first); 252 195 } 196 // printing authors 197 for (set<string>::iterator a=i->second.begin(); 198 a!=i->second.end(); ++a){ 199 if (a!=i->second.begin()) 200 tmp << ","; 201 tmp << " " << *a; 202 } 203 tmp << "\n"; 204 i = j; 253 205 } 254 206 }
Note: See TracChangeset
for help on using the changeset viewer.