json-glib: update to 1.10.6
[oi-userland.git] / components / library / readline / patches / readline82-013.patch
blobcb4164fbe5ec47176bb816dea6db536987c8c427
1 READLINE PATCH REPORT
2 =====================
4 Readline-Release: 8.2
5 Patch-ID: readline82-013
7 Bug-Reported-by: Grisha Levit <grishalevit@gmail.com>
8 Bug-Reference-ID: <CAMu=Brrv5qKY6LPfw8PxqNXNO8rNsZo0Fb=BcFb-uHObWPqnrw@mail.gmail.
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2023-04/msg00082.html
11 Bug-Description:
13 When readline is accumulating bytes until it reads a complete multibyte
14 character, reading a byte that makes the multibyte character invalid can
15 result in discarding the bytes in the partial character.
17 Patch (apply with `patch -p0'):
19 *** ../readline-8.2-patched/text.c Mon May 1 09:37:52 2023
20 --- text.c Mon May 29 12:22:29 2023
21 ***************
22 *** 86,90 ****
23 rl_insert_text (const char *string)
25 ! register int i, l;
27 l = (string && *string) ? strlen (string) : 0;
28 --- 86,91 ----
29 rl_insert_text (const char *string)
31 ! register int i;
32 ! size_t l;
34 l = (string && *string) ? strlen (string) : 0;
35 ***************
36 *** 705,709 ****
37 /* Insert the character C at the current location, moving point forward.
38 If C introduces a multibyte sequence, we read the whole sequence and
39 ! then insert the multibyte char into the line buffer. */
40 int
41 _rl_insert_char (int count, int c)
42 --- 706,714 ----
43 /* Insert the character C at the current location, moving point forward.
44 If C introduces a multibyte sequence, we read the whole sequence and
45 ! then insert the multibyte char into the line buffer.
46 ! If C == 0, we immediately insert any pending partial multibyte character,
47 ! assuming that we have read a character that doesn't map to self-insert.
48 ! This doesn't completely handle characters that are part of a multibyte
49 ! character but map to editing functions. */
50 int
51 _rl_insert_char (int count, int c)
52 ***************
53 *** 719,727 ****
54 #endif
56 if (count <= 0)
57 return 0;
59 ! #if defined (HANDLE_MULTIBYTE)
60 ! if (MB_CUR_MAX == 1 || rl_byte_oriented)
62 incoming[0] = c;
63 --- 724,749 ----
64 #endif
66 + #if !defined (HANDLE_MULTIBYTE)
67 if (count <= 0)
68 return 0;
69 + #else
70 + if (count < 0)
71 + return 0;
72 + if (count == 0)
73 + {
74 + if (pending_bytes_length == 0)
75 + return 0;
76 + if (stored_count <= 0)
77 + stored_count = count;
78 + else
79 + count = stored_count;
81 ! memcpy (incoming, pending_bytes, pending_bytes_length);
82 ! incoming[pending_bytes_length] = '\0';
83 ! incoming_length = pending_bytes_length;
84 ! pending_bytes_length = 0;
85 ! memset (&ps, 0, sizeof (mbstate_t));
86 ! }
87 ! else if (MB_CUR_MAX == 1 || rl_byte_oriented)
89 incoming[0] = c;
90 ***************
91 *** 731,734 ****
92 --- 753,759 ----
93 else if (_rl_utf8locale && (c & 0x80) == 0)
95 + if (pending_bytes_length)
96 + _rl_insert_char (0, 0);
98 incoming[0] = c;
99 incoming[1] = '\0';
100 ***************
101 *** 765,769 ****
102 incoming_length = 1;
103 pending_bytes_length--;
104 ! memmove (pending_bytes, pending_bytes + 1, pending_bytes_length);
105 /* Clear the state of the byte sequence, because in this case the
106 effect of mbstate is undefined. */
107 --- 790,795 ----
108 incoming_length = 1;
109 pending_bytes_length--;
110 ! if (pending_bytes_length)
111 ! memmove (pending_bytes, pending_bytes + 1, pending_bytes_length);
112 /* Clear the state of the byte sequence, because in this case the
113 effect of mbstate is undefined. */
114 ***************
115 *** 828,832 ****
116 --- 854,862 ----
117 xfree (string);
119 + #if defined (HANDLE_MULTIBYTE)
120 + return (pending_bytes_length != 0);
121 + #else
122 return 0;
123 + #endif
126 ***************
127 *** 861,864 ****
128 --- 891,896 ----
129 incoming_length = 0;
130 stored_count = 0;
132 + return (pending_bytes_length != 0);
133 #else /* !HANDLE_MULTIBYTE */
134 char str[TEXT_COUNT_MAX+1];
135 ***************
136 *** 874,880 ****
137 count -= decreaser;
139 - #endif /* !HANDLE_MULTIBYTE */
141 return 0;
144 --- 906,912 ----
145 count -= decreaser;
148 return 0;
149 + #endif /* !HANDLE_MULTIBYTE */
152 ***************
153 *** 904,910 ****
154 stored_count = 0;
156 ! #endif
158 return 0;
161 --- 936,944 ----
162 stored_count = 0;
165 ! return (pending_bytes_length != 0);
166 ! #else
167 return 0;
168 + #endif
171 ***************
172 *** 984,987 ****
173 --- 1018,1026 ----
176 + /* If we didn't insert n and there are pending bytes, we need to insert
177 + them if _rl_insert_char didn't do that on its own. */
178 + if (r == 1 && rl_insert_mode == RL_IM_INSERT)
179 + r = _rl_insert_char (0, 0); /* flush partial multibyte char */
181 if (n != (unsigned short)-2) /* -2 = sentinel value for having inserted N */
183 ***************
184 *** 1055,1058 ****
185 --- 1094,1099 ----
186 rl_quoted_insert (int count, int key)
188 + int r;
190 /* Let's see...should the callback interface futz with signal handling? */
191 #if defined (HANDLE_SIGNALS)
192 ***************
193 *** 1073,1085 ****
194 if (count < 0)
196 - int r;
199 r = _rl_insert_next (1);
200 while (r == 0 && ++count < 0);
201 - return r;
204 ! return _rl_insert_next (count);
207 --- 1114,1128 ----
208 if (count < 0)
211 r = _rl_insert_next (1);
212 while (r == 0 && ++count < 0);
214 + else
215 + r = _rl_insert_next (count);
217 ! if (r == 1)
218 ! _rl_insert_char (0, 0); /* insert partial multibyte character */
220 ! return r;
224 *** ../readline-8.2/patchlevel 2013-11-15 08:11:11.000000000 -0500
225 --- patchlevel 2014-03-21 08:28:40.000000000 -0400
226 ***************
227 *** 1,3 ****
228 # Do not edit -- exists only for use by patch
230 ! 12
231 --- 1,3 ----
232 # Do not edit -- exists only for use by patch
234 ! 13