There are some systems that have usernames of the form DOMAIN\username,
which causes an invalid escape character to be inserted. I was going to
add some escaping, but decided it would be best to just outright set the
value, since I don't want the DOMAIN portion in there anyways.
I'm not sure whether to go for signed or unsigned types for the offsets, but
without a doubt size_t is a better alternative than uint32_t. Added casts
after checking bounds before and after calling external libraries (in this
case libuv).
The `job_stop` function was calling `uv_read_stop` on the std{out,err} streams.
This is now responsibility of `RStream` and because of those calls `job_stop`
wasn't emitting the `JobExit` event.
Instead of a single 'job read' callback, job control consumers need to provide
callbacks for "stdout read", "stderr read" and "exit". For vimscript, the
JobActivity autocommand is still used to handle every job event, for example:
```vim
:let srv1_id = jobstart('netcat-server-1', 'nc', ['-l', '9991'])
:let srv2_id = jobstart('netcat-server-2', 'nc', ['-l', '9991'])
function JobEvent()
" v:job_data[0] = the job id
" v:job_data[1] = the event type, one of "stdout", "stderr" or "exit"
" v:job_data[2] = data read from stdout or stderr
if v:job_data[1] == 'stdout'
let str = 'Message from job '.v:job_data[0].': '.v:job_data[2]
elseif v:job_data[1] == 'stderr'
let str = 'Error message from job '.v:job_data[0].': '.v:job_data[2]
else
" Exit
let str = 'Job '.v:job_data[0].' exited'
endif
call append(line('$'), str)
endfunction
au JobActivity netcat-server-* call JobEvent()
```
And to see messages from 'job 1', run in another terminal:
```sh
bash -c "while true; do echo 123; sleep 1; done" | nc localhost 9991
```
RStream will be the main way Neovim receives asynchronous messages, so it is
best to have a specialized EventType for it. A new flag parameter was added to
`rstream_new` which tells the RStream instance to defer event handling for later
with KE_EVENT instead of handling it directly from libuv callback.
Possible bug reported by @oni-link [here](https://github.com/neovim/neovim/pull/485/files#r11664573).
It was handled by doing a circular walk through a key buffer and saving the
index between calls with a static variable.
Also replaced some `char_u` occurrences by `uint8_t` and removed unused
headers in input.c module.
Dependencies are now hosted in a github repository and this brings two advantages:
- Improved build time with travis since we no longer have to build each
dependency
- Less chance of build errors due to external servers being down since Github is
now the single point of failure
The `RStream` class hides the differences between files and other types of
streams with a simpler, general-purpose API for performing non-blocking reads
with libuv. Most of the code was adapted from input.c.