Skip to content

Commit b4ab6ef

Browse files
Merge pull request #44228 from JuliaLang/sk/nbsp
- replace non-breaking spaces with plain spaces - use only UNIX line endings (\n) - end text files with single newlines - rewrite whitespace checks in Julia & check for: - trailing non-ASCII whitespace - non-breaking spaces anywhere - non-UNIX line endings - missing trailing newline
2 parents 2d34539 + b07b5ba commit b4ab6ef

File tree

145 files changed

+429
-279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+429
-279
lines changed

.mailmap

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,4 @@ Daniel Karrasch <[email protected]> <[email protected]>
282282
283283

284284
285-
285+

HISTORY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4102,7 +4102,7 @@ Library improvements
41024102
41034103
+ Using colons (`:`) to represent a collection of indices is deprecated. They now must be
41044104
explicitly converted to a specialized array of integers with the `to_indices` function.
4105-
   As a result, the type of `SubArray`s that represent views over colon indices has changed.
4105+
As a result, the type of `SubArray`s that represent views over colon indices has changed.
41064106
41074107
+ Logical indexing is now more efficient. Logical arrays are converted by `to_indices` to
41084108
a lazy, iterable collection of indices that doesn't support indexing. A deprecation

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ docs-revise:
9999

100100
check-whitespace:
101101
ifneq ($(NO_GIT), 1)
102-
@$(JULIAHOME)/contrib/check-whitespace.sh
102+
@$(JULIAHOME)/contrib/check-whitespace.jl
103103
else
104104
$(warn "Skipping whitespace check because git is unavailable")
105105
endif
@@ -472,7 +472,7 @@ endif
472472

473473
# Include all git-tracked filenames
474474
git ls-files >> light-source-dist.tmp
475-
475+
476476
# Include documentation filenames
477477
find doc/_build/html >> light-source-dist.tmp
478478

base/abstractset.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ issetequal(a::AbstractSet, b) = issetequal(a, Set(b))
434434
function issetequal(a, b::AbstractSet)
435435
if haslength(a)
436436
# check b for too many unique elements
437-
length(a) < length(b) && return false
437+
length(a) < length(b) && return false
438438
end
439439
return issetequal(Set(a), b)
440440
end

