View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015890CMakeCMakepublic2015-12-21 10:432016-05-02 08:30
ReporterFredrik Björkenfors 
Assigned ToClinton Stimpson 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformWindowsOSWindows 7OS VersionWin7 SP1
Product VersionCMake 3.4 
Target VersionCMake 3.5Fixed in VersionCMake 3.5 
Summary0015890: file(STRINGS ..) doesn't work on single character files.
DescriptionIf the file passed to file(STRINGS <file> VAR) contains a single character file VAR will be empty.
Steps To ReproduceRun CMake on the attached project.

Workaround: Adding any character to the input file, including an EOL character.
Additional InformationIf the file has less than 2 characters ReadBOM(std::istream& in) will set the failbit and the attempt to rewind the file will fail.
TagsNo tags attached.
Attached Fileszip file icon CMake_bug.zip [^] (413 bytes) 2015-12-21 10:43

 Relationships

  Notes
(0040014)
Brad King (manager)
2015-12-21 10:47

Thanks. This was likely introduced as of CMake 3.2 with this change:

 file: Teach STRINGS to support UTF-16 and UTF-32 encodings
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f77a700 [^]
(0040015)
Brad King (manager)
2015-12-21 10:52

The bug itself may be in the KWSys FStream::ReadBOM implementation introduced here:

 FStream: Add ability to detect BOM.
 http://public.kitware.com/gitweb?p=KWSys.git;a=commitdiff;h=b3b20cc0 [^]
(0040017)
Fredrik Björkenfors (reporter)
2015-12-21 11:00

Yes, this is were the rewind fails due to in.read setting the failbit. I think seekg clears the eofbit, but not the failbit.
in.read(reinterpret_cast<char*>(bom), 2);
+ if(!in.good())
+ {
+ in.seekg(orig);
+ return BOM_None;
+ }
(0040032)
Clinton Stimpson (developer)
2016-01-01 00:43

Here is a candidate fix.
http://review.source.kitware.com/#/c/20612/ [^]
(0040152)
Brad King (manager)
2016-01-07 16:07

The KWSys change referenced in 0015890:0040032 has been merged to upstream KWSys. Here is a commit to CMake to update it:

 KWSys 2016-01-07 (2418443e)
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f2b0bf6e [^]
(0040995)
Robert Maynard (manager)
2016-05-02 08:30

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-12-21 10:43 Fredrik Björkenfors New Issue
2015-12-21 10:43 Fredrik Björkenfors File Added: CMake_bug.zip
2015-12-21 10:47 Brad King Note Added: 0040014
2015-12-21 10:52 Brad King Note Added: 0040015
2015-12-21 10:52 Brad King Assigned To => Clinton Stimpson
2015-12-21 10:52 Brad King Status new => assigned
2015-12-21 10:52 Brad King Target Version => CMake 3.5
2015-12-21 11:00 Fredrik Björkenfors Note Added: 0040017
2016-01-01 00:43 Clinton Stimpson Note Added: 0040032
2016-01-07 16:07 Brad King Note Added: 0040152
2016-01-07 16:07 Brad King Status assigned => resolved
2016-01-07 16:07 Brad King Resolution open => fixed
2016-01-07 16:07 Brad King Fixed in Version => CMake 3.5
2016-05-02 08:30 Robert Maynard Note Added: 0040995
2016-05-02 08:30 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team