mirror of
https://github.com/reactos/CMake.git
synced 2024-12-15 07:41:15 +00:00
Merge topic '16607-error-out-on-non-seekable-input-files'
ded616bd
cmListFileLexer: bail out on seek-errors
This commit is contained in:
commit
30243e7faf
@ -80,6 +80,13 @@ bool cmListFileParser::ParseFile()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bom == cmListFileLexer_BOM_Broken) {
|
||||
cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
|
||||
this->IssueFileOpenError("Error while reading Byte-Order-Mark. "
|
||||
"File not seekable?");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify the Byte-Order-Mark, if any.
|
||||
if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) {
|
||||
cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
|
||||
|
@ -2559,11 +2559,15 @@ static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
|
||||
if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
|
||||
return cmListFileLexer_BOM_UTF32LE;
|
||||
}
|
||||
fsetpos(f, &p);
|
||||
if (fsetpos(f, &p) != 0) {
|
||||
return cmListFileLexer_BOM_Broken;
|
||||
}
|
||||
return cmListFileLexer_BOM_UTF16LE;
|
||||
}
|
||||
}
|
||||
rewind(f);
|
||||
if (fseek(f, 0, SEEK_SET) != 0) {
|
||||
return cmListFileLexer_BOM_Broken;
|
||||
}
|
||||
return cmListFileLexer_BOM_None;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ struct cmListFileLexer_Token_s
|
||||
enum cmListFileLexer_BOM_e
|
||||
{
|
||||
cmListFileLexer_BOM_None,
|
||||
cmListFileLexer_BOM_Broken,
|
||||
cmListFileLexer_BOM_UTF8,
|
||||
cmListFileLexer_BOM_UTF16BE,
|
||||
cmListFileLexer_BOM_UTF16LE,
|
||||
|
@ -290,7 +290,7 @@ add_RunCMake_test(target_link_libraries)
|
||||
|
||||
add_RunCMake_test(target_compile_features)
|
||||
add_RunCMake_test(CheckModules)
|
||||
add_RunCMake_test(CommandLine)
|
||||
add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
|
||||
add_RunCMake_test(CommandLineTar)
|
||||
|
||||
add_RunCMake_test(install)
|
||||
|
@ -1,3 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake_command(NoArgs ${CMAKE_COMMAND})
|
||||
@ -301,3 +303,14 @@ set(CMAKE_RELATIVE_PATH_TOP_BINARY \"${RunCMake_TEST_BINARY_DIR}\")
|
||||
)
|
||||
endfunction()
|
||||
run_cmake_depends()
|
||||
|
||||
function(reject_fifo)
|
||||
find_program(BASH_EXECUTABLE bash)
|
||||
if(BASH_EXECUTABLE)
|
||||
set(BASH_COMMAND_ARGUMENT "'${CMAKE_COMMAND}' -P <(echo 'return()')")
|
||||
run_cmake_command(reject_fifo ${BASH_EXECUTABLE} -c ${BASH_COMMAND_ARGUMENT})
|
||||
endif()
|
||||
endfunction()
|
||||
if(CMAKE_HOST_UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
|
||||
reject_fifo()
|
||||
endif()
|
||||
|
1
Tests/RunCMake/CommandLine/reject_fifo-result.txt
Normal file
1
Tests/RunCMake/CommandLine/reject_fifo-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
2
Tests/RunCMake/CommandLine/reject_fifo-stderr.txt
Normal file
2
Tests/RunCMake/CommandLine/reject_fifo-stderr.txt
Normal file
@ -0,0 +1,2 @@
|
||||
CMake Error in .*
|
||||
Error while reading Byte-Order-Mark\. File not seekable\?
|
Loading…
Reference in New Issue
Block a user