CrYears - Release Notes

Copyright 2026-2027 by The Software Samurai.
On the web: http://www.SoftwareSam.us/
Software released under GNU GPL3, and documentation released under FDL1.3

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. <http://www.gnu.org/licenses/>
   CrYears (cryr.pl): version 0.0.02
   Developed under : Perl v:5.42.3
                     Grep v:3.12

Description

This package includes the Perl script 'cryr.pl' which demonstrates the use of grep to simplify updating of source code in preparation for creating a distribution package.
Coincidentally, it also demonstrates some basic (and not-so-basic) Perl functionality and syntax.

The author uses this program to scan for strings which represent a range of years, primarily in connection with copyright notices; hence, the name: CopyrightYears.pl

It is also used to identify date ranges used in screenshots, diagrams and other instances which may occasionally become stale when each new year arrives.



Also included in the package are some sample source code files in various programming languages. These may be used to test the functionality of 'cryr.pl'.
Example: ./cryr.pl -path='./1_TestData' (see invocation options)

Note that 'test.cpp' is a fully-functional (but brain-damaged) application originally created in response to a student request and modified slightly for this package. The application can be built using the included 'Makefile'.
   cd 1_TestData
   gmake
   ./test --help

The miscellaneous other files in the 1_TestData directory are simply examples for testing the cryr.pl program.



The cryr.pl program can easily be modified to scan your source code for any often-included and occasionally-updated sequence, such as an address, a URL, contact information, version number, etc.


Download and unpack the distribution archive.


Command-line Options for ‘cryr.pl’

Usage: cryr.pl [OPTIONS]

Invocation options fall into two categories:
    1) Selection of the files to be scanned.
    2) Setting the parameters for the scan.

File-specification Options

When invoked without parameters, the files scanned will be all '.hpp' and '.cpp' files in the CWD (Current-Working-Directory). This is the “Regular Expression” (regex) specifying the default basic source file group to be scanned:   *[.][hc]pp
Note that the order in which filespec options are specified can affect which files are actually scanned.

The other filespec options, '-texi','-pl','-make','-aux' are added to the primary filespec option.
For example: “cryr.pl -pl”  will scan all files in the CWD with extensions of '.hpp','.cpp' and '.pl'.

Other Options



Notes

User friendliness begins with an acknowledgment that many users are too bloody lazy to read the documentation; therefore, as with many of the author's other script files, an option may be specified using either a single dash or a double dash.
The following are equivalent:
cryr.pl -icase
cryr.pl --icase
cryr.pl ---------icase
The author believes that most script files (and many compiled programs) would benefit from this simple syntax filter.

Misc. Developer Notes

The Primary Scan Regular Expression

Notes on the regular expression (regexp) used to scan for date-range substrings. The basic target is a string of the form: "2021-2025" or minor variations on that form.

The Secondary Scan Filters

Technical Note:It is possible (though unlikely) that the secondary filters could match text in the temporary buffer which represents an embedded ANSI color escape sequence inserted by the grep utility rather than actual source code.
Color escape sequences take the general form:

ESC [  0  1  ;  3  1  m
1b  5b 30 31 3b 33 31 6d
If this happens, adjust the search token to exclude the ANSI sequence.

Inclusion Filter

The inclusion filter is applied to the data captured during the primary scan. This is done by writing the results of the primary scan to a temporary file. 'grep' is then used to scan the temporary file.
Only lines which contain the inclusion token will be reported to the user.
Example: cryr.pl -incl='Copyright'
This report would include lines which contain both the primary token and the word “Copyright” (case-sensitive).
Reported:
"Copyright (c) 2004-2024, Bobo the Basement Troll"
Not Reported:
const char* crYears = "2004-2024"; // copyright years
The second line is excluded because the scan is case-sensitive by default; therefore, to report both, use the '-icase' option:
Example: cryr.pl -incl='Copyright' -icase
or
Example: cryr.pl -incl='[cC]opyright'

Exclusion Filter

The exclusion filter is applied to one of two sets of captured data:
  1) Applied to the data captured during the primary scan.
  2) Applied to the results of the inclusion-filter scan.
This is done by writing the results of the previous scan to a temporary file. 'grep' is then used to scan the temporary file. Only lines which include the primary-scan token but not the exclusion token will be reported.
Example: -excl='[-] ?2026'
This would exclude lines which have already been updated for the year 2026.
Reported:
const char* crYears = "2004-2025";
const char* crYears = "2004 - 2025";
Not Reported:
const char* crYears = "2004-2026";
const char* crYears = "2004 - 2026";
(See also the special case of the: “-excl=''” option described above.)


Special Characters

Both the shell program and the grep utility define a set of “special” characters. Unfortunately, it is not the same set and the “specialness” of each character may be defined differently by each. If the filter argument is enclosed in single quotes, the shell will probably pass special characters through without interpretation.
Example: --incl='[-] ?2023'
This will match both "-2023" and "- 2023" as expected.

The following will be passed through the shell without interpretation; however, grep sees parentheses as “special” characters.
Example: --incl='(c)'
In order for grep to see them as ordinary characters, they must be individually escaped.
Example: --incl='\(c\)'
Example: --incl='[(]c[)]'
Some "very special" characters are single-quote, double-quote and the dash character ('-').
If searching for a single or double quote, then the argument should be enclosed in the opposite quote: # Example: --incl='This is a double-quote: "'
Example: --incl="This is a single-quote: '"
The dash is special to the shell only if it is the first character of the token; otherwise, it is an ordinary character:
Example: --incl='\-Hello World!'             (backslash '\' removes the specialness)
Example: --incl='Hello-World!'               (not the first character of token)
Bash and other shell programs provide a way to get around the specialness of the leading dash character, and this special invocation syntax is used by cryr.pl:
The Bash '--' double-dash/double-hyphen operator is used to signal the end of command-line arguments for the utility being invoked. Any tokens following the double-dash will not be interpreted as grep invocation options, but will instead be passed to grep as operational parameters.
Example: grep -nHsE --color=always -- '-abc' '-stupid nonportable filename.txt'
This means that the following inclusion filter will work as expected:
Example: cryr --incl='-Hello World!'

(Don't even get us started on the backtick [`] character, which in the world of special characters, is poison-on-a-stick.)


Version History

See the source file.