comparison configmix/_speedups.c @ 564:44e18fbf7741

Refactor: signature of _convert_ucs4_to_utf8(): change order of args
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 06 Jan 2022 22:36:37 +0100
parents f75c5b13a1d7
children 5c617d870bb8
comparison
equal deleted inserted replaced
563:2c211934d4b0 564:44e18fbf7741
143 143
144 static 144 static
145 Py_ssize_t 145 Py_ssize_t
146 _convert_ucs4_to_utf8( 146 _convert_ucs4_to_utf8(
147 Py_UCS4 ch, 147 Py_UCS4 ch,
148 unsigned char *targetStart, unsigned char *targetEnd,
149 int strict,
148 PyObject *ch_obj, /* for error messages: the string where ch comes from */ 150 PyObject *ch_obj, /* for error messages: the string where ch comes from */
149 Py_ssize_t ch_obj_end, /* effective length of ch_obj (error reporting) */ 151 Py_ssize_t ch_obj_end /* effective length of ch_obj (error reporting) */
150 unsigned char *targetStart, unsigned char *targetEnd, 152 )
151 int strict)
152 { 153 {
153 const Py_UCS4 byteMask = 0xBF; 154 const Py_UCS4 byteMask = 0xBF;
154 const Py_UCS4 byteMark = 0x80; 155 const Py_UCS4 byteMark = 0x80;
155 156
156 Py_ssize_t bytesToWrite = 0; 157 Py_ssize_t bytesToWrite = 0;
220 221
221 if (_hex2ucs4(s, end, &c) != 0) 222 if (_hex2ucs4(s, end, &c) != 0)
222 return NULL; 223 return NULL;
223 224
224 /* Replace the combination PyUniode_New/PyUnicode_WriteChar */ 225 /* Replace the combination PyUniode_New/PyUnicode_WriteChar */
225 bytes_written = _convert_ucs4_to_utf8(c, s, end+1, buf, &(buf[6]), 1); 226 bytes_written = _convert_ucs4_to_utf8(c, buf, &(buf[6]), 1, s, end+1);
226 if (bytes_written < 0) { 227 if (bytes_written < 0) {
227 return NULL; 228 return NULL;
228 } 229 }
229 u = PyUnicode_FromStringAndSize((const char *)buf, bytes_written); 230 u = PyUnicode_FromStringAndSize((const char *)buf, bytes_written);
230 if (u == NULL) { 231 if (u == NULL) {