aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
Commit message (Collapse)AuthorAge
...
* Windows: is_executable(): do not check exec bit.Rui Abreu Ferreira2015-08-23
| | | | | | | | | In Windows there is no equivalent to the filesystem executable bit; the documentation states that for Windows :executable() returns 1 for all files. But this behaviour was broken because is_executable() checked for the UNIX bit. When WIN32 is defined we now skip the S_IXUSR check.
* os/fs.c: remove os_file_is_readonly()Justin M. Keyes2015-08-17
| | | | | | | | | | | | | | | | | | | os_file_is_readonly() in its current form is equivalent to !os_file_is_writable(). This does not appear to be a bug, because Vim's use of check_file_readonly() (which we changed to os_file_is_readonly()) is equivalent to !os_file_is_writable() in every case. os_file_is_readonly() also fails this test: returns false if the file is non-read, non-write A more useful form would define behavior under these cases: - path is executable (but not writable) - path is non-existent - path is directory But there is no reason for os_file_is_readonly() to exist, so remove it.
* os_file_is_*: libuv implJustin M. Keyes2015-08-17
| | | | | | - uv_fs_access() is far more robust than access(). In particular, it handles utf16 paths (Windows). - Still need R_OK, W_OK in win_defs.h
* win_defs.h: define R_OK, W_OK for MSVC.Rui Abreu Ferreira2015-08-17
|
* fs.c: implement os_file_is_readable()Justin M. Keyes2015-08-17
| | | | | | | Use access() because: - We already use it for os_file_is_writable() - Vim's old check_file_readonly() ends up using access() after all.
* eval: Fix jobwait() to process multiple jobs concurrentlyThiago de Arruda2015-08-13
| | | | | | | | | | | | | The new event processing architecture changed `jobwait()` semantics: Only one job is processed at time since process_wait only focuses on one queue. This fixes the problem with a few changes: - Allow the event queue polled by `process_wait` to be overriden by a new argument. - Allow the parent queue to be overriden with `queue_replace_parent` - Create a temporary queue that serves as the parent for all jobs passed to `jobwait()`
* rstream: Pass read count to read eventsThiago de Arruda2015-08-13
| | | | This is necessary to keep events in the same order received from the OS.
* event: Refactor async event processingThiago de Arruda2015-08-13
| | | | | | | | | | - Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
* process: Pass loop reference during initializationThiago de Arruda2015-08-13
| | | | | Change the API so that it is passed to {uv,pty}_process_init instead of `process_spawn`.
* loop: Simplify loop.c and move some code to input.cThiago de Arruda2015-08-13
| | | | | | - Declare poll timer in Loop structure instead of a loop_poll_events local variable. - Move deferred event management to input.c
* shell.c: A full RBuffer with no NL can freeze shell output. #3156oni-link2015-08-11
| | | | | | | | | | | | | | | out_data_cb() can return without emptying the full RBuffer (no NL was seen). Because the shell output stream is stopped until space in the Rbuffer is freed up, no more shell output is written. To prevent this, output the full RBuffer when write_output() did not write anything. write_output() can also process the same RBuffer content more than once, if no NL was seen. To prevent NUL bytes from producing new lines (if lines are not written to a buffer), translate NUL to SOH(1). Fixes #2983
* os_get_user_name() for non UNIX system #2729Rui Abreu Ferreira2015-08-04
| | | | | | | | os_get_user_name() requires getuid(), which is only available in UNIX. Return FAIL for non UNIX systems. On FAIL os_get_user_name() fills the buffer with the uid. In Windows libuv uses 0 for uid in stat structs, so 0 is used here too.
* os/fs: Move mkdir_recurse from eval.c to os/fs.cZyX2015-07-26
|
* os/fs: Define os_strerror as an alias to uv_strerrorZyX2015-07-26
| | | | It is not needed to know that os/* uses libuv.
* job: Replace by a better process abstraction layerThiago de Arruda2015-07-17
| | | | | | | | | | | | | - New libuv/pty process abstraction with simplified API and no globals. - Remove nvim/os/job*. Jobs are now a concept that apply only to programs spawned by vimscript job* functions. - Refactor shell.c/channel.c to use the new module, which brings a number of advantages: - Simplified API, less code - No slots in the user job table are used - Not possible to acidentally receive data from vimscript - Implement job table in eval.c, which is now a hash table with unilimited job slots and unique job ids.
* rstream/wstream: Unify structures and simplify APIThiago de Arruda2015-07-17
| | | | | | | | | | | | | - Simplify RStream/WStream API and make it more consistent with libuv. - Move into the event loop layer(event subdirectory) - Remove uv_helpers module. - Simplify job/process internal modules/API. - Unify RStream and WStream into a single structure. This is necessary because libuv streams can be readable and writable at the same time(and because the uv_helpers.c hack to associate multiple streams with libuv handle was removed) - Make struct definition public, allowing more flexible/simple memory management by users of the module. - Adapt channel/job modules to cope with the changes.
* event loop: New abstraction layer with refactored time/signal APIThiago de Arruda2015-07-17
| | | | | | | | | | - Add event loop abstraction module under src/nvim/event. The src/nvim/event/loop module replaces src/nvim/os/event - Remove direct dependency on libuv signal/timer API and use the new abstraction instead. - Replace all references to uv_default_loop() by &loop.uv, a new global variable that wraps libuv main event loop but allows the event loop functions to be reused in other contexts.
* Remove dead WIFSTOPPED and WIFCONTINUED checksFredrik Fornwall2015-07-13
| | | | | | | | | These macros would never return true since the preceding waitpid() call did not specify the WUNTRACED or WCONTINUED options (which is correct since we only care for processes that exited here). Besides removing dead code, this improves portability since WIFCONTINUED is not defined on all platforms.
* os/*defs: restore some comments and formatting.Justin M. Keyes2015-07-06
|
* refactor: remove SYS_MENU_FILE (unused)Yamakaky2015-07-06
|
* Split os_unix_defs.h into os/Yamakaky2015-07-06
|
* rbuffer: Reimplement as a ring buffer and decouple from rstreamThiago de Arruda2015-07-01
| | | | | | | | | | | | | | | | | | | | Extract the RBuffer class from rstream.c and reimplement it as a ring buffer, a more efficient version that doesn't need to relocate memory. The old rbuffer_read/rbuffer_write interfaces are kept for simple reading/writing, and the RBUFFER_UNTIL_{FULL,EMPTY} macros are introduced to hide wrapping logic when more control is required(such as passing the buffer pointer to a library function that writes directly to the pointer) Also add a basic infrastructure for writing helper C files that are only compiled in the unit test library, and use this to write unit tests for RBuffer which contains some macros that can't be accessed directly by luajit. Helped-by: oni-link <knil.ino@gmail.com> Reviewed-by: oni-link <knil.ino@gmail.com> Reviewed-by: Scott Prager <splinterofchaos@gmail.com> Reviewed-by: Justin M. Keyes <justinkz@gmail.com> Reviewed-by: Michael Reed <m.reed@mykolab.com>
* rstream: Fix bug triggered when libuv doesn't use the allocated bufferoni-link2015-07-01
| | | | | Libuv will return 0 to signal that the buffer allocated by `alloc_cb` wasn't used, and in this case the read_cb should simply be ignored.
* klib: Improve klist.hThiago de Arruda2015-07-01
| | | | | | | | | | | - Add `kl_shift_at` macro and backing function. This can be used to shift elements at arbitrary positions. `kl_shift` is now defined on top of the new macro. - Change shift/push API, now `kl_push` accepts an object as parameter and `kl_shift` returns the object instead of a status. An assertion against shifting at the end of a list(or empty lists) was added. - Add `kl_iter` and `kl_iter_at` macros. `kl_iter_at` is for starting the iteration at arbitrary positions.
* os/fs: Use module-local uv_loop_t instanceThiago de Arruda2015-07-01
| | | | | | This event loop is just a stub instance used in synchronous libuv function calls, it needs to be decoupled from the main event loop in order to run it from another thread.
* Fix warnings: shell.c: do_os_system(): Nonnull passed null: FP. #2923Eliseo Martínez2015-06-28
| | | | | | | | | | | | Problem : Argument with 'nonnull' attribute passed null @ 203. Diagnostic : False positive. Rationale : Problem is supposed to appear when argv[0] is NULL within do_os_system. But argv is being generated by shell_build_argv(), which implies argv[0] is the current value for 'shell' option. Now, option has a non-null default ($SHELL or "sh"), and, if set by the user, it can be empty, but not NULL. So, argv[0] can never be NULL. Resolution : Assert shell_build_argv() postcondition.
* event_teardown(): retry uv_loop_close() instead of abort. #2903oni-link2015-06-25
| | | | | | | | | | | | | | | | | | | | | | | abort() causes a bad exit; retry uv_loop_close() instead. Before this change, this ruby script will cause nvim to abort() instead of exiting cleanly: ``` require 'open3' require 'base64' Open3.popen3('nvim --embed -u -NONE') {|stdin, stdout, stderr, wait_thr| # base64-encoded msgpack message for the vim_command "qa!". stdin.write Base64.decode64('kwKrdmltX2NvbW1hbmSRo3FhIQ==') puts wait_thr.value } ``` References ##2663 Closes #2466 Closes #2648 Helped-by: Rui Abreu Ferreira <raf-ep@gmx.com>
* getenv: return NULL if empty #2574Scott Prager2015-05-29
| | | | | | Making an environment variable empty can be a way of unsetting it for platforms that don't support unsetenv(). In most cases, we treat empty variables as having been unset. For all others, use os_env_exists().
* input: rename input_{start,stop}_stdin()Justin M. Keyes2015-05-27
| | | | | - "stdin" is misleading because it may read from stdout or stderr - also remove some unused includes
* input: stream_set_blocking(): libuv implJustin M. Keyes2015-05-27
| | | | | | | | | - Create a private libuv loop instead of re-using uv_default_loop(), to avoid conflict[1] with existing watcher(s) on the fd. - Expose the global "input" fd as a getter instead of a mutable global. [1] .deps/build/src/libuv/src/unix/core.c:833: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
* input: set input stream to blocking on exitJustin M. Keyes2015-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If stdin is non-blocking, many tools (e.g. cat(1), read(1)) which assume that stdin is blocking, will break in odd ways: read: read error: 0: Resource temporarily unavailable cat: -: Resource temporarily unavailable rm: error closing file libuv puts stdin in nonblocking mode, and leaves it that way at exit (this is apparently by design). So, before this commit, this always works (because the shell clobbers O_NONBLOCK): $ nvim --cmd q $ read ...but these forms do _not_ work: $ nvim --cmd q && read $ echo foo | nvim --cmd q && read $ nvim && read After this commit, all of the above forms work. Background: https://github.com/fish-shell/fish-shell/commit/437b4397b9cf273922ce7b414bf6626845f15ad0#diff-41f4d294430cd8c36538999d62681ae2 https://github.com/fish-shell/fish-shell/issues/176#issuecomment-15800155 - bash (and other shells: zsh, tcsh, fish), upon returning to the foreground, always sets fd 0 back to blocking mode. This practice only applies to stdin, _not_ stdout or stderr (in practice these fds may be affected anyways). - bash/zsh/tcsh/fish do _not_ restore the non-blocking status of stdin when _resuming a job_. - We do _not_ save/restore the original flags visible to fcntl(F_[SG]ETFL), because (counterintuitively) that isn't expected. Helped-by: oni-link <knil.ino@gmail.com> Closes #2086 Closes #2377 --- Note: The following implementation of stream_set_blocking() was discarded, because it resulted in a failed libuv assertion[1]: int stream_set_blocking(int fd, bool blocking) { uv_pipe_t stream; uv_pipe_init(uv_default_loop(), &stream, 0); uv_pipe_open(&stream, fd); int retval = uv_stream_set_blocking((uv_stream_t *)&stream, blocking); uv_close((uv_handle_t *)&stream, NULL); return retval; } [1] .deps/build/src/libuv/src/unix/core.c:833: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
* Rename var eof as input_eof #2728Rui Abreu Ferreira2015-05-24
| | | | | - In Windows eof is a function, renamed the eof var in input.c to input_eof
* Add guard for sys/wait.h header in job.c #2686Rui Abreu Ferreira2015-05-21
| | | | | The sys/wait.h include was moved after the vim.h include, since the include guards are defined in config.h the guards cannot be used earlier.
* Remove char_u: message:smsg()Michael Reed2015-05-13
|
* os/input.c: Eliminate conversion warning from gcc 5 #2617Björn Linse2015-05-09
|
* Merge 'p' declaration with init in vim_version_dir()Mark Bainter2015-05-06
|
* Remove char_u: concat_fnames()Mark Bainter2015-05-06
|
* unify jobstart, termopen, and system interfacesScott Prager2015-05-02
| | | | | | | | | | | | | | | | | For any of these functions, if {cmd} is a string, execute "&shell &shellcmdflag '{cmd}'", or simply {cmd} if it's a list. In termopen(), if the 'name' option is not supplied, try to guess using '{cmd}' (string) or {cmd}[0] (list). Simplify ex_terminal to use the string form of termopen(). termopen: get name from argument Convert list_to_argv to tv_to_argv. Helped-by: Björn Linse <@bfredl> Helped-by: oni-link <knil.ino@gmail.com> Helped-by: Thiago de Arruda <@tarruda>
* Enable -Wconversion: normal.c.Eliseo Martínez2015-04-27
| | | | | | | | | | | | | | | | | | | | | | | | Refactor summary: - extern int opcount --> extern long opcount - bool find_decl(..., int len, ...) --> bool find_decl(..., size_t len, ...) * int find_ident_under_cursor(...) --> size_t find_ident_under_cursor(...) - int find_ident_at_pos(...) --> size_t find_ident_at_pos(...) - int modify_fname(..., int *usedlen, ..., int *fnamelen) --> int modify_fname(..., size_t *usedlen, ..., size_t *fnamelen) * char_u *eval_vars(..., int *usedlen, ...) --> char_u *eval_vars(..., size_t *usedlen, ...) - int find_cmdline_var(..., int *usedlen) --> ssize_t find_cmdline_var(..., size_t *usedlen) - static char_u *repl_cmdline(..., int srclen, ...) --> static char_u *repl_cmdline(..., size_t srclen, ...) - bool get_visual_text(..., int *lenp) --> bool get_visual_text(..., size_t *lenp) * char_u *find_file_name_in_path(..., int len, ...) --> char_u *find_file_name_in_path(..., size_t len, ...) - static char_u *eval_includeexpr(..., int len) --> static char_u *eval_includeexpr(..., size_t len) - char_u *find_file_in_path(..., int len, ...) --> char_u *find_file_in_path(..., size_t len, ...) * char_u *find_file_in_path_option(..., int len, ...) --> char_u *find_file_in_path_option(..., size_t len, ...) - char_u *find_directory_in_path(..., int len, ...) --> char_u *find_directory_in_path(..., size_t len, ...) * int spell_move_to(...) --> size_t spell_move_to(...) - int spell_check(...) --> size_t spell_check(...) - static int spell_bad_len --> static size_t spell_bad_len - void find_pattern_in_path(..., int len, ...) --> void find_pattern_in_path(..., size_t len, ...) Helped-by: Justin M. Keyes <justinkz@gmail.com>
* TAB0 might not be defined in termios.h #2483Rui Abreu Ferreira2015-04-23
| | | | | - OpenBSD termios.h does not have TAB0, skip its use if it is not defined
* Refactor get_env() to respect const qualifierMark Bainter2015-04-18
| | | | | | Without the casts*, the compiler rightly warns about the os_getenv losing the qualifier. This refactor adds a variable to manage this properly, and renames the original variables to increase clarity.
* Remove char_u: vim_setenv()Mark Bainter2015-04-18
|
* Remove char_u: vim_getenv()Mark Bainter2015-04-17
|
* Remove char_u: after_pathstep()Mark Bainter2015-04-17
| | | | See: #459
* Implement os_unsetenv()Rui Abreu Ferreira2015-04-14
| | | | | | | - In UNIX systems where unsetenv() is available, it is used. Otherwise the variables are set with the empty string. - New check HAVE_UNSETENV for unsetenv() - Added unit test to env_spec.lua
* memory: Add `free` wrapper and refactor project to use itThiago de Arruda2015-04-13
| | | | | | We already use wrappers for allocation, the new `xfree` function is the equivalent for deallocation and provides a way to fully replace the malloc implementation used by Neovim.
* memory: Replace klib memory pools by malloc/freeThiago de Arruda2015-04-12
| | | | | | Klib pools were used to improve allocation efficiency for some small objects, but it is not a thread-safe approach. Thread safety in allocations will be required for implementing #2371).
* remove char_u: vim_version_dir #2414Mark Bainter2015-04-12
| | | | See: #459
* refactor remove_tail() function to no longer use char_u #2413Mark Bainter2015-04-12
| | | | See #459
* Refactor default_vim{,runtime}_dir to use char type. #2375Mark Bainter2015-04-12
| | | | | | See: #459 Reviewed-by: Justin M. Keyes <justinkz@gmail.com> Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>