Commit Graph

14 Commits

Author SHA1 Message Date
Jesse Natalie
fb91e6f0eb
Flush stdout before changing mode back to text (#5477) 2023-11-15 17:02:00 +00:00
Ralf Habacker
3eff21366e
Fix MinGW build error (#4935) (#5127)
This commit fixes the following build error when the source code is build
with MinGW gcc 12 and compiler switch '-Werror=maybe-uninitialized' is
added:

    'file.{anonymous}::OutputFile::old_mode_' may be used uninitialized
     in this function [-Werror=maybe-uninitialized]
2023-03-03 15:53:08 +00:00
Steven Perron
91572e769a
Write binary files to stdout in binary on windows. (#4834)
We currently do not set stdout to binary mode when writing a binary
file on Windows.  This cause some extra characters to be written that
mess up the output.  We try to fix that.

Fixes #4793
2022-06-29 15:40:29 -04:00
5265644D61736F6E
881001070a
fix SIGSEGV when reading from a non-existant file (#4453)
When a tool (tested with spirv-dis and spirv-as) runs on a file that
does not exist, it notifies the user and tries to close the stream that
was never successfully opened.
2021-08-16 09:44:22 -04:00
Steven Perron
0bd920eb9d
Use standard function to get stdin to binary mode. (#4141)
* Use standard function to get stdin to binary mode.

The fisrt implementation to try to change stdin to binary mode is not
protable.  Using freopen has a lot of implementation defined behaviour,
and the code relied on that working.

Looking into the MSVC documentation, I do not see a protable way of
doing this.  I've implemented a Windows specific method and do nothing
for other systems.  In general, UNIX based systems do make a distinction
between text and binary files, so nothing needs to be done for them.

Fixes #2518

* Split ReadFile into two different functions.

We want to remove the flag parameter.  So the original function has been
replaced with ReadBinaryFile and ReadTextFile.  This should make the
code more readable.

* Change name of CorrectlyReadFile to avoid confusion.
2021-03-01 09:38:49 -05:00
Paul Thomson
e589d0d575
Add missing include (#3788)
Missing include in io.h for strcmp.
2020-09-10 08:31:41 +01:00
dan sinclair
7919b877c3 Close opened file handles. (#2644)
The close for the file handles was missing in the error cases.

Fixes #2641
2019-05-31 10:28:33 -04:00
dan sinclair
58a6876cee
Rewrite include guards (#1793)
This CL rewrites the include guards to make PRESUBMIT.py include guard
check happy.
2018-08-03 08:05:33 -04:00
David Neto
7d6c90c912 Reopen stdin for binary as needed
Fixes #1688
2018-07-10 17:49:07 -04:00
dan sinclair
f80696eaf6
[val] Add extra context to error messages. (#1600)
[val] Add extra context to error messages.

This CL extends the error messages produced by the validator to output the
disassembly of the errored line.

The validation_id messages have also been updated to print the line number of
the error instead of the word number. Note, the error number is from the start
of the SPIR-V, it does not include any headers printed in the disassembled code.

Fixes #670, #1581
2018-06-19 16:02:44 -04:00
David Neto
9fc8658ef3 Relicense SPIRV-Tools under Apache 2.0
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/383

Finalize v2016.4
2016-09-02 10:00:29 -04:00
David Neto
4dd4c14b80 Avoid integer modulo by 1, to avoid warning
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/349
2016-08-15 11:27:13 -04:00
Lei Zhang
23a3c2f762 DRY file writing code in tools. 2016-06-30 15:56:47 -04:00
Lei Zhang
7fd27e737a DRY file reading code in tools. 2016-06-30 15:56:20 -04:00