aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
Commit message (Collapse)AuthorAge
* docs: miscdundargoc2025-01-30
| | | | | | | | | Co-authored-by: Dustin S. <dstackmasta27@gmail.com> Co-authored-by: Ferenc Fejes <fejes@inf.elte.hu> Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: Yochem van Rosmalen <git@yochem.nl> Co-authored-by: brianhuster <phambinhanctb2004@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* vim-patch:partial:9.1.1050: too many strlen() calls in os_unix.c (#32188)zeertzjq2025-01-24
| | | | | | | | | | | | | | Problem: too many strlen() calls in os_unix.c Solution: refactor os_unix.c and remove calls to strlen() (John Marriott) closes: vim/vim#16496 https://github.com/vim/vim/commit/efc41a5958bf25b352e0916af5f57dafbbb44f17 Omit os_expand_wildcards() change: Nvim's code is more complicated and harder to refactor. Co-authored-by: John Marriott <basilisk@internode.on.net>
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* vim-patch:8.2.0985: simplify() does not remove slashes from "///path"zeertzjq2024-10-13
| | | | | | | | | | | Problem: Simplify() does not remove slashes from "///path". Solution: Reduce > 2 slashes to one. (closes vim/vim#6263) https://github.com/vim/vim/commit/fdcbe3c3fedf48a43b22938c9331addb2f1182f1 Omit Test_readdirex() change: changed again in patch 9.0.0323. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* fix(build): remove USE_FNAME_CASE, redundant with CASE_INSENSITIVE_FILENAMEbfredl2024-10-11
| | | | | It stands to reason, you need to "fix" case-insensitive filenames if-and-only-if you have case-insensitive filenames.
* vim-patch:9.1.0761: :cd completion fails on Windows with backslash in path ↵zeertzjq2024-10-07
| | | | | | | | | | | | | | | | | (#30703) Problem: :cd completion fails on Windows with backslash in path Solution: switch no_bslash argument to FALSE in file_pat_to_reg_pat() Note: only fixes the problem on Windows. For Unix, we still need to escape backslashes since those are taken as regex atoms (and could be invalid regex atoms). fixes: vim/vim#15643 closes: vim/vim#15808 https://github.com/vim/vim/commit/1a31c430bb175144d097ca607dbe10d7960f372a Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:partial:8.1.0914: code related to findfile() is spread out (#30000)zeertzjq2024-08-07
| | | | | | | | | | Problem: Code related to findfile() is spread out. Solution: Put findfile() related code into a new source file. (Yegappan Lakshmanan, closes vim/vim#3934) https://github.com/vim/vim/commit/5fd0f5052f9a312bb4cfe7b4176b1211d45127ee Keep functions related to wildcard expansion in path.c, as in Vim they are now spread out among multiple files, which isn't really ideal.
* vim-patch:9.0.0634: evaluating "expr" options has more overhead than neededzeertzjq2024-08-02
| | | | | | | | | | | | | | | | | | Problem: Evaluating "expr" options has more overhead than needed. Solution: Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr', "expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr', 'formatexpr', 'indentexpr' and 'charconvert'. https://github.com/vim/vim/commit/a4e0b9785e409e9e660171cea76dfcc5fdafad9b vim-patch:9.0.0635: build error and compiler warnings Problem: Build error and compiler warnings. Solution: Add missing change. Add type casts. https://github.com/vim/vim/commit/3292a229402c9892f5ab90645fbfe2b1db342f5b Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.1.0569: fnamemodify() treats ".." and "../" differently (#29673)zeertzjq2024-07-12
| | | | | | | | | Problem: fnamemodify() treats ".." and "../" differently. Solution: Expand ".." properly like how "/.." is treated in 8.2.3388. (zeertzjq) closes: vim/vim#15218 https://github.com/vim/vim/commit/1ee7420460768df67ea4bc73467f2d4f8b1555bd
* vim-patch:9.1.0568: Cannot expand paths from 'cdpath' settingzeertzjq2024-07-12
| | | | | | | | | | | | | | Problem: Cannot expand paths from 'cdpath' setting (Daniel Hahler) Solution: Implement 'cdpath' completion, add the new 'dir_in_path' completion type (LemonBoy) fixes vim/vim#374 closes: vim/vim#15205 https://github.com/vim/vim/commit/a20bf69a3b32024cb7809be87af33bf9dc490a19 Co-authored-by: LemonBoy <thatlemon@gmail.com>
* vim-patch:8.2.3388: fnamemodify('path/..', ':p') differs from using ↵zeertzjq2024-07-12
| | | | | | | | | | 'path/../' (#29667) Problem: fnamemodify('path/..', ':p') differs from using 'path/../'. Solution: Include the "/.." in the directory name. (closes vim/vim#8808) https://github.com/vim/vim/commit/4eaef9979fc5032606897963f1af37674ee0d422 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: remove CH_FOLD macrodundargoc2024-07-10
| | | | It should not be needed as utf_fold should already work on its own.
* refactor(memory): use builtin strcat() instead of STRCAT()bfredl2024-06-11
| | | | | | | | The latter was mostly relevant with the past char_u madness. NOTE: STRCAT also functioned as a counterfeit "NOLINT" for clint apparently. But NOLINT-ing every usecase is just the same as disabling the check entirely.
* refactor(path.c): add nonnull attributes (#28829)zeertzjq2024-05-19
| | | This possibly fixes the coverity warning.
* fix(path): avoid chdir() when resolving path (#28799)zeertzjq2024-05-17
| | | | | | | | | | | | | | | | | | | | | | Use uv_fs_realpath() instead. It seems that uv_fs_realpath() has some problems on non-Linux platforms: - macOS and other BSDs: this function will fail with UV_ELOOP if more than 32 symlinks are found while resolving the given path. This limit is hardcoded and cannot be sidestepped. - Windows: while this function works in the common case, there are a number of corner cases where it doesn't: - Paths in ramdisk volumes created by tools which sidestep the Volume Manager (such as ImDisk) cannot be resolved. - Inconsistent casing when using drive letters. - Resolved path bypasses subst'd drives. Ref: https://docs.libuv.org/en/v1.x/fs.html#c.uv_fs_realpath I don't know if the old implementation that uses uv_chdir() and uv_cwd() also suffers from the same problems. - For the ELOOP case, chdir() seems to have the same limitations. - On Windows, Vim doesn't use anything like chdir() either. It uses _wfullpath(), while libuv uses GetFinalPathNameByHandleW().
* docs: misc (#28609)dundargoc2024-05-15
| | | | | | | | | | | | Closes https://github.com/neovim/neovim/issues/28484. Closes https://github.com/neovim/neovim/issues/28719. Co-authored-by: Chris <crwebb85@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Jake B <16889000+jakethedev@users.noreply.github.com> Co-authored-by: Jonathan Raines <jonathan.s.raines@gmail.com> Co-authored-by: Yi Ming <ofseed@foxmail.com> Co-authored-by: Zane Dufour <zane@znd4.me> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq2024-04-20
| | | | | | Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls.
* fix(path): check return value of append_path() (#28309)Joey Gouly2024-04-13
| | | | | | | | | | | | | | | | | | | | | | | If the filename passed to vim_FullName() is a relative directory, and does not exist, it is appended to the current working directory. Since the return value of append_path() was ignored, and if the buffer length was too small to fit getcwd() + dirname(filename), it would still try to append the basename(filename). This was manifesting as a failure in test/unit/path_spec.lua in: itp('fails and uses filename if given filename contains non-existing directory', .. This failure occurs when running the tests from directory with a short path such as: /work/src/nv test/unit/path_spec.lua:420: Expected objects to be the same. Passed in: (string) '/work/src/nv/test.file' Expected: (string) 'non_existing_dir/test.file' This return value for the second call to append_path() to append basename(filename) was checked, and this is where it would fail for normal / longer getcwd()s.
* refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* refactor: remove redundant NOLINT commentsdundargoc2024-01-01
|
* refactor: follow style guidedundargoc2023-12-30
|
* refactor: eliminate cyclic includesdundargoc2023-12-20
|
* refactor: use `bool` to represent boolean valuesdundargoc2023-12-19
|
* refactor(options): reduce `findoption()` usageFamiu Haque2023-12-09
| | | | | | Problem: Many places in the code use `findoption()` to access an option using its name, even if the option index is available. This is very slow because it requires looping through the options array over and over. Solution: Use option index instead of name wherever possible. Also introduce an `OptIndex` enum which contains the index for every option as enum constants, this eliminates the need to pass static option names as strings.
* refactor(IWYU): fix includes for cmdhist.h (#26324)zeertzjq2023-11-30
|
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* build(IWYU): replace most private mappings with pragmas (#26247)zeertzjq2023-11-27
|
* refactor: move garray_T to garray_defs.h (#26227)zeertzjq2023-11-26
|
* refactor: follow style guidedundargoc2023-11-19
| | | | | - reduce variable scope - prefer initialization over declaration and assignment
* refactor: iwyu (#26062)zeertzjq2023-11-16
|
* refactor: follow style guidedundargoc2023-11-13
| | | | | | - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
* refactor: remove redundant castsdundargoc2023-11-11
|
* refactor: change some xstrndup() and xstrnsave() to xmemdupz() (#25959)zeertzjq2023-11-10
| | | | When the given length is exactly the number of bytes to copy, xmemdupz() makes the intention clearer.
* fix(path): restore space separation in 'path' (#25571)zeertzjq2023-10-10
| | | Removing this behavior causes more inconsistencies and bugs.
* fix(path): accept special characters on Windows (#25424)Leonardo Mello2023-10-04
|
* refactor: reorganize option header files (#25437)zeertzjq2023-09-30
| | | | | | - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|
* feat(options)!: remove compatible behaviours for vim 5.0 and earlierLewis Russell2023-07-17
|
* fix(runtime): respect 'fileignorecase' when sourcing (#24344)zeertzjq2023-07-14
|
* fix(completion): don't add backslashes to runtime pattern (#24296)zeertzjq2023-07-08
| | | | | Problem: Bashslashes added as regexp in runtime completion may be treated as path separator with some 'isfname' value. Solution: Make curly braces work for runtime completion and use it.
* fix(api): nvim_parse_cmd error message in pcall() #23297Alexandre Teoi2023-07-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: nvim_parse_cmd() in pcall() may show an error message (side-effect): :lua pcall(vim.api.nvim_parse_cmd, vim.fn.getcmdline(), {}) E16: Invalid range Solution: Avoid emsg() in the nvim_parse_cmd() codepath. - refactor(api): add error message output parameter to get_address() - fix: null check emsg() parameter - refactor: remove emsg_off workaround from do_incsearch_highlighting() - refactor: remove emsg_off workaround from cmdpreview_may_show() - refactor: remove remaining calls to emsg() from parse_cmd_address() and get_address() - (refactor): lint set_cmd_dflall_range() - refactor: addr_error() - move output parameter to return value Fix #20339 TODO: These are the functions called by `get_address()`: ``` nvim_parse_cmd() -> parse_cmdline() -> parse_cmd_address() -> get_address() skipwhite() addr_error() qf_get_cur_idx() qf_get_cur_valid_idx() qf_get_size() qf_get_valid_size() mark_get() mark_check() assert() skip_regexp() magic_isset() > do_search() > searchit() ascii_isdigit() getdigits() getdigits_int32() compute_buffer_local_count() hasFolding() ``` From these functions, I found at least two that call emsg directly: - do_search() - seems to be simple to refactor - searchit() - will be more challenging because it may generate multiple error messages, which can't be handled by the current `errormsg` out-parameter. For example, it makes multiple calls to `vim_regexec_multi()` in a loop that possibly generate error messages, and later `searchit()` itself may generate another one: - https://github.com/neovim/neovim/blob/c194acbfc479d8e5839fa629363f93f6550d035c/src/nvim/search.c#L631-L647 - https://github.com/neovim/neovim/blob/c194acbfc479d8e5839fa629363f93f6550d035c/src/nvim/search.c#L939-L954 --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* refactor: remove some casts to char * (#24200)zeertzjq2023-06-29
|
* fix(events): don't expand non-file as file namezeertzjq2023-06-07
|
* fix(runtime): do not allow breakcheck inside runtime path calculationbfredl2023-04-19
| | | | | | | | | problem: breakcheck might run arbitrary lua code, which might require modules and thus invoke runtime path calculation recursively. solution: Block the use of breakcheck when expanding glob patterns inside 'runtimepath' fixes #23012
* vim-patch:8.2.4184: cannot use an import in 'includeexpr'zeertzjq2023-04-17
| | | | | | | | | Problem: Cannot use an import in 'includeexpr'. Solution: Set the script context when evaluating 'includeexpr' https://github.com/vim/vim/commit/47bcc5f4c83c158f43ac2ea7abfe99dbf5c2e098 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.1400: find_file_in_path() is not reentrant (#23146)zeertzjq2023-04-17
| | | | | | | | | Problem: find_file_in_path() is not reentrant. Solution: Instead of global variables pass pointers to the functions. (closes vim/vim#12093) https://github.com/vim/vim/commit/5145c9a829cd43cb9e7962b181bf99226eb3a53f Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:8.2.1049: Vim9: leaking memory when using continuation linezeertzjq2023-04-14
| | | | | | | | | | | | | | | | | | | Problem: Vim9: leaking memory when using continuation line. Solution: Keep a pointer to the continuation line in evalarg_T. Centralize checking for a next command. https://github.com/vim/vim/commit/b171fb179053fa631fec74911b5fb9374cb6a8a1 Omit eval_next_line(): Vim9 script only. vim-patch:8.2.1050: missing change in struct Problem: Missing change in struct. Solution: Add missing change. https://github.com/vim/vim/commit/65a8ed37f7bc61fbe5c612a7b0eb0dfc16ad3e11 Co-authored-by: Bram Moolenaar <Bram@vim.org>