Test pre-commit hook

This commit is contained in:
Laurent Saboret 2006-06-16 12:12:15 +00:00
parent f81db767a0
commit 7a9c25dfb9
2 changed files with 0 additions and 65 deletions

1
.gitattributes vendored
View File

@ -644,7 +644,6 @@ Maintenance/rpm/SPECS/CGAL-manual-tools.spec -text
Maintenance/rpm/SPECS/CGAL.spec -text
Maintenance/rpm/get_cgal_trunk_url -text
Maintenance/rpm/rpmbuild -text
Maintenance/svn_server/hooks/Warn_line_too_long.C -text
Maintenance/svn_server/hooks/post-commit -text
Maintenance/svn_server/hooks/post-commit.tmpl -text
Maintenance/svn_server/hooks/post-lock.tmpl -text

View File

@ -1,64 +0,0 @@
// Takes filenames as argument, and prints a warning for each too long line
// (>= 80 characters).
// First argument is the name of the directory.
// Following arguments are file names in this directory.
// Directory must not contain "/test".
// File names must end with ".h", ".hpp", ".C", ".c", ".cpp".
//
// Sylvain Pion. 2001, 2003, 2004.
// $Date: 2006-04-18 14:42:52 +0200 (Tue, 18 Apr 2006) $
// $Revision: 30642 $
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
int main(int argc, char **argv)
{
if (argc < 3) {
std::cerr << "Input file name(s) as argument" << std::endl;
return -1;
}
// Check we are not in test directory.
std::string dirname (argv[1]);
if (dirname.find("/test") != std::string::npos)
return 0;
// Iterate over all files.
for (int file = 2; file < argc; ++file) {
std::string filename(argv[file]);
// Test if filename ends with ".h", ".hpp", ".C", ".c", ".cpp".
if (filename.find(".h") == std::string::npos &&
filename.find(".hpp") == std::string::npos &&
filename.find(".c") == std::string::npos &&
filename.find(".C") == std::string::npos &&
filename.find(".cpp") == std::string::npos)
continue;
std::ifstream iFile(filename.c_str());
if (!iFile.is_open())
std::cerr << "could not open file " << filename << std::endl;
unsigned line_number=0;
std::string line;
while (getline(iFile, line)) {
++line_number;
// We don't warn if line_number <= 20 because the headers usually
// emit the warning validly.
if (line.size() >= 80 && line_number > 20) {
std::cerr << std::endl << std::endl << std::endl
<< "WARNING WARNING WARNING : Line " << line_number
<< " of file " << filename
<< " is too long (" << line.size() << " characters)"
<< std::endl << std::endl << std::endl;
}
}
}
return 0;
}