Эх сурвалжийг харах

iOS: set terminal size and LANG variable on startup

Fuzzer: fix another crash

Remove debugging aid
Miguel de Icaza 5 жил өмнө
parent
commit
7edbf003eb

+ 1 - 1
SwiftSH.binaries

@@ -1 +1 @@
-Subproject commit 74442115cff9caf7cd7bfb17a52ba759f4dbcf26
+Subproject commit 909e4164c720fb2b1305215b3fa04b57f86b98a0

+ 1 - 1
SwiftTerm/Sources/SwiftTerm/Buffer.swift

@@ -27,7 +27,7 @@ class Buffer {
         get { _yBase }
         get { _yBase }
         set {
         set {
             if newValue > _lines.count {
             if newValue > _lines.count {
-                abort ()
+                //abort ()
             }
             }
             _yBase = newValue
             _yBase = newValue
         }
         }

+ 1 - 1
SwiftTerm/Sources/SwiftTerm/Terminal.swift

@@ -3331,7 +3331,7 @@ open class Terminal {
     //
     //
     func cmdScrollDown (_ pars: [Int])
     func cmdScrollDown (_ pars: [Int])
     {
     {
-        let p = max (pars.count == 0 ? 1 : pars [0], 1)
+        let p = min (max (pars.count == 0 ? 1 : pars [0], 1), rows)
         
         
         for _ in 0..<p {
         for _ in 0..<p {
             buffer.lines.splice (start: buffer.yBase + buffer.scrollBottom, deleteCount: 1, items: [])
             buffer.lines.splice (start: buffer.yBase + buffer.scrollBottom, deleteCount: 1, items: [])

+ 2 - 1
SwiftTerm/Sources/SwiftTermFuzz/main.swift

@@ -45,6 +45,7 @@ func testInput (d: Data)
 func testCrashes ()
 func testCrashes ()
 {
 {
     let crashes = [
     let crashes = [
+        "timeout-a9539e3703587af2fe071ece51e17fa168ac6d2d",
         "timeout-c7784cb0fcb8cd15fe71cd670e64a8bd6800a499",
         "timeout-c7784cb0fcb8cd15fe71cd670e64a8bd6800a499",
         "crash-dda8a48c04d1461c3b1cf179ae2f6367c8d4ec7b",
         "crash-dda8a48c04d1461c3b1cf179ae2f6367c8d4ec7b",
         "crash-98664e18a4536bf5b581833b4316b19d30d1fc50",
         "crash-98664e18a4536bf5b581833b4316b19d30d1fc50",
@@ -91,7 +92,7 @@ func testCrashes ()
     ]
     ]
     
     
     for crash in crashes {
     for crash in crashes {
-        let url = URL(fileURLWithPath: "/Users/miguel/cvs/SwiftTerm/\(crash)")
+        let url = URL(fileURLWithPath: "/Users/miguel/cvs/SwiftTerm/results-fuzzer/\(crash)")
         do {
         do {
             print ("Running test \(crash)")
             print ("Running test \(crash)")
             let data = try Data(contentsOf: url)
             let data = try Data(contentsOf: url)

+ 6 - 1
iOS/UIKitSshTerminalView.swift

@@ -26,6 +26,7 @@ public class SshTerminalView: TerminalView, TerminalViewDelegate {
             shell = try? SSHShell(sshLibrary: Libssh2.self,
             shell = try? SSHShell(sshLibrary: Libssh2.self,
                                   host: "192.168.86.78",
                                   host: "192.168.86.78",
                                   port: 22,
                                   port: 22,
+                                  environment: [Environment(name: "LANG", variable: "en_US.UTF-8")],
                                   terminal: "xterm-256color")
                                   terminal: "xterm-256color")
             connect()
             connect()
         } catch {
         } catch {
@@ -51,6 +52,8 @@ public class SshTerminalView: TerminalView, TerminalViewDelegate {
                 if let error = error {
                 if let error = error {
                     self.feed(text: "[ERROR] \(error)\n")
                     self.feed(text: "[ERROR] \(error)\n")
                 } else {
                 } else {
+                    let t = self.getTerminal()
+                    s.setTerminalSize(width: UInt (t.cols), height: UInt (t.rows))
                 }
                 }
             }
             }
         }
         }
@@ -70,7 +73,9 @@ public class SshTerminalView: TerminalView, TerminalViewDelegate {
     }
     }
     
     
     public func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) {
     public func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) {
-        //
+        if let s = shell {
+            s.setTerminalSize(width: UInt (newCols), height: UInt (newRows))
+        }
     }
     }
     
     
     public func send(source: TerminalView, data: ArraySlice<UInt8>) {
     public func send(source: TerminalView, data: ArraySlice<UInt8>) {