Skip to content

Remove non-inclusive language #2954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2020
Merged
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
8 changes: 4 additions & 4 deletions Sources/PackageLoading/Target+PkgConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ public func pkgConfigArgs(for target: SystemLibraryTarget, diagnostics: Diagnost
fileSystem: fileSystem,
brewPrefix: brewPrefix)

// Run the whitelist checker.
let filtered = whitelist(pcFile: pkgConfigName, flags: (pkgConfig.cFlags, pkgConfig.libs))
// Run the allow list checker.
let filtered = allowlist(pcFile: pkgConfigName, flags: (pkgConfig.cFlags, pkgConfig.libs))

// Remove any default flags which compiler adds automatically.
let (cFlags, libs) = removeDefaultFlags(cFlags: filtered.cFlags, libs: filtered.libs)

// Set the error if there are any unallowed flags.
var error: Swift.Error?
if !filtered.unallowed.isEmpty {
error = PkgConfigError.nonWhitelistedFlags(filtered.unallowed.joined(separator: ", "))
error = PkgConfigError.prohibitedFlags(filtered.unallowed.joined(separator: ", "))
}

return PkgConfigResult(
Expand Down Expand Up @@ -170,7 +170,7 @@ extension SystemPackageProviderDescription {
/// compiler/linker. List of allowed flags:
/// cFlags: -I, -F
/// libs: -L, -l, -F, -framework, -w
public func whitelist(
public func allowlist(
pcFile: String,
flags: (cFlags: [String], libs: [String])
) -> (cFlags: [String], libs: [String], unallowed: [String]) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/PackageLoadingTests/Inputs/Bar.pc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Name: Foo
URL: http://127.0.0.1/
Description: The one and only SystemModule
Version: 1.10.0
Cflags: -I${includedir} -I/path/to/inc -DBlackListed
Cflags: -I${includedir} -I/path/to/inc -DDenyListed
Libs: -L${libdir} -L/usr/da/lib -lSystemModule -lok
6 changes: 3 additions & 3 deletions Tests/PackageLoadingTests/PkgConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class PkgConfigTests: XCTestCase {
XCTAssertFalse(result.couldNotFindConfigFile)
}

// Pc file with non whitelisted flags.
// Pc file with prohibited flags.
try withCustomEnv(["PKG_CONFIG_PATH": inputsDir.pathString]) {
let result = pkgConfigArgs(for: SystemLibraryTarget(pkgConfig: "Bar"), diagnostics: diagnostics)!
XCTAssertEqual(result.pkgConfigName, "Bar")
Expand All @@ -90,8 +90,8 @@ class PkgConfigTests: XCTestCase {
XCTAssertNil(result.provider)
XCTAssertFalse(result.couldNotFindConfigFile)
switch result.error {
case PkgConfigError.nonWhitelistedFlags(let desc)?:
XCTAssertEqual(desc, "-DBlackListed")
case PkgConfigError.prohibitedFlags(let desc)?:
XCTAssertEqual(desc, "-DDenyListed")
default:
XCTFail("unexpected error \(result.error.debugDescription)")
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/PackageLoadingTests/WhitelistTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
import PackageLoading
import XCTest

final class PkgConfigWhitelistTests: XCTestCase {
final class PkgConfigAllowlistTests: XCTestCase {
func testSimpleFlags() {
let cFlags = ["-I/usr/local/Cellar/gtk+3/3.18.9/include/gtk-3.0"]
let libs = ["-L/usr/local/Cellar/gtk+3/3.18.9/lib", "-lgtk-3", "-w"]
XCTAssertTrue(whitelist(pcFile: "dummy", flags: (cFlags, libs)).unallowed.isEmpty)
XCTAssertTrue(allowlist(pcFile: "dummy", flags: (cFlags, libs)).unallowed.isEmpty)
}

func testFlagsWithInvalidFlags() {
let cFlags = ["-I/usr/local/Cellar/gtk+3/3.18.9/include/gtk-3.0", "-L/hello"]
let libs = ["-L/usr/local/Cellar/gtk+3/3.18.9/lib", "-lgtk-3", "-module-name", "name", "-werror"]
let unallowed = whitelist(pcFile: "dummy", flags: (cFlags, libs)).unallowed
let unallowed = allowlist(pcFile: "dummy", flags: (cFlags, libs)).unallowed
XCTAssertEqual(unallowed, ["-L/hello", "-module-name", "name", "-werror"])
}

func testFlagsWithValueInNextFlag() {
let cFlags = ["-I/usr/local", "-I", "/usr/local/Cellar/gtk+3/3.18.9/include/gtk-3.0", "-L/hello"]
let libs = ["-L", "/usr/lib", "-L/usr/local/Cellar/gtk+3/3.18.9/lib", "-lgtk-3", "-module-name", "-lcool", "ok", "name"]
let unallowed = whitelist(pcFile: "dummy", flags: (cFlags, libs)).unallowed
let unallowed = allowlist(pcFile: "dummy", flags: (cFlags, libs)).unallowed
XCTAssertEqual(unallowed, ["-L/hello", "-module-name", "ok", "name"])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/// - codeUnit: The code unit to be checked.
///
/// - Returns: True if shell escaping is not needed.
private func inShellWhitelist(_ codeUnit: UInt8) -> Bool {
private func inShellAllowlist(_ codeUnit: UInt8) -> Bool {
#if os(Windows)
if codeUnit == UInt8(ascii: "\\") {
return true
Expand Down Expand Up @@ -49,8 +49,8 @@ extension String {
/// - Returns: Shell escaped string.
public func spm_shellEscaped() -> String {

// If all the characters in the string are in whitelist then no need to escape.
guard let pos = utf8.firstIndex(where: { !inShellWhitelist($0) }) else {
// If all the characters in the string are in the allow list then no need to escape.
guard let pos = utf8.firstIndex(where: { !inShellAllowlist($0) }) else {
return self
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@ import TSCLibc
#if os(Windows)
#else
public final class PseudoTerminal {
let master: Int32
let slave: Int32
let primary: Int32
let secondary: Int32
public var outStream: LocalFileOutputByteStream

public init?(){
var master: Int32 = 0
var slave: Int32 = 0
if openpty(&master, &slave, nil, nil, nil) != 0 {
var primary: Int32 = 0
var secondary: Int32 = 0
if openpty(&primary, &secondary, nil, nil, nil) != 0 {
return nil
}
guard let outStream = try? LocalFileOutputByteStream(filePointer: fdopen(slave, "w"), closeOnDeinit: false) else {
guard let outStream = try? LocalFileOutputByteStream(filePointer: fdopen(secondary, "w"), closeOnDeinit: false) else {
return nil
}
self.outStream = outStream
self.master = master
self.slave = slave
self.primary = primary
self.secondary = secondary
}

public func readMaster(maxChars n: Int = 1000) -> String? {
public func readPrimary(maxChars n: Int = 1000) -> String? {
var buf: [CChar] = [CChar](repeating: 0, count: n)
if read(master, &buf, n) <= 0 {
if read(primary, &buf, n) <= 0 {
return nil
}
return String(cString: buf)
}

public func closeSlave() {
_ = TSCLibc.close(slave)
public func closeSecondary() {
_ = TSCLibc.close(secondary)
}

public func closeMaster() {
_ = TSCLibc.close(master)
public func closePrimary() {
_ = TSCLibc.close(primary)
}

public func close() {
closeSlave()
closeMaster()
closeSecondary()
closePrimary()
}
}
#endif
6 changes: 3 additions & 3 deletions swift-tools-support-core/Sources/TSCUtility/PkgConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import Foundation
public enum PkgConfigError: Swift.Error, CustomStringConvertible {
case couldNotFindConfigFile(name: String)
case parsingError(String)
case nonWhitelistedFlags(String)
case prohibitedFlags(String)

public var description: String {
switch self {
case .couldNotFindConfigFile(let name):
return "couldn't find pc file for \(name)"
case .parsingError(let error):
return "parsing error(s): \(error)"
case .nonWhitelistedFlags(let flags):
return "non whitelisted flag(s): \(flags)"
case .prohibitedFlags(let flags):
return "prohibited flag(s): \(flags)"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ final class TerminalControllerTests: XCTestCase {

// Test red color.
term.write("hello", inColor: .red)
XCTAssertEqual(pty.readMaster(), "\u{1B}[31mhello\u{1B}[0m")
XCTAssertEqual(pty.readPrimary(), "\u{1B}[31mhello\u{1B}[0m")

// Test clearLine.
term.clearLine()
XCTAssertEqual(pty.readMaster(), "\u{1B}[2K\r")
XCTAssertEqual(pty.readPrimary(), "\u{1B}[2K\r")

// Test endline.
term.endLine()
XCTAssertEqual(pty.readMaster(), "\r\n")
XCTAssertEqual(pty.readPrimary(), "\r\n")

// Test move cursor.
term.moveCursor(up: 3)
XCTAssertEqual(pty.readMaster(), "\u{1B}[3A")
XCTAssertEqual(pty.readPrimary(), "\u{1B}[3A")

// Test color wrapping.
var wrapped = term.wrap("hello", inColor: .noColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ final class ProgressAnimationTests: XCTestCase {

var output = ""
let thread = Thread {
while let out = terminal.readMaster() {
while let out = terminal.readPrimary() {
output += out
}
}

thread.start()
closure(terminal)
terminal.closeSlave()
terminal.closeSecondary()

// Make sure to read the complete output before checking it.
thread.join()
terminal.closeMaster()
terminal.closePrimary()

return output
}
Expand Down