base/array.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ the `value` that was passed; this means that if the `value` is itself modified,
452452
all elements of the `fill`ed array will reflect that modification because they're
453453
_still_ that very `value`. This is of no concern with `fill(1.0, (5,5))` as the
454454
`value` `1.0` is immutable and cannot itself be modified, but can be unexpected
455-
with mutable values like — most commonly — arrays. For example, `fill([], 3)`
455+
with mutable values like — most commonly — arrays. For example, `fill([], 3)`
456456
places _the very same_ empty array in all three locations of the returned vector:
457457
458458
```jldoctest

base/gmp.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ function digits!(a::AbstractVector{T}, n::BigInt; base::Integer = 10) where {T<:
736736
i, j = firstindex(a)-1, length(s)+1
737737
lasti = min(lastindex(a), firstindex(a) + length(s)-1 - isneg(n))
738738
while i < lasti
739-
# base ≤ 36: 0-9, plus a-z for 10-35
739+
# base ≤ 36: 0-9, plus a-z for 10-35
740740
# base > 36: 0-9, plus A-Z for 10-35 and a-z for 36..61
741741
x = s[j -= 1]
742742
a[i += 1] = base 36 ? (x>0x39 ? x-0x57 : x-0x30) : (x>0x39 ? (x>0x60 ? x-0x3d : x-0x37) : x-0x30)

base/indices.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ A linear indexing style uses one integer index to describe the position in the a
2323
(even if it's a multidimensional array) and column-major
2424
ordering is used to efficiently access the elements. This means that
2525
requesting [`eachindex`](@ref) from an array that is `IndexLinear` will return
26-
a simple one-dimensional range, even if it is multidimensional.
26+
a simple one-dimensional range, even if it is multidimensional.
2727
2828
A custom array that reports its `IndexStyle` as `IndexLinear` only needs
2929
to implement indexing (and indexed assignment) with a single `Int` index;
30-
all other indexing expressions — including multidimensional accesses — will
30+
all other indexing expressions — including multidimensional accesses — will
3131
be recomputed to the linear index. For example, if `A` were a `2×3` custom
3232
matrix with linear indexing, and we referenced `A[1, 3]`, this would be
3333
recomputed to the equivalent linear index and call `A[5]` since `2*1 + 3 = 5`.
@@ -50,13 +50,13 @@ a range of [`CartesianIndices`](@ref).
5050
5151
A `N`-dimensional custom array that reports its `IndexStyle` as `IndexCartesian` needs
5252
to implement indexing (and indexed assignment) with exactly `N` `Int` indices;
53-
all other indexing expressions — including linear indexing — will
53+
all other indexing expressions — including linear indexing — will
5454
be recomputed to the equivalent Cartesian location. For example, if `A` were a `2×3` custom
5555
matrix with cartesian indexing, and we referenced `A[5]`, this would be
5656
recomputed to the equivalent Cartesian index and call `A[1, 3]` since `5 = 2*1 + 3`.
5757
5858
It is significantly more expensive to compute Cartesian indices from a linear index than it is
59-
to go the other way. The former operation requires division — a very costly operation — whereas
59+
to go the other way. The former operation requires division — a very costly operation — whereas
6060
the latter only uses multiplication and addition and is essentially free. This asymmetry means it
6161
is far more costly to use linear indexing with an `IndexCartesian` array than it is to use
6262
Cartesian indexing with an `IndexLinear` array.

base/missing.jl

-1
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,3 @@ macro coalesce(args...)
463463
end
464464
return esc(:(let val; $expr; end))
465465
end
466-

base/pkgid.jl

-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,3 @@ function binunpack(s::String)
4242
name = read(io, String)
4343
return PkgId(UUID(uuid), name)
4444
end
45-

base/randomdevice.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ function _make_uint_seed()
7474
catch
7575
return _ad_hoc_entropy() % Cuint
7676
end
77-
end
77+
end

base/reflection.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ Alternatively, in isolation `m1` and `m2` might be ordered, but if a third
15461546
method cannot be sorted with them, they may cause an ambiguity together.
15471547
15481548
For parametric types, the `ambiguous_bottom` keyword argument controls whether
1549-
`Union{}` counts as an ambiguous intersection of type parameters – when `true`,
1549+
`Union{}` counts as an ambiguous intersection of type parameters – when `true`,
15501550
it is considered ambiguous, when `false` it is not.
15511551
15521552
# Examples

base/ryu/LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
2222
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
2323
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
2424
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25-
DEALINGS IN THE SOFTWARE.
25+
DEALINGS IN THE SOFTWARE.

base/strings/basic.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ about strings:
1616
* Each `AbstractChar` in a string is encoded by one or more code units
1717
* Only the index of the first code unit of an `AbstractChar` is a valid index
1818
* The encoding of an `AbstractChar` is independent of what precedes or follows it
19-
* String encodings are [self-synchronizing] – i.e. `isvalid(s, i)` is O(1)
19+
* String encodings are [self-synchronizing] – i.e. `isvalid(s, i)` is O(1)
2020
2121
[self-synchronizing]: https://en.wikipedia.org/wiki/Self-synchronizing_code
2222
@@ -46,8 +46,8 @@ AbstractString
4646
ncodeunits(s::AbstractString) -> Int
4747
4848
Return the number of code units in a string. Indices that are in bounds to
49-
access this string must satisfy `1 ≤ i ≤ ncodeunits(s)`. Not all such indices
50-
are valid – they may not be the start of a character, but they will return a
49+
access this string must satisfy `1 ≤ i ≤ ncodeunits(s)`. Not all such indices
50+
are valid – they may not be the start of a character, but they will return a
5151
code unit value when calling `codeunit(s,i)`.
5252
5353
# Examples
@@ -389,7 +389,7 @@ length(s::AbstractString) = @inbounds return length(s, 1, ncodeunits(s)::Int)
389389
function length(s::AbstractString, i::Int, j::Int)
390390
@boundscheck begin
391391
0 < i ncodeunits(s)::Int+1 || throw(BoundsError(s, i))
392-
0  j < ncodeunits(s)::Int+1 || throw(BoundsError(s, j))
392+
0 j < ncodeunits(s)::Int+1 || throw(BoundsError(s, j))
393393
end
394394
n = 0
395395
for k = i:j
@@ -438,8 +438,8 @@ thisind(s::AbstractString, i::Integer) = thisind(s, Int(i))
438438
function thisind(s::AbstractString, i::Int)
439439
z = ncodeunits(s)::Int + 1
440440
i == z && return i
441-
@boundscheck 0  i z || throw(BoundsError(s, i))
442-
@inbounds while 1 < i && !(isvalid(s, i)::Bool)
441+
@boundscheck 0 i z || throw(BoundsError(s, i))
442+
@inbounds while 1 < i && !(isvalid(s, i)::Bool)
443443
i -= 1
444444
end
445445
return i
@@ -498,7 +498,7 @@ function prevind(s::AbstractString, i::Int, n::Int)
498498
z = ncodeunits(s) + 1
499499
@boundscheck 0 < i z || throw(BoundsError(s, i))
500500
n == 0 && return thisind(s, i) == i ? i : string_index_err(s, i)
501-
while n > 0 && 1 < i
501+
while n > 0 && 1 < i
502502
@inbounds n -= isvalid(s, i -= 1)
503503
end
504504
return i - n
@@ -557,7 +557,7 @@ function nextind(s::AbstractString, i::Int, n::Int)
557557
z = ncodeunits(s)
558558
@boundscheck 0 i z || throw(BoundsError(s, i))
559559
n == 0 && return thisind(s, i) == i ? i : string_index_err(s, i)
560-
while n > 0 && i < z
560+
while n > 0 && i < z
561561
@inbounds n -= isvalid(s, i += 1)
562562
end
563563
return i + n

base/strings/io.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function show(
209209

210210
# early out for short strings
211211
len = ncodeunits(str)
212-
len  limit - 2 && # quote chars
212+
len limit - 2 && # quote chars
213213
return show(io, str)
214214

215215
# these don't depend on string data

base/strings/string.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function getindex_continued(s::String, i::Int, u::UInt32)
247247
end
248248
n = ncodeunits(s)
249249

250-
(i += 1) > n && @goto ret
250+
(i += 1) > n && @goto ret
251251
@inbounds b = codeunit(s, i) # cont byte 1
252252
b & 0xc0 == 0x80 || @goto ret
253253
u |= UInt32(b) << 16
@@ -287,7 +287,7 @@ length(s::String) = length_continued(s, 1, ncodeunits(s), ncodeunits(s))
287287
@inline function length(s::String, i::Int, j::Int)
288288
@boundscheck begin
289289
0 < i ncodeunits(s)+1 || throw(BoundsError(s, i))
290-
0  j < ncodeunits(s)+1 || throw(BoundsError(s, j))
290+
0 j < ncodeunits(s)+1 || throw(BoundsError(s, j))
291291
end
292292
j < i && return 0
293293
@inbounds i, k = thisind(s, i), i
@@ -300,21 +300,21 @@ end
300300
@inbounds b = codeunit(s, i)
301301
@inbounds while true
302302
while true
303-
(i += 1)  n || return c
304-
0xc0  b  0xf7 && break
303+
(i += 1) n || return c
304+
0xc0 b 0xf7 && break
305305
b = codeunit(s, i)
306306
end
307307
l = b
308308
b = codeunit(s, i) # cont byte 1
309309
c -= (x = b & 0xc0 == 0x80)
310310
x & (l 0xe0) || continue
311311

312-
(i += 1)  n || return c
312+
(i += 1) n || return c
313313
b = codeunit(s, i) # cont byte 2
314314
c -= (x = b & 0xc0 == 0x80)
315315
x & (l 0xf0) || continue
316316

317-
(i += 1)  n || return c
317+
(i += 1) n || return c
318318
b = codeunit(s, i) # cont byte 3
319319
c -= (b & 0xc0 == 0x80)
320320
end

base/strings/substring.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct SubString{T<:AbstractString} <: AbstractString
2525
ncodeunits::Int
2626

2727
function SubString{T}(s::T, i::Int, j::Int) where T<:AbstractString
28-
i  j || return new(s, 0, 0)
28+
i j || return new(s, 0, 0)
2929
@boundscheck begin
3030
checkbounds(s, i:j)
3131
@inbounds isvalid(s, i) || string_index_err(s, i)

base/ttyhascolor.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ end
2424
in(key_value::Pair{Symbol,Bool}, ::TTY) = key_value.first === :color && key_value.second === get_have_color()
2525
haskey(::TTY, key::Symbol) = key === :color
2626
getindex(::TTY, key::Symbol) = key === :color ? get_have_color() : throw(KeyError(key))
27-
get(::TTY, key::Symbol, default) = key === :color ? get_have_color() : default
27+
get(::TTY, key::Symbol, default) = key === :color ? get_have_color() : default

contrib/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Installation
66
|[ mac/ ](https://github.com/JuliaLang/julia/blob/master/contrib/mac/) | Mac install files |
77
|[ windows/ ](https://github.com/JuliaLang/julia/blob/master/contrib/windows/) | Windows install files |
88
|[ add_license_to_files.jl ](https://github.com/JuliaLang/julia/blob/master/contrib/add_license_to_files.jl ) | Add the Julia license to files in the Julia Project |
9-
|[ check-whitespace.sh ](https://github.com/JuliaLang/julia/blob/master/contrib/check-whitespace.sh) | Check for trailing white space |
9+
|[ check-whitespace.jl ](https://github.com/JuliaLang/julia/blob/master/contrib/check-whitespace.jl) | Check for white space issues |
1010
|[ commit-name.sh ](https://github.com/JuliaLang/julia/blob/master/contrib/commit-name.sh) | Computes a version name for a commit |
1111
|[ fixup-libgfortran.sh ](https://github.com/JuliaLang/julia/blob/master/contrib/fixup-libgfortran.sh) | Include libgfortran and libquadmath for installations |
1212
|[ fixup-libstdc++.sh ](https://github.com/JuliaLang/julia/blob/master/contrib/fixup-libstdc++.sh) | Include libstdc++ for installations |

contrib/check-whitespace.jl

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env julia
2+
3+
const patterns = split("""
4+
*.1
5+
*.c
6+
*.cpp
7+
*.h
8+
*.inc
9+
*.jl
10+
*.lsp
11+
*.make
12+
*.md
13+
*.mk
14+
*.rst
15+
*.scm
16+
*.sh
17+
*.yml
18+
*Makefile
19+
""")
20+
21+
const errors = Set{Tuple{String,Int,String}}()
22+
23+
for path in eachline(`git ls-files -- $patterns`)
24+
lineno = 0
25+
non_blank = 0
26+
27+
file_err(msg) = push!(errors, (path, 0, msg))
28+
line_err(msg) = push!(errors, (path, lineno, msg))
29+
30+
for line in eachline(path, keep=true)
31+
lineno += 1
32+
contains(line, '\r') && file_err("non-UNIX line endings")
33+
contains(line, '\ua0') && line_err("non-breaking space")
34+
endswith(line, '\n') || line_err("no trailing newline")
35+
line = chomp(line)
36+
endswith(line, r"\s") && line_err("trailing whitespace")
37+
contains(line, r"\S") && (non_blank = lineno)
38+
end
39+
non_blank < lineno && line_err("trailing blank lines")
40+
end
41+
42+
if isempty(errors)
43+
println(stderr, "Whitespace check found no issues.")
44+
exit(0)
45+
else
46+
println(stderr, "Whitespace check found $(length(errors)) issues:")
47+
for (path, lineno, msg) in sort!(collect(errors))
48+
if lineno == 0
49+
println(stderr, "$path -- $msg")
50+
else
51+
println(stderr, "$path:$lineno -- $msg")
52+
end
53+
end
54+
exit(1)
55+
end

contrib/check-whitespace.sh

-39
This file was deleted.

contrib/fixup-libgfortran.sh

-1
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,3 @@ for lib in libopenblas libcholmod liblapack $SONAMES; do
160160
done
161161
done
162162
done
163-

contrib/mac/frameworkapp/JuliaLauncher/Assets.xcassets/AppIcon.appiconset/Contents.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@
6565
"version" : 1,
6666
"author" : "xcode"
6767
}
68-
}
68+
}

contrib/mac/frameworkapp/JuliaLauncher/Assets.xcassets/Contents.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"version" : 1,
44
"author" : "xcode"
55
}
6-
}
6+
}

contrib/mac/frameworkapp/installresources/conclusion.rtf

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ Conclusion\
7777
\f1 \cb1 \
7878
\pard\pardeftab720\partightenfactor0
7979

80-
\f2 \cf0 \cb2 ln -s INSTALL_LOCATION/Julia.framework/Helpers/julia DIR_IN_PATH/julia}
80+
\f2 \cf0 \cb2 ln -s INSTALL_LOCATION/Julia.framework/Helpers/julia DIR_IN_PATH/julia}

contrib/mac/frameworkapp/installresources/readme.rtf

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ Readme\
2828
\f2 \cb2 $HOME
2929
\f1 \cb1 usually expands to
3030
\f2 \cb2 /Users/username
31-
\f1 \cb1 ).}
31+
\f1 \cb1 ).}

contrib/relative_path.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
# shells and whatnot during the build are all POSIX shells/cygwin. We rely on the build
88
# system itself to canonicalize to `\` when it needs to, and deal with the shell escaping
99
# and whatnot at the latest possible moment.
10-
sys.stdout.write(os.path.relpath(sys.argv[2], sys.argv[1]).replace(os.path.sep, '/'))
10+
sys.stdout.write(os.path.relpath(sys.argv[2], sys.argv[1]).replace(os.path.sep, '/'))

0 commit comments

Comments
 (0)