[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master f2621cd 4/6: Apply 'e_script' coding rules to
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master f2621cd 4/6: Apply 'e_script' coding rules to hash-bang files |
Date: |
Wed, 22 May 2019 15:27:39 -0400 (EDT) |
branch: master
commit f2621cdb5e84497d646f5ab2a5f1315152a29d33
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Apply 'e_script' coding rules to hash-bang files
Typical shell scripts have no distinctive file extension.
---
test_coding_rules.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index 68b1962..41a07cd 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -25,7 +25,7 @@
#include "handle_exceptions.hpp"
#include "istream_to_string.hpp"
#include "main_common.hpp"
-#include "miscellany.hpp" // split_into_lines()
+#include "miscellany.hpp" // begins_with(), split_into_lines()
#include <boost/filesystem/convenience.hpp> // fs::extension()
#include <boost/filesystem/fstream.hpp>
@@ -155,8 +155,9 @@ file::file(std::string const& file_path)
throw std::runtime_error("Failure in file input stream.");
}
- // Sort these lists by enumerator, but keep 'e_ephemeral' last.
+ // Sort each sublist by enumerator, but keep 'e_ephemeral' last.
phylum_ =
+ // extension() tests are simplest
".ico" == extension() ? e_binary
: ".ini" == extension() ? e_binary
: ".png" == extension() ? e_binary
@@ -197,6 +198,7 @@ file::file(std::string const& file_path)
: ".xrc" == extension() ? e_xml_other
: ".xsd" == extension() ? e_xml_other
: ".xsl" == extension() ? e_xml_other
+ // phyloanalyze() tests inspect only file name
: phyloanalyze("^ChangeLog-") ? e_binary
: phyloanalyze("^tags$") ? e_expungible
: phyloanalyze("^COPYING$") ? e_gpl
@@ -207,6 +209,9 @@ file::file(std::string const& file_path)
: phyloanalyze("^md5sums$") ? e_md5
: phyloanalyze("^INSTALL$") ? e_synopsis
: phyloanalyze("^README") ? e_synopsis
+ // test file contents only if necessary
+ : begins_with(data(), "#!") ? e_script
+ // keep this last
: phyloanalyze("^eraseme") ? e_ephemeral
: throw std::runtime_error("File is unexpectedly uncategorizable.")
;
- [lmi-commits] [lmi] master updated (548812c -> 5451a41), Greg Chicares, 2019/05/22
- [lmi-commits] [lmi] master fbe3879 3/6: Assert a precondition; improve documentation, Greg Chicares, 2019/05/22
- [lmi-commits] [lmi] master f2621cd 4/6: Apply 'e_script' coding rules to hash-bang files,
Greg Chicares <=
- [lmi-commits] [lmi] master 5a7e4c1 5/6: Check concinnity of hooks/, Greg Chicares, 2019/05/22
- [lmi-commits] [lmi] master 4638d55 1/6: Fix defect committed 20190518T1712Z: script might not be in $PWD, Greg Chicares, 2019/05/22
- [lmi-commits] [lmi] master 0dfb9cb 2/6: Parameterize directory tested by 'make check_concinnity', Greg Chicares, 2019/05/22
- [lmi-commits] [lmi] master 5451a41 6/6: Improve documentation, Greg Chicares, 2019/05/22