Skip to content

Commit a371afb

Browse files
committed
More formatting, update local script
1 parent 5fa6eb9 commit a371afb

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

Scripts/format.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,3 @@ echo "Formatting Swift sources in $(pwd)"
1818
# Run the format / lint commands
1919
git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place
2020
git ls-files -z '*.swift' | xargs -0 swift format lint --strict --parallel
21-
22-
sed -i '' 's/borrowbuffer/borrow buffer/g' "Sources/BinaryParsing/Parser Types/ParserSpan.swift"

Sources/BinaryParsing/Parsers/Integer.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
163163

164164
// 2) Load and store value in `result`.
165165
let result =
166-
unsafe endianness.isBigEndian
166+
unsafe endianness.isBigEndian
167167
? Self(_unchecked: (), _parsingBigEndian: &input)
168168
: Self(_unchecked: (), _parsingLittleEndian: &input)
169169

@@ -207,7 +207,8 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
207207
func consumeZeroPadding() throws(ParsingError) {
208208
var paddingBuffer = input.divide(atOffset: paddingCount)
209209
for _ in 0..<paddingCount {
210-
guard unsafe 0 == paddingBuffer.consumeUnchecked(type: UInt8.self) else {
210+
guard unsafe 0 == paddingBuffer.consumeUnchecked(type: UInt8.self)
211+
else {
211212
throw ParsingError(
212213
status: .invalidValue, location: paddingBuffer.startPosition)
213214
}
@@ -217,12 +218,12 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
217218
if endianness.isBigEndian {
218219
try consumeZeroPadding()
219220
self =
220-
unsafe endianness.isBigEndian
221+
unsafe endianness.isBigEndian
221222
? Self(_unchecked: (), _parsingBigEndian: &input)
222223
: Self(_unchecked: (), _parsingLittleEndian: &input)
223224
} else {
224225
self =
225-
unsafe endianness.isBigEndian
226+
unsafe endianness.isBigEndian
226227
? Self(_unchecked: (), _parsingBigEndian: &input)
227228
: Self(_unchecked: (), _parsingLittleEndian: &input)
228229
try consumeZeroPadding()
@@ -241,7 +242,7 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
241242
let paddingCount = byteCount - MemoryLayout<Self>.size
242243
if paddingCount < 0 {
243244
self =
244-
unsafe Self.isSigned
245+
unsafe Self.isSigned
245246
? Self(
246247
_unchecked: (), _parsingSigned: &input, endianness: endianness,
247248
byteCount: byteCount)
@@ -250,7 +251,7 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
250251
byteCount: byteCount)
251252
} else {
252253
self =
253-
try unsafe Self.isSigned
254+
try unsafe Self.isSigned
254255
? Self(
255256
_unchecked: (), _parsingSigned: &input, endianness: endianness,
256257
paddingCount: paddingCount)
@@ -330,7 +331,7 @@ extension MultiByteInteger {
330331
_unchecked _: Void, parsing input: inout ParserSpan, endianness: Endianness
331332
) {
332333
self =
333-
unsafe endianness.isBigEndian
334+
unsafe endianness.isBigEndian
334335
? Self(_unchecked: (), _parsingBigEndian: &input)
335336
: Self(_unchecked: (), _parsingLittleEndian: &input)
336337
}
@@ -485,8 +486,8 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
485486
/// - Parameters:
486487
/// - input: The `ParserSpan` to parse from. If parsing succeeds, the start
487488
/// position of `input` is moved forward by `byteCount`.
488-
/// - byteCount: The number of bytes to read the value from.
489489
/// - endianness: The endianness to use when interpreting the parsed value.
490+
/// - byteCount: The number of bytes to read the value from.
490491
/// - Throws: A `ParsingError` if `input` contains fewer than `byteCount`
491492
/// bytes, if the parsed value overflows this integer type, or if the
492493
/// padding bytes are invalid.
@@ -601,7 +602,7 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
601602
endianness: Endianness
602603
) throws(ParsingError) {
603604
let result =
604-
unsafe endianness.isBigEndian
605+
unsafe endianness.isBigEndian
605606
? T(_unchecked: (), _parsingBigEndian: &input)
606607
: T(_unchecked: (), _parsingLittleEndian: &input)
607608
self = try Self(_throwing: result)
@@ -654,7 +655,8 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
654655
parsing input: inout ParserSpan,
655656
storedAs: T.Type
656657
) throws(ParsingError) {
657-
self = try unsafe Self(_throwing: T(truncatingIfNeeded: input.consumeUnchecked()))
658+
self = try unsafe Self(
659+
_throwing: T(truncatingIfNeeded: input.consumeUnchecked()))
658660
}
659661

660662
/// Creates an integer by parsing and converting a value of the given
@@ -678,7 +680,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable {
678680
/// position of `input` is moved forward by the size of this integer.
679681
/// - storageType: The integer type to parse from `input` before conversion
680682
/// to the destination type.
681-
/// - endianness: The endianness to use when interpreting the parsed value.
682683
/// - Throws: A `ParsingError` if `input` does not have enough bytes to store
683684
/// `storageType`, or if converting the parsed value to this integer type
684685
/// overflows.

0 commit comments

Comments
 (0)