Commit Graph

32 Commits

Author SHA1 Message Date
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Brad King 030556b72b cmListFileLexer: Revise C++ coding style using clang-format
Manually extract the C++ portion of `cmListFileLexer.in.l` into a
temporary file, format it, and then move it back into the original file.
Manually format C++ code inside the lexer actions to match our style.
Then re-generate the lexer.
2016-05-17 13:27:23 -04:00
Brad King e4a92dab3f cmListFileLexer: Update to flex 2.6
Revise the documented modifications we need to make to the
flex-generated source file according to the needs of the new version.
Update our own implementation to avoid warnings with flex types.
2016-05-17 10:56:37 -04:00
Brad King 02b3cba9df cmListFileLexer: Fix lexing of single '[' character (#15092)
The lexer changes in commit v3.0.0-rc1~495^2 (Add Lua-style long
brackets and long comments to CMake language, 2013-08-06) accidentally
left out matching '[' as a single character in an unquoted argument.
Add a lexer rule to match it and extend the RunCMake.Syntax test to
cover this case.
2014-08-18 10:18:20 -04:00
Clinton Stimpson 5730710c86 Use cmsys::[io]fstream instead of cmsys_ios::[io]fstream.
Also use SystemTools::Fopen() instead of fopen().
This is to eventually support utf-8 filenames.
2014-01-07 09:27:44 -05:00
Brad King efcf318f8d Add \-continuation to CMake language quoted arguments
Teach the CMake language lexer to treat the \-LF pair terminating a
line ending in an odd number of backslashes inside a quoted argument
as a continuation.  Drop the pair from the returned quoted argument
token text.  This will allow long lines inside quoted argument
strings to be divided across multiple lines in the source file.
It will also allow quoted argument text to start on the line after
the opening quote.  For example, the code:

 set(x "\
 ...")

sets variable "x" to the value "..." with no opening newline.

Previously an odd number of backslashes at the end of a line inside
a quoted argument would put a \-LF pair (or a \-CR pair) literally
in the argument.  Then the command-argument evaluator would complain
that the \-escape sequence is invalid.  Therefore this syntax is
available to use without changing behavior of valid existing code.

Teach the RunCMake.Syntax test to cover cases of quoted arguments
with lines ending in \, \\, and \\\.  Odd counts are continuations.
2013-10-23 09:02:07 -04:00
Brad King daa0f6f98d Add Lua-style long brackets and long comments to CMake language
Teach the CMake language parser to recognize Lua-style "long bracket"
arguments.  These start with two '[' separated by zero or more '='
characters e.g. "[[" or "[=[" or "[==[".  They end with two ']'
separated by the same number of '=' as the opening bracket.  There is no
nesting of brackets of the same level (number of '=').  No escapes,
variable expansion, or other processing is performed on the content
between such brackets so they always represent exactly one argument.

Also teach CMake to parse and ignore "long comment" syntax.  A long
comment starts with "#" immediately followed by an opening long bracket.
It ends at the matching close long bracket.

Teach the RunCMake.Syntax test to cover long bracket and long comment
cases.
2013-10-17 09:07:00 -04:00
Brad King a8c652342f cmListFileLexer: Convert CRLF -> LF newlines explicitly
Read input files in binary mode instead of text mode and convert CRLF
newlines to LF newlines explicitly in our own buffer.  This is necessary
to read CMake source files with CRLF newlines on platforms whose C
runtime libraries do not transform newlines in text mode.  For example,
a Cygwin or Linux binary may not transform CRLF -> LF in files read from
a Windows filesystem.  Perform the conversion ourselves to ensure that
multi-line string literals in CMake source files have LF newlines
everywhere.
2013-10-17 09:07:00 -04:00
Brad King dbd933365e cmListFileLexer: Allow a leading UTF-8 Byte-Order-Mark (#11137)
Teach the lexer to read a UTF-8, UTF-16 BE/LE, or UTF-32 BE/LE
Byte-Order-Mark from the start of a file if any is present.  Report an
error on files using UTF-16 or UTF-32 and accept a UTF-8 or missing BOM.
2013-10-17 09:06:59 -04:00
Brad King 56457837e2 cmListFileLexer: Allow command names with one letter (#14181)
Teach the lexer to treat a single letter as an identifier instead of an
unquoted argument.  Outside of a command invocation, the parser treats
an identifier as a command name and an unquoted argument as an error.
Inside of a command invocation, the parser treats an identifier as an
unquoted argument.  Therefore this change to the lexer will make what
was previously an error case work with no other behavioral change.
2013-10-17 09:06:59 -04:00
Brad King ad3d5c59b3 cmListFileLexer: Fix leak on error before EOF
Teach cmListFileLexerDestroy to call cmListFileLexerSetToken with a NULL
token to free the token string buffer.  Without this, if an error occurs
before the token cleanup happens when EOF is reached, then the token
string buffer may leak.
2013-09-17 10:27:08 -04:00
Brad King c50f7ede20 cmListFileLexer: Modify flex output to avoid Borland warning
Remove the "yyscanner = NULL" assignment from the end of the
yylex_destroy function because Borland warns that the value is never
used.
2013-08-08 13:26:28 -04:00
Brad King 58e524165d Warn about arguments not separated by whitespace
Teach the lexer to return tokens for whitespace.  Teach the parser to
tolerate the space tokens where whitespace is allowed.  Also teach the
parser to diagnose and warn about cases of quoted arguments followed
immediately by another argument.  This was accidentally allowed
previously, so we only warn.

Update the RunCMake.Syntax test case StringNoSpace expected stderr to
include the warnings.
2013-08-08 13:26:27 -04:00
Brad King 28685ade7a cmListFileLexer: Split normal and legacy unquoted arguments
Match legacy arguments separately.  Add macros to simplify and clarify
matching rules.
2013-08-08 13:26:26 -04:00
Brad King 1eafa3edaf cmListFileLexer: Fix line number after backslash in string
If a line inside a string ends in a backslash count the following
newline character as a line increment.  Add a test covering this case to
verify that subsequent line numbers are correct.
2013-08-08 13:26:26 -04:00
Brad King e1381b1fc6 Document removal of 'register' from flex/bison output
In each .l and .y input file that has instructions for manual
transformation of the output to include a step to remove the 'register'
storage specifier.
2013-06-28 16:37:59 -04:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King 3d6100d7c6 COMP: Fix warnings produced by the change in include order from the re-organization of lexer code. 2006-08-09 09:45:04 -04:00
Brad King a3836e09a2 COMP: Moved duplicate flex-generated lexer warning suppression and cross-platform support code to a single cmStandardLexer.h included by all lexer sources. Added fix for macro redefinitions on Borland 5.8 compiler. 2006-08-08 14:00:28 -04:00
Brad King ab61137eb1 COMP: Fix and/or disable warnings for Borland 5.6 build. 2006-08-01 11:38:42 -04:00
Brad King dbe997e63b BUG: When an unquoted argument contains a pair of matching double quotes spaces and tabs should be allowed in-between. This allows arguments like -DFOO='"bar zot"' to work. 2005-09-19 17:20:48 -04:00
Brad King bccf040b00 BUG: Unquoted arguments can have quotes that are not at the beginning, but only an even number of them. 2005-08-01 16:49:37 -04:00
Brad King 28bb8e04c0 COMP: Defining YY_NO_INPUT to remove compilation of unused yyinput function. It was producing a warning about unreachable code. 2005-03-15 08:14:35 -05:00
Brad King 89a8261f68 ENH: Mangled lexer symbols to begin in cmListFileLexer_yy instead of just yy to avoid conflict with other lexers that may be added. 2005-01-19 12:06:24 -05:00
Brad King bc26a216b4 BUG#1179: Fix for syntax in unquoted arguments. 2004-09-20 08:51:12 -04:00
Brad King 486a26d3db BUG#1049: Added error message when file ends in an unterminated string. 2004-08-31 18:39:42 -04:00
Brad King 2716ac3966 BUG: Fixed parsing of unquoted arguments to allow double-quotes within the argument. 2004-06-18 10:51:10 -04:00
Brad King 5473791b4b ENH: Added cmListFileLexer_SetString method to allow a string to be parsed as input. 2004-04-21 16:23:58 -04:00
Brad King cf42225c0b ERR: Removed YY_BREAK statements after return statements because they are unreachable. 2003-12-09 09:16:40 -05:00
Brad King c85e16450d ERR: Added missing static keyword to cmListFileLexerSetToken and cmListFileLexerAppend definitions. 2003-12-09 09:11:35 -05:00
Brad King 2b957198fd ERR: Fixed comment about how to run flex to reflect new name of this file. 2003-12-08 15:05:16 -05:00
Brad King c05b800f9f ERR: Renaming cmListFileLexer.l to cmListFileLexer.in.l to avoid make programs trying to run lex automatically whn building cmListFileLexer.c. 2003-12-08 14:20:48 -05:00