lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 4f35f0c 2/5: Use extension '.rates' for rate


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 4f35f0c 2/5: Use extension '.rates' for rate tables; enforce coding rules for them
Date: Wed, 7 Dec 2016 09:37:16 +0000 (UTC)

branch: master
commit 4f35f0c5d61ba13ac6f179235b57cb5647f40d88
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Use extension '.rates' for rate tables; enforce coding rules for them
    
    A distinctive extension is better than '.txt' in general, and is needed
    in particular to customize coding rules for rate tables.
---
 gwc/develop2.txt      |    7 ++++---
 rate_table_tool.cpp   |   12 ++++++------
 test_coding_rules.cpp |   21 +++++++++++++++------
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/gwc/develop2.txt b/gwc/develop2.txt
index fcfa000..ffa402c 100644
--- a/gwc/develop2.txt
+++ b/gwc/develop2.txt
@@ -15,9 +15,10 @@ git clone file:///opt/lmi/blessed/proprietary
   # (a pre-commit hook shows these commands' output, filtered)
 
 cd /opt/lmi/proprietary/data/
-cd ../data; make src_dir=/opt/lmi/src/lmi -f /opt/lmi/src/lmi/GNUmakefile 
check_concinnity 2>&1 |less -S
-cd ../src ; make src_dir=/opt/lmi/src/lmi -f /opt/lmi/src/lmi/GNUmakefile 
check_concinnity 2>&1 |less -S
-cd ../test; make src_dir=/opt/lmi/src/lmi -f /opt/lmi/src/lmi/GNUmakefile 
check_concinnity 2>&1 |less -S
+cd ../data  ; make src_dir=/opt/lmi/src/lmi -f /opt/lmi/src/lmi/GNUmakefile 
check_concinnity 2>&1 |less -S
+cd ../src   ; make src_dir=/opt/lmi/src/lmi -f /opt/lmi/src/lmi/GNUmakefile 
check_concinnity 2>&1 |less -S
+cd ../test  ; make src_dir=/opt/lmi/src/lmi -f /opt/lmi/src/lmi/GNUmakefile 
check_concinnity 2>&1 |less -S
+cd ../tables; make src_dir=/opt/lmi/src/lmi -f /opt/lmi/src/lmi/GNUmakefile 
check_concinnity 2>&1 |less -S
 
   # Commit the changes in whatever batches make sense
 
diff --git a/rate_table_tool.cpp b/rate_table_tool.cpp
index f0088d8..c0cb113 100644
--- a/rate_table_tool.cpp
+++ b/rate_table_tool.cpp
@@ -114,8 +114,8 @@ void list_tables(fs::path const& database_filename)
 /// be useful.
 ///
 /// If 'path_to_merge' names a file, then merge that file. If it names
-/// a directory, then merge all '*.txt' files in that directory. See
-/// rationale:
+/// a directory, then merge all '*.rates' files in that directory.
+/// Rationale:
 ///   http://lists.nongnu.org/archive/html/lmi/2016-11/msg00025.html
 
 void merge
@@ -141,7 +141,7 @@ void merge
         fs::directory_iterator const eod;
         for(; i != eod; ++i)
             {
-            if(".txt" != fs::extension(*i)) continue;
+            if(".rates" != fs::extension(*i)) continue;
             table const& t = table::read_from_text(*i);
             table_file->add_or_replace_table(t);
             ++count;
@@ -175,7 +175,7 @@ void delete_table
 std::string do_save_as_text_file(table const& t)
 {
     std::ostringstream oss;
-    oss << std::setfill('0') << std::setw(5) << t.number() << ".txt";
+    oss << std::setfill('0') << std::setw(5) << t.number() << ".rates";
     std::string const filename = oss.str();
     t.save_as_text(filename);
     return filename;
@@ -433,8 +433,8 @@ int try_main(int argc, char* argv[])
         {"crc"         ,NO_ARG   ,0 ,'c' ,0 ,"show CRCs of all tables"},
         {"list"        ,NO_ARG   ,0 ,'t' ,0 ,"list all tables"},
         {"merge=PATH"  ,REQD_ARG ,0 ,'m' ,0 ,"merge PATH (file or dir) into 
database"},
-        {"extract=n"   ,REQD_ARG ,0 ,'e' ,0 ,"extract table #n into 
0000n.txt"},
-        {"extract-all" ,NO_ARG   ,0 ,'x' ,0 ,"extract all tables to txt 
files"},
+        {"extract=n"   ,REQD_ARG ,0 ,'e' ,0 ,"extract table #n into 
'0000n.rates'"},
+        {"extract-all" ,NO_ARG   ,0 ,'x' ,0 ,"extract all tables to '.rates' 
files"},
         {"rename=FILE" ,REQD_ARG ,0 ,'r' ,0 ,"rename tables from FILE"},
         {"verify"      ,NO_ARG   ,0 ,'v' ,0 ,"verify integrity of all tables"},
         {0             ,NO_ARG   ,0 ,0   ,0 ,""}
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index 2698edc..53a766d 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -65,12 +65,13 @@ enum enum_phylum
     ,e_make       = 1 << 10
     ,e_md5        = 1 << 11
     ,e_patch      = 1 << 12
-    ,e_relax_ng   = 1 << 13
-    ,e_script     = 1 << 14
-    ,e_synopsis   = 1 << 15
-    ,e_touchstone = 1 << 16
-    ,e_xml_input  = 1 << 17
-    ,e_xml_other  = 1 << 18
+    ,e_rates      = 1 << 13
+    ,e_relax_ng   = 1 << 14
+    ,e_script     = 1 << 15
+    ,e_synopsis   = 1 << 16
+    ,e_touchstone = 1 << 17
+    ,e_xml_input  = 1 << 18
+    ,e_xml_other  = 1 << 19
     };
 
 enum enum_kingdom
@@ -171,6 +172,7 @@ file::file(std::string const& file_path)
         : ".make"       == extension() ? e_make
         : ".md5sums"    == extension() ? e_md5
         : ".patch"      == extension() ? e_patch
+        : ".rates"      == extension() ? e_rates
         : ".rnc"        == extension() ? e_relax_ng
         : ".ac"         == extension() ? e_script
         : ".bat"        == extension() ? e_script
@@ -450,6 +452,12 @@ void check_config_hpp(file const& f)
 /// notices must include the current year, except that html versions
 /// of the GPL use the FSF's copyright years in the '&copy;' notice.
 ///
+/// Rate tables (phylum 'e_rates') are tested for a copyright notice,
+/// even though none is logically required (e.g., regulatory tables
+/// are not copyrighted), because the principal use case for '.rates'
+/// files is to embody proprietary data that really should have a
+/// copyright notice.
+///
 /// SOMEDAY !! This test could be liberalized to permit copyright
 /// notices to span multiple lines. For now, it is assumed that the
 /// year appears on the same line as the word "Copyright".
@@ -718,6 +726,7 @@ void check_preamble(file const& f)
         (   f.is_of_phylum(e_gpl)
         ||  f.is_of_phylum(e_md5)
         ||  f.is_of_phylum(e_patch)
+        ||  f.is_of_phylum(e_rates)
         ||  f.is_of_phylum(e_touchstone)
         ||  f.is_of_phylum(e_xml_input)
         )



reply via email to

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