Skip to content

Commit 7a0cb43

Browse files
committed
Problem: too easy to release a project with obsolete Copyrights
Solution: Take legalese seriously. During regeneration, check if the current year is mentioned (from, until, listed, whatever) in a line with the "Copyright" word or some of the ways it can be written in the XML `<license>` tag. If the year is not listed in any such line (or no such lines are there), warn the user in at least the build-logged messages, and also pause for 5 sec so the interactive people can break, fix and regenerate. Signed-off-by: Jim Klimov <[email protected]>
1 parent 5d305b4 commit 7a0cb43

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

zproject.gsl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,35 @@ function resolve_includes (xml)
5050
endfor
5151
endfunction
5252

53+
# Sanity-check if project.xml, license.xml etc. reference the current
54+
# year (as starting, ending, just listed...) in Copyright line context
55+
function check_license_years (xml)
56+
if count (my.xml.license) > 0
57+
# Assign HHMMSSss into my.time and YYYYMMDD into my.date:
58+
my.time = time.now(my.date)
59+
my.now_year = string.substr(my.date, 0, , 4)
60+
my.year_seen = 0
61+
for my.xml.license
62+
# This pattern supports several ways of spelling the copyright
63+
# character (ASCII code 169) or registered symbol (ASCII 174).
64+
# Note that in XML tag they should be spelled via escape sequences;
65+
# a direct UTF character in the tag can be misinterpreted by GSL.
66+
if regexp.match ("(opyright|\(C\)|\&\#(169|[xX][aA]9|174|[xX][aA][eE])\;|\&copy\;|&copy;|&#(169|174|[xX][aA]9|[xX][aA][eE]);|$(conv.chr(169))|$(conv.chr(174))).*$(my.now_year)", license.)
67+
my.year_seen += 1
68+
endif
69+
endfor
70+
if (0 = my.year_seen)
71+
echo "W: Current year '$(my.now_year)' is not listed in any license tag / Copyright line!"
72+
echo "W: Do you want to Ctrl+Break now, edit your license.xml and regenerate the project?"
73+
echo "W: (Sleeping 5 sec...)"
74+
thread.sleep (500)
75+
echo "W: Oh well, moving on with possibly obsoleted copyrights"
76+
endif
77+
endif
78+
endfunction
79+
5380
resolve_includes (project)
81+
check_license_years (project)
5482

5583
# Check if project contains one or more C++ sources
5684
function project_use_cxx ()

0 commit comments

Comments
 (0)