[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 9e360f0 2/5: Make future copyright updates ea
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 9e360f0 2/5: Make future copyright updates easier |
Date: |
Sun, 3 Jan 2021 08:07:11 -0500 (EST) |
branch: master
commit 9e360f003b9795b980cd0b762e4de182d27b59f8
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Make future copyright updates easier
* GNUmakefile: Handle hooks/ subdirectory as well. Mark end of each
list of potential issues, for readability. Improve some regexes.
* test_coding_rules.cpp: Avoid false positives by writing "Copyright"
using string-literal concatenation.
* wx_test_about_version.cpp: Likewise.
---
GNUmakefile | 14 +++++++++++---
test_coding_rules.cpp | 4 ++--
wx_test_about_version.cpp | 8 ++++----
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/GNUmakefile b/GNUmakefile
index b3d18a3..cc0af94 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -520,11 +520,16 @@ backup_directory := ../saved_$(old_year)
unutterable := Copyright
+# The first two commands in the recipe use 'mkdir' without '-p',
+# deliberately: if they fail, something is amiss (probably the
+# result of trying to update copyrights twice in the same year).
+
.PHONY: happy_new_year
happy_new_year: source_clean
$(MKDIR) $(backup_directory)
+ $(MKDIR) $(backup_directory)/hooks
$(TOUCH) --date=$(old_year)0101 BOY
- for z in *; \
+ for z in * hooks/*; \
do \
[ $$z -nt BOY ] \
&& [ ! -d $$z ] \
@@ -540,12 +545,14 @@ happy_new_year: source_clean
$(GREP) --directories=skip '$(old_year)[, ]*$(old_year)' * || true
$(GREP) --directories=skip '$(new_year)[, ]*$(old_year)' * || true
$(GREP) --directories=skip '$(new_year)[, ]*$(new_year)' * || true
+ @$(ECHO) "...end first list of potential issues."
[ -z '$(wildcard *.?pp)' ] || $(GREP) '$(old_year)' *.?pp \
| $(SED) \
-e '/$(old_year)[, ]*$(new_year)/d' \
-e'/https*:\/\/lists.nongnu.org\/archive\/html\/lmi\/$(old_year)/d'
\
-e'/\(VERSION\|version\).*$(old_year)[0-9]\{4\}T[0-9]\{4\}Z/d' \
|| true
+ @$(ECHO) "...end second list of potential issues."
$(GREP) --directories=skip $(unutterable) * \
| $(SED) \
-e '/$(unutterable).*$(new_year) Gregory W. Chicares/d' \
@@ -582,12 +589,13 @@ happy_new_year: source_clean
-e '/:good_copyright=/d' \
-e '/:$(unutterable) (C)$$/d' \
-e '/$(unutterable) (C) 1900/d' \
- -e '/$(unutterable).*`date -u +.%Y.`/d' \
+ -e '/$(unutterable).*[$$](date -u +.%Y.)/d' \
-e
'/http:\/\/www.gnu.org\/prep\/maintain\/maintain.html#$(unutterable)-Notices/d'
\
-e '/year appears on the same line as the word "$(unutterable)"/d' \
-e '/document.add_comment("$(unutterable) (C) " + y + " Gregory W.
Chicares.");/d' \
- -e '/oss << "$(unutterable) .*" << year;/d' \
+ -e '/oss << R*"$(unutterable) .*" << year;/d' \
|| true
+ @$(ECHO) "...end third list of potential issues."
@$(ECHO) "Done."
################################################################################
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index b92042f..9f07ecf 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -509,14 +509,14 @@ void check_copyright(file const& f)
{ // Scope to avoid unwanted '-Wshadow' diagnostic.
std::ostringstream oss;
- oss << R"(Copyright \(C\)[^\n]*)" << year;
+ oss << 'C' << R"(opyright \(C\)[^\n]*)" << year;
require(f, oss.str(), "lacks current copyright.");
}
if(f.is_of_phylum(e_html) && !f.phyloanalyze("^COPYING"))
{
std::ostringstream oss;
- oss << R"(Copyright ©[^\n]*)" << year;
+ oss << 'C' << R"(opyright ©[^\n]*)" << year;
require(f, oss.str(), "lacks current secondary copyright.");
}
}
diff --git a/wx_test_about_version.cpp b/wx_test_about_version.cpp
index 9c8e79a..9fe7354 100644
--- a/wx_test_about_version.cpp
+++ b/wx_test_about_version.cpp
@@ -81,11 +81,11 @@ int year_from_string(wxString const& s)
// May throw if the input doesn't conform to the expectations.
int extract_last_copyright_year(wxString const& html)
{
- // Find the line starting with "Copyright".
+ // Find the line starting with "C""opyright".
wxString copyright_line;
for(auto const& line : wxSplit(html ,'\n' ,'\0'))
{
- if(line.StartsWith("Copyright"))
+ if(line.StartsWith("C""opyright"))
{
LMI_ASSERT_WITH_MSG
(copyright_line.empty()
@@ -99,7 +99,7 @@ int extract_last_copyright_year(wxString const& html)
LMI_ASSERT_WITH_MSG
(!copyright_line.empty()
- ,"Copyright line not found in the license notices text"
+ ,"C""opyright line not found in the license notices text"
);
// We suppose that we have a sequence of comma-separated (4 digit, let
@@ -120,7 +120,7 @@ int extract_last_copyright_year(wxString const& html)
,m
,std::regex("(?:\\d{4}, )+(\\d{4})")
)
- , "Copyright line \""
+ , "C""opyright line \""
+ copyright_line
+ "\" doesn't contain copyright years"
);