comparison src/misc1.c @ 25206:dc66d0284518 v8.2.3139

patch 8.2.3139: functions for string manipulation are spread out Commit: https://github.com/vim/vim/commit/a2438132a675be4dde3acbdf03ba1fdb2f09427c Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Jul 10 21:29:18 2021 +0200 patch 8.2.3139: functions for string manipulation are spread out Problem: Functions for string manipulation are spread out. Solution: Move string related functions to a new source file. (Yegappan Lakshmanan, closes #8470)
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Jul 2021 21:30:04 +0200
parents 53fd6370e4fd
children 34a6db7af738
comparison
equal deleted inserted replaced
25205:362cabc968e8 25206:dc66d0284518
693 { 693 {
694 buf[0] = 'n'; 694 buf[0] = 'n';
695 if (finish_op) 695 if (finish_op)
696 { 696 {
697 buf[1] = 'o'; 697 buf[1] = 'o';
698 // to be able to detect force-linewise/blockwise/characterwise operations 698 // to be able to detect force-linewise/blockwise/characterwise
699 // operations
699 buf[2] = motion_force; 700 buf[2] = motion_force;
700 } 701 }
701 else if (restart_edit == 'I' || restart_edit == 'R' 702 else if (restart_edit == 'I' || restart_edit == 'R'
702 || restart_edit == 'V') 703 || restart_edit == 'V')
703 { 704 {
2097 result = 1; // partial match 2098 result = 1; // partial match
2098 } 2099 }
2099 return result; 2100 return result;
2100 } 2101 }
2101 2102
2102 /*
2103 * Concatenate two strings and return the result in allocated memory.
2104 * Returns NULL when out of memory.
2105 */
2106 char_u *
2107 concat_str(char_u *str1, char_u *str2)
2108 {
2109 char_u *dest;
2110 size_t l = str1 == NULL ? 0 : STRLEN(str1);
2111
2112 dest = alloc(l + (str2 == NULL ? 0 : STRLEN(str2)) + 1L);
2113 if (dest != NULL)
2114 {
2115 if (str1 == NULL)
2116 *dest = NUL;
2117 else
2118 STRCPY(dest, str1);
2119 if (str2 != NULL)
2120 STRCPY(dest + l, str2);
2121 }
2122 return dest;
2123 }
2124
2125 static void 2103 static void
2126 prepare_to_exit(void) 2104 prepare_to_exit(void)
2127 { 2105 {
2128 #if defined(SIGHUP) && defined(SIG_IGN) 2106 #if defined(SIGHUP) && defined(SIG_IGN)
2129 // Ignore SIGHUP, because a dropped connection causes a read error, which 2107 // Ignore SIGHUP, because a dropped connection causes a read error, which