cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

fix byte-order-marker handling when reading VS solution files

Open rabauke opened this issue 3 years ago • 1 comments

I think the handling of a possible byte order marker in a VS solution file is not correct. std::getline reads just the 3 bytes of the BOM as any other character till there is a new line. The BOM at the beginning of a file does not cause std::getline returning an empty string. See also cfe23927097b64bc8ecaf702eaa0212d0a7e5c6f.

rabauke avatar Jul 28 '22 22:07 rabauke

thanks for looking into this.

danmar avatar Jul 30 '22 09:07 danmar

there are plenty of test failures. did you see that?

 AssertionError: cppcheck: error: Visual Studio solution file header not found

the path for the solution file used is : test/cli/helloworld/helloworld.sln

danmar avatar Aug 21 '22 15:08 danmar

@danmar : Thanks for drawing my attention to the failing builds. If I understand the issue correctly, Visual Studio has three different storage formats for solution files

  • UTF-8
  • Unicode
  • ANSI

The main difference between ANSI and UTF-8 that UTF-8 files start with a byte order marker and and empty line. Both, the BOM and the empty line, are afaik not present in the older ANSI format.

This means that current cppcheck code is actually correct. Though, the code comment Skip BOM is slightly misleading as the code skips the BOM and the empty 1st line, as it is the required behavior for solution files with UTF-8 encoding.

This finding renders this PR obsolete.

rabauke avatar Aug 27 '22 15:08 rabauke