Commit Graph

526 Commits

Author SHA1 Message Date
John Hood e0f6eb78ef Improve roundtrip verification tests and debug dump.
Add another round-trip verification.  For both original and generated
state, generate a diff from an initial, empty state.  Verify that
these two diffs are the same.
2015-12-06 17:42:34 -05:00
John Hood 66634eb97c Move grapheme printing from FrameState::append_cell() to Framebuffer::Cell::print_grapheme(). 2015-12-06 17:42:34 -05:00
John Hood 0b51260540 Fix for UTF-8 roundtrip verification bug.
The problem was that the round-trip verification code copies the
current state, which may contain intermediate Parser state for
multibyte characters and ANSI escape sequences.  It then applies diffs
to that copy, which may appear as badly formed input.

Also removes some dead, never-used code.
2015-12-06 17:42:34 -05:00
john hood e4a99256cb Avoid wcwidth(), wcrtomb() and mbrtowc() on ASCII/ISO8859-1 characters.
ASCII <-> UTF has trivial mappings.  Avoid wcrtomb() and mbrtowc().

ISO-8859-1 is all narrow characters, and cheap to test for.  It might
be possible to cheaply test other popular UTF blocks and/or planes as
well.

These two changes get 2-3x faster input processing on Linux and
FreeBSD.  Performance improvement in actual usage is more modest but
still significant.
2015-12-06 17:42:34 -05:00
John Hood f5d814a9c4 Reduce character cell lookups in Emulator::print(). 2015-12-06 17:42:34 -05:00
John Hood 589d21bbf2 Add make_shared emulation for std::tr1::shared_ptr; use make_shared 2015-12-06 17:42:34 -05:00
John Hood b41bad918d Make Terminal::Framebuffer::Rows shared and copy-on-write.
* Support both std:: and std::tr1:: shared_ptr. FreeBSD 10 now uses C++11 by default.
* Remove Framebuffer pointers in STMClient
2015-12-06 17:42:34 -05:00
John Hood c090d257f2 Rework Terminal::Display to improve performance and treat passed Framebuffers as const.
* Refactor put_cell() and parts of new_frame(), and associated state, into put_row().
* Optimize display and line wrap handling code/output.
* Make last_frame a const ref, to eliminate a costly copy of the framebuffer on every screen refresh.
* In new_frame()'s scroll optimization, don't copy rows, use pointers instead.
* Don't check entire frame buffer for scrolling if first line hasn't scrolled.
* Add a generation counter on Row objects to allow quicker/better identification of scroll regions
* Use at() for bounds-checking on framebuffers, because they can be resized.
* Copy and resize scroll buffer on window resize.
2015-12-06 17:42:34 -05:00
John Hood 32afa96111 Change Framebuffer's containers/methods to improve performance.
* Reduce the size of Terminal::Cell.
* Change colors and attributes in Terminal::Rendition to bitfields/bitmask.
* Change Cells to use UTF-8 strings instead of vector<wchar_t>.  Store Rows in a vector instead of a deque.
* Add various Framebuffer::append() methods for more efficient passing of single and repeated characters.
* Change title/icon strings from deques to a vector typedef-- this is more for tidiness than any real performance.
2015-12-06 17:42:34 -05:00
John Hood 8fdcdc88cd Isolated algorithmic improvements.
* Fix inefficient STL use around Parser::UTF8Parser.
* Reduce typeid() usage, change some of it to a virtual method
* Do multiple-line scrolls as a single move
2015-12-06 17:42:34 -05:00
John Hood 3fa42cb8bb Support different IPv4 and IPv6 MTUs.
Closes #688.
2015-11-29 10:31:17 -05:00
John Hood b742e958b6 mosh-server: Support timeouts on lost connectivity to network client.
Closes #690.
2015-11-24 02:36:08 -05:00
Andrew Chin 8b5b7aedfa Make --help or -h work again
Also make --help go to stdout, but everywhere else print_help is used,
     go to stderr

Signed-off-by: Andrew Chin <achin@eminence32.net>
2015-11-01 01:09:00 -04:00
Anders Kaseorg 57e54c46bc Specify syntax = "proto2" to silence warning with protobuf 3
[libprotobuf WARNING google/protobuf/compiler/parser.cc:491] No syntax
specified for the proto file. Please use 'syntax = "proto2";' or
'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2
syntax.)

The release notes say a future release will turn this warning into an
error.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-10-31 23:55:26 -04:00
John Hood 0de4082e86 base64: remove a timing variation 2015-10-20 02:39:36 -04:00
John Hood 0eb614809a Add configurable support for Apple Common Crypto and Nettle libraries. 2015-10-16 19:00:42 -04:00
John Hood db311f92f7 Replace OpenSSL base64 impl with a simple direct impl.
Unit tests, too.
2015-10-16 19:00:42 -04:00
John Hood 3c52091f4d Add window resizing test 2015-10-14 23:28:21 -04:00
John Hood 01749be642 Add test for behavior at column 80. 2015-10-14 23:28:21 -04:00
John Hood fb76563d33 Add multiline-scroll regression test 2015-10-14 23:28:21 -04:00
John Hood 14ae25ee2a Add test for unicode combining fallback assert, issue 667 2015-10-14 23:28:12 -04:00
John Hood 307b241f0d End to end test suite for Mosh sessions.
For original messy development history, see
https://github.com/cgull/mosh/tree/localhost
or
https://github.com/cgull/mosh/commit/e7feed48a4a271e2977f714f58acfa04cdaa5cca
2015-10-14 23:27:29 -04:00
John Hood 5959342ac7 mosh-client: return meaningful exitstatus on network setup/teardown or other failure 2015-10-03 03:43:18 -04:00
John Hood 7fb542c874 Change SSH_CONNECTION fallback to allow IPv6 2015-10-03 03:43:18 -04:00
Keith Winstein 7ec19a5bed terminal.cc: Remove overly-strong assertion on Unicode fallback
Fixes #667
2015-08-24 09:52:39 -07:00
John Hood 310b899a23 Support older getaddrinfo() missing AI_NUMERICSERV
Define this flag as 0 if unavailable.
This is needed for my OS X 10.5 system.

