lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [5565] Restrict non-binary files to ISO-8859-15 and whites


From: Greg Chicares
Subject: [lmi-commits] [5565] Restrict non-binary files to ISO-8859-15 and whitespace
Date: Sat, 08 Sep 2012 09:13:18 +0000

Revision: 5565
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5565
Author:   chicares
Date:     2012-09-08 09:13:17 +0000 (Sat, 08 Sep 2012)
Log Message:
-----------
Restrict non-binary files to ISO-8859-15 and whitespace

Modified Paths:
--------------
    lmi/trunk/test_coding_rules.cpp

Modified: lmi/trunk/test_coding_rules.cpp
===================================================================
--- lmi/trunk/test_coding_rules.cpp     2012-09-08 01:50:09 UTC (rev 5564)
+++ lmi/trunk/test_coding_rules.cpp     2012-09-08 09:13:17 UTC (rev 5565)
@@ -315,6 +315,22 @@
         }
 }
 
+/// Validate characters, allowing only Latin-9 and whitespace.
+///
+/// Throw if the file contains a character outside the union of
+/// ISO-8859-15 and the minimal POSIX whitespace set " \f\n\r\t\v".
+///
+/// To locate violations: "grep -P '[\x00-\x08\x0e-\x1f\x7f-\x9f]'".
+
+void assay_non_latin(file const& f)
+{
+    static boost::regex const forbidden("[\\x00-\\x08\\x0e-\\x1f\\x7f-\\x9f]");
+    if(boost::regex_search(f.data(), forbidden))
+        {
+        throw std::runtime_error("File contains a forbidden character.");
+        }
+}
+
 /// Validate whitespace.
 ///
 /// Throw if the file contains '\f', '\r', '\t', or '\v', except in
@@ -1077,6 +1093,7 @@
         return statistics();
         }
 
+    assay_non_latin         (f);
     assay_whitespace        (f);
 
     check_config_hpp        (f);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]