aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/strings.c
Commit message (Collapse)AuthorAge
* vim-patch:9.1.1076: vim_strnchr() is strange and unnecessary (#32327)zeertzjq2025-02-05
| | | | | | | | | | | | | | | | | | | | | | Problem: vim_strnchr() is strange and unnecessary (after v9.1.1009) Solution: Remove vim_strnchr() and use memchr() instead. Also remove a comment referencing an #if that is no longer present. vim_strnchr() is strange in several ways: - It's named like vim_strchr(), but unlike vim_strchr() it doesn't support finding a multibyte char. - Its logic is similar to vim_strbyte(), but unlike vim_strbyte() it uses char instead of char_u. - It takes a pointer as its size argument, which isn't convenient for all its callers. - It allows embedded NULs, unlike other "strn*" functions which stop when encountering a NUL byte. In comparison, memchr() also allows embedded NULs, and it converts bytes in the string to (unsigned char). closes: vim/vim#16579 https://github.com/vim/vim/commit/34e1e8de91ff4a8922d454e3147ea425784aa0a0
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* fix(coverity/497375): f_strpart cast overflow (#30773)Devon Gardner2024-10-12
| | | | | | | Problem: Casting long to int introduces risk of overflow. Solution: Work with all int64_t (long) rather than casting back and forth.
* fix(diff): use mmfile_t in linematchLewis Russell2024-09-30
| | | | | | | | | | | | | | | Problem: Linematch used to use strchr to navigate a string, however strchr does not supoprt embedded NULs. Solution: Use `mmfile_t` instead of `char *` in linematch and introduce `strnchr()`. Also remove heap allocations from `matching_char_iwhite()` Fixes: #30505
* vim-patch:9.1.0638: E1510 may happen when formatting a message for smsg() ↵zeertzjq2024-07-29
| | | | | | | | | | | (#29907) Problem: E1510 may happen when formatting a message (after 9.1.0181). Solution: Only give E1510 when using typval. (zeertzjq) closes: vim/vim#15391 https://github.com/vim/vim/commit/0dff31576a340b74cec81517912923c38cb28450
* refactor: add assertion for v_blob in tv_ptr() (#29554)zeertzjq2024-07-04
| | | Also add test for using printf() and id() with a Blob.
* refactor: replace '\0' with NULJames Tirta Halim2024-06-04
|
* refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|
* vim-patch:9.1.0451: No test for escaping '<' with shellescape()zeertzjq2024-05-31
| | | | | | | | | | Problem: No test for escaping '<' with shellescape() Solution: Add a test. Use memcpy() in code to make it easier to understand. Fix a typo (zeertzjq). closes: vim/vim#14876 https://github.com/vim/vim/commit/88c8c547d5fc380e5685c2b01ec564ccdf9b259a
* vim-patch:9.1.0449: MS-Windows: Compiler warningszeertzjq2024-05-31
| | | | | | | | | | | | | | | | Problem: MS-Windows: Compiler warnings Solution: Resolve size_t to int warnings closes: vim/vim#14874 A couple of warnings in ex_docmd.c have been resolved by modifying their function argument types, followed by some changes in various function call sites. This also allowed removal of some casts to cope with size_t/int conversion. https://github.com/vim/vim/commit/51024bbc1a9e298b1fb8f2e465fccb5db409551e Co-authored-by: Mike Williams <mrmrdubya@gmail.com>
* vim-patch:9.1.0409: too many strlen() calls in the regexp engine (#28857)zeertzjq2024-05-20
| | | | | | | | | | | | | | | | | Problem: too many strlen() calls in the regexp engine Solution: refactor code to retrieve strlen differently, make use of bsearch() for getting the character class (John Marriott) closes: vim/vim#14648 https://github.com/vim/vim/commit/82792db6315f7c7b0e299cdde1566f2932a463f8 Cherry-pick keyvalue_T and its comparison functions from patch 9.1.0256. vim-patch:9.1.0410: warning about uninitialized variable vim-patch:9.1.0412: typo in regexp_bt.c in DEBUG code Co-authored-by: John Marriott <basilisk@internode.on.net>
* fix: transposed xcalloc arguments (#28695)zeertzjq2024-05-11
|
* vim-patch:9.1.0181: no overflow check for string formatting (#27863)zeertzjq2024-03-15
| | | | | | | | | | | Problem: no overflow check for string formatting Solution: Check message formatting function for overflow. (Chris van Willegen) closes: vim/vim#13799 https://github.com/vim/vim/commit/c35fc03dbd47582b256776fb11f11d8ceb24f8f0 Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
* refactor: avoid copying before vim_strup() if possible (#27830)James2024-03-13
| | | | | | Current uses of vim_strup() calls memcpy()/strcpy() before calling vim_strup(). This results in 2 * strlen(string) operations. We can trivially convert to lowercase while copying the string instead.
* refactor(msgpack): allow flushing buffer while packing msgpackbfredl2024-03-07
| | | | | | | | | | | | | | Before, we needed to always pack an entire msgpack_rpc Object to a continous memory buffer before sending it out to a channel. But this is generally wasteful. it is better to just flush whatever is in the buffer and then continue packing to a new buffer. This is also done for the UI event packer where there are some extra logic to "finish" of an existing batch of nevents/ncalls. This doesn't really stop us from flushing the buffer, just that we need to update the state machine accordingly so the next call to prepare_call() always will start with a new event (even though the buffer might contain overflow data from a large event).
* refactor(api): use an arena for mappingsbfredl2024-02-18
|
* refactor(strcase_save): optimize memory allocation (#27319)Raphael2024-02-03
| | | | Problem: Double xmalloc usage led to excess memory allocations. Solution: Switch to xrealloc to adjust memory as needed, minimizing allocations.
* 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: follow style guidedundargoc2023-12-30
|
* refactor: use `bool` to represent boolean valuesdundargoc2023-12-19
|
* docs: add style rule regarding initializationdundargoc2023-12-18
| | | | | Specifically, specify that each initialization should be done on a separate line.
* 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: move function macros out of vim_defs.h (#26300)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* refactor: enable formatting for ternariesdundargoc2023-11-20
| | | | | | This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
* refactor: follow style guidedundargoc2023-11-19
| | | | | - reduce variable scope - prefer initialization over declaration and assignment
* 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: 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.
* vim-patch:9.0.2041: trim(): hard to use default mask (#25692)zeertzjq2023-10-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: trim(): hard to use default mask (partly revert v9.0.2040) Solution: use default mask when it is empty The default 'mask' value is pretty complex, as it includes many characters. Yet, if one needs to specify the trimming direction, the third argument, 'trim()' currently requires the 'mask' value to be provided explicitly. Currently, an empty 'mask' will make 'trim()' call return 'text' value that is passed in unmodified. It is unlikely that someone is using it, so the chances of scripts being broken by this change are low. Also, this reverts commit 9.0.2040 (which uses v:none for the default and requires to use an empty string instead). closes: vim/vim#13358 https://github.com/vim/vim/commit/8079917447e7436dccc2e4cd4a4a56ae0a4712f2 vim-patch:9.0.2040: trim(): hard to use default mask Problem: trim(): hard to use default mask Solution: Use default 'mask' when it is v:none The default 'mask' value is pretty complex, as it includes many characters. Yet, if one needs to specify the trimming direction, the third argument, 'trim()' currently requires the 'mask' value to be provided explicitly. 'v:none' is already used to mean "use the default argument value" in user defined functions. See |none-function_argument| in help. closes: vim/vim#13363 https://github.com/vim/vim/commit/6e6386716f9494ae86027c6d34f657fd03dfec42 Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
* vim-patch:9.0.1997: Some unused code in move.c and string.cdundargoc2023-10-07
| | | | | | | | | | | Problem: Some unused code in move.c and string.c Solution: Remove it closes: vim/vim#13288 https://github.com/vim/vim/commit/580c1fcb4ad85360cd3a361c3c8e37b534153d60 Co-authored-by: dundargoc <gocdundar@gmail.com>
* vim-patch:9.0.1990: strange error numberzeertzjq2023-10-07
| | | | | | | | | | | | Problem: strange error number Solution: change error number, add doc tag for E1507 closes: vim/vim#13270 https://github.com/vim/vim/commit/ea746f9e862092aef3d4e95c64d116759b9fabe0 Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|
* vim-patch:9.0.1950: Vim9: error codes spread out (#25405)zeertzjq2023-09-29
| | | | | | | | | | | | | | Problem: Vim9: error codes spread out Solution: group them together and reserve 100 more for future use Reserve 100 error codes for future enhancements to the Vim9 class support closes: vim/vim#13207 https://github.com/vim/vim/commit/413f83990f15d5d59d27ab741670f527a7a3feb8 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* vim-patch:9.0.1884: Wrong order of arguments for error messages (#25055)zeertzjq2023-09-09
| | | | | | | | | | Problem: Wrong order of arguments for error messages Solution: Reverse order or arguments for e_aptypes_is_null_nr_str closes: vim/vim#13051 https://github.com/vim/vim/commit/1bd2cb11694690a77e4141bce2e34d9dfb882f1c Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
* vim-patch:9.0.1863: wrong format specifiers in e_aptypes_is_null_str_nr (#25015)zeertzjq2023-09-04
| | | | | | | | Problem: wrong format specifiers in e_aptypes_is_null_str_nr Solution: Fix the wrong format specifier closes: vim/vim#13020 https://github.com/vim/vim/commit/7db89bdc23e53c7bc43af6f1c7281bc69a6a3098
* vim-patch:9.0.1856: issues with formatting positional arguments (#25013)zeertzjq2023-09-04
| | | | | | | | | | | | | Problem: issues with formatting positional arguments Solution: fix them, add tests and documentation closes: vim/vim#12140 closes: vim/vim#12985 Tentatively fix message_test. Check NULL ptr. https://github.com/vim/vim/commit/aa90d4f031f73a34aaef5746931ea746849a2231 Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
* vim-patch:9.0.1515: reverse() does not work for a Stringzeertzjq2023-08-19
| | | | | | | | | | | | | | | | | | | Problem: reverse() does not work for a String. Solution: Implement reverse() for a String. (Yegappan Lakshmanan, closes vim/vim#12179) https://github.com/vim/vim/commit/03ff1c2dde7f15eca5c9baa6dafbda9b49bedc3b vim-patch:9.0.1738: Duplicate code to reverse a string Problem: Duplicate code to reverse a string Solution: Move reverse_text() to strings.c and remove string_reverse(). closes: vim/vim#12847 https://github.com/vim/vim/commit/4dd266cb66d901cf5324f09405cfea3f004bd29f Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* fix(printf): make positional %zd and %zu work (#24722)zeertzjq2023-08-15
|
* vim-patch:9.0.1704: Cannot use positional arguments for printf() (#24719)zeertzjq2023-08-15
| | | | | | | | | | Problem: Cannot use positional arguments for printf() Solution: Support positional arguments in string formatting closes: vim/vim#12140 https://github.com/vim/vim/commit/0c6181fec4c362eb9682d5af583341eb20cb1af5 Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
* fix(runtime): respect 'fileignorecase' when sourcing (#24344)zeertzjq2023-07-14
|
* perf(rtp): reduce rtp scans (#24191)Lewis Russell2023-07-13
| | | | | | | | | | | * perf(rtp): reduce rtp scans Problem: Scanning the filesystem is expensive and particularly affects startuptime. Solution: Reduce the amount of redundant directory scans by relying less on glob patterns and handle vim and lua sourcing lower down.
* fix(messages): use "Vimscript" instead of "VimL" #24111Justin M. Keyes2023-06-22
| | | | followup to #24109 fix #16150
* vim-patch:9.0.1629: having utf16idx() rounding up is inconvenient (#24019)zeertzjq2023-06-14
| | | | | | | | Problem: Having utf16idx() rounding up is inconvenient. Solution: Make utf16idx() round down. (Yegappan Lakshmanan, closes vim/vim#12523) https://github.com/vim/vim/commit/95707037afa1aeae4f3494dc623a721ceed7fc4e Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* vim-patch:9.0.1617: charidx() result is not consistent with byteidx() (#23963)zeertzjq2023-06-09
| | | | | | | | | | Problem: charidx() and utf16idx() result is not consistent with byteidx(). Solution: When the index is equal to the length of the text return the lenght of the text instead of -1. (Yegappan Lakshmanan, closes vim/vim#12503) https://github.com/vim/vim/commit/577922b917e48285a7a312daf7b5bbc6e272939c Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* vim-patch:9.0.1524: passing -1 for bool is not always rejectedzeertzjq2023-05-08
| | | | | | | Problem: Passing -1 for bool is not always rejected. Solution: Check for error in a better way. (closes vim/vim#12358) https://github.com/vim/vim/commit/8cf51376b842e0060edf08bd2e5bd9933c552ecf
* vim-patch:9.0.1522: some functions give two error messageszeertzjq2023-05-08
| | | | | | | | | | | | Problem: Some functions give two error messages. Solution: Do not give a second error message. (closes vim/vim#12352) https://github.com/vim/vim/commit/e4098457ab9c94225b1b0e3c5e06b82b75587971 It seems that tv_get_bool() is actually not exactly the same as tv_get_number(), so change it to a function instead. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:8.2.2607: strcharpart() cannot include composing characterszeertzjq2023-05-04
| | | | | | | | | Problem: strcharpart() cannot include composing characters. Solution: Add the {skipcc} argument. https://github.com/vim/vim/commit/02b4d9b18a03549b68e364e428392b7a62766c74 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: uncrustifydundargoc2023-04-26
| | | | Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.