Signed-off-by: John Hood <cgull@glup.org>
2015-06-21 16:14:41 -04:00
Anders Kaseorg 10dd74c016 NotificationEngine: Fix -Weffc++ warning
Fixes warning: ‘Overlay::NotificationEngine::escape_key_string’ should
be initialized in the member initialization list.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-11 01:16:52 -04:00
John Hood d0db0968b1 Enable altivec on ppc64el
From http://launchpadlibrarian.net/171225681/mosh_1.2.4a-1build1_1.2.4a-1ubuntu1.diff.gz

Fixes #615.
2015-06-11 00:55:12 -04:00
John Hood fc80eaaecf Show the escape key properly when server unavailable.
Fixes #624.

Signed-off-by: John Hood <cgull@glup.org>
2015-06-11 00:49:06 -04:00
John Hood 8acee95c02 Resolve Coverity issue with Parser::Transition's ownership of Action *.
This commit is somewhat subtle; it informs Coverity that
Parser::Transition only holds an Action* temporarily, and should never
create/delete one.  I believe runtime checkers should also understand
this OK.

Signed-off-by: John Hood <cgull@glup.org>
2015-06-10 23:52:25 -04:00
John Hood 6f4a59e20f Resolve Coverity issues
Signed-off-by: John Hood <cgull@glup.org>
2015-06-10 23:51:42 -04:00
John Hood 026a3f0346 Resolve cppcheck issues.
Signed-off-by: John Hood <cgull@glup.org>
2015-06-10 23:50:56 -04:00
Keith Winstein 2e4e601468 mosh-server.cc: compare like types.
Fixes #626 (resize not working) introduced by 543f346a
2015-06-09 15:17:48 -07:00
John Hood dd58a398de ocb.cc: Mark local functions as static
This fixes the broken i386 build (aka generic code).
Untested on __ALTIVEC__ and __ARM_NEON__.

Signed-off-by: John Hood <cgull@glup.org>
2015-06-07 17:06:40 -04:00
Anders Kaseorg 90965f175f benchmark: Swap misleading width and height variables
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-06 13:53:05 -04:00
John Hood 543f346ac7 Fix various new compiler warnings.
terminalfunctions.cc: set_if_available() was undeclared.
Fix printf() wint_t/wchar_t warnings.
mosh-server.cc: Fix warning for side effects inside typeid().

Signed-off-by: John Hood <cgull@glup.org>
2015-06-06 13:12:32 -04:00
Anders Kaseorg b604a7d7c2 Respect HOME environment variable if set
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-05 22:53:31 -04:00
Anders Kaseorg 9019f62bf6 Respect SHELL environment variable if set
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-05 22:53:31 -04:00
John Hood 8a91e78349 termemu: respect $SHELL and exec argv if given
Signed-off-by: John Hood <cgull@glup.org>
2015-06-05 22:41:21 -04:00
John Hood 73fd6442c5 Add command line parameters for benchmark. 2015-06-05 22:41:21 -04:00
John Hood 67c22e5065 issue #507: fix/simplify parsing of colors 2015-06-05 00:12:01 -04:00
Anders Kaseorg cd2ae36f36 Mark local functions as static
This helps to catch unused functions like the former mosh_read_line,
allows the compiler to make better inlining decisions, and reduces the
binary size a bit.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:52:03 -04:00
Anders Kaseorg a52b095f50 mosh-server: Remove unused mosh_read_line function
This function is buggy.  feof(file) does not become true until after
we’ve tried to read past the last character; it should instead be
checking the getc return value for EOF (which is distinct from any
unsigned char).  Really it should just be replaced by istream
&std::getline(istream &is, string &str).  Fortunately, it’s unused so
we can just delete it.

Resolves a truncated stdio return value issue found by Coverity Scan
service.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:50:40 -04:00
Anders Kaseorg 0824e6549a base64: Make base64_encode declaration consistent with its definition
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:50:40 -04:00
Anders Kaseorg 8f6b226d8b Base64Key: Deduplicate PRNG code
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:50:40 -04:00
Anders Kaseorg c03bacd0c9 mosh-server: Catch exception for parsing nonintegral number of colors
Print a real error message instead of abnormally aborting.  Found by
Coverity Scan service.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:50:40 -04:00
Anders Kaseorg 23f0eedb8c Parser::UTF8Parser::input: Remove dead code for negative size_t
size_t is unsigned.  Fixes two issues found by the Coverity Scan
service, one about the dead code and one about the std::string
exception being uncaught by mosh-server.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:50:40 -04:00
Geoffrey Thomas a38b6f61d5 STMClient::process_network_input: Return void, instead of always true
This function has never in its history had a codepath returning false.
2015-06-04 23:47:32 -04:00
Geoffrey Thomas 4b75bcfdd9 terminaldisplay: Make a for loop's boundary better match its body
Both f and frame.last_frame must have the same number of rows here, but
since we're iterating over frame.last_frame's rows, make that more
explicit.
2015-06-04 23:47:32 -04:00
Geoffrey Thomas b5ac92491c Throw std::exception subclasses instead of std::strings
Now everything we throw or catch ourselves is a subclass of
std::exception.
2015-06-04 23:47:32 -04:00