Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/ceedling/preprocessinator_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'ceedling/constants'
require 'ceedling/encodinator'
require 'ceedling/parsing_parcels'
require 'stringio'

class PreprocessinatorExtractor

Expand Down Expand Up @@ -80,6 +81,10 @@ class PreprocessinatorExtractor

# `input` must have the interface of IO -- StringIO for testing or File in typical use
def extract_file_as_array_from_expansion(input, filepath)
# Strip null bytes that GCC -E may embed in preprocessed output.
# Null bytes cause encoding errors in downstream line processing.
content = input.read.to_s.gsub("\0", "")
input = StringIO.new(content)

##
## Iterate through all lines and alternate between extract and ignore modes.
Expand Down
8 changes: 7 additions & 1 deletion lib/ceedling/system_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def shell_capture3(command:, boom:false)

stdout, stderr, status = Open3.capture3(command)

# Strip null bytes that some tools (e.g. GCC -H / -E) may inject into output.
# Null bytes cause ArgumentError ("string contains null byte") in downstream
# processing such as file path operations and YAML parsing.
stdout = stdout.to_s.gsub("\0", "")
stderr = stderr.to_s.gsub("\0", "")

# If boom, then capture the actual exit code.
# Otherwise, leave it as zero as though execution succeeded.
exit_code = status.exitstatus.freeze if boom and !status.nil?
Expand All @@ -87,7 +93,7 @@ def shell_capture3(command:, boom:false)
output: (stdout + stderr).to_s.freeze,

# Individual streams for detailed logging
stdout: stdout.freeze, #TODO PROBABLY DROP THESE TOO
stdout: stdout.freeze,
stderr: stderr.freeze,

# Relay full Process::Status
Expand Down
8 changes: 6 additions & 2 deletions lib/ceedling/yaml_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ class YamlWrapper
def load(filepath)
source = ERB.new(File.read(filepath)).result
begin
return YAML.load(source, aliases: true)
result = YAML.load(source, aliases: true)
rescue ArgumentError
return YAML.load(source)
result = YAML.load(source)
end
# YAML.load("") returns false in Ruby, not nil or [].
# Callers typically check `result.nil? || result.empty?` which raises
# NoMethodError on false. Return [] for empty/false results instead.
result == false ? [] : result
end

def load_string(source)
Expand Down
2 changes: 1 addition & 1 deletion vendor/unity
Submodule unity updated 114 files