Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3b1a74a

Browse files
committed
Rename unicode_write_t structure and its methods to "_PyUnicodeWriter"
1 parent ee4544c commit 3b1a74a

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

Objects/stringlib/unicode_format.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ get_field_object(SubString *input, PyObject *args, PyObject *kwargs,
494494
appends to the output.
495495
*/
496496
static int
497-
render_field(PyObject *fieldobj, SubString *format_spec, unicode_writer_t *writer)
497+
render_field(PyObject *fieldobj, SubString *format_spec, _PyUnicodeWriter *writer)
498498
{
499499
int ok = 0;
500500
PyObject *result = NULL;
@@ -540,7 +540,7 @@ render_field(PyObject *fieldobj, SubString *format_spec, unicode_writer_t *write
540540
goto done;
541541

542542
len = PyUnicode_GET_LENGTH(result);
543-
if (unicode_writer_prepare(writer,
543+
if (_PyUnicodeWriter_Prepare(writer,
544544
len, PyUnicode_MAX_CHAR_VALUE(result)) == -1)
545545
goto done;
546546
copy_characters(writer->buffer, writer->pos,
@@ -811,7 +811,7 @@ do_conversion(PyObject *obj, Py_UCS4 conversion)
811811
static int
812812
output_markup(SubString *field_name, SubString *format_spec,
813813
int format_spec_needs_expanding, Py_UCS4 conversion,
814-
unicode_writer_t *writer, PyObject *args, PyObject *kwargs,
814+
_PyUnicodeWriter *writer, PyObject *args, PyObject *kwargs,
815815
int recursion_depth, AutoNumber *auto_number)
816816
{
817817
PyObject *tmp = NULL;
@@ -872,7 +872,7 @@ output_markup(SubString *field_name, SubString *format_spec,
872872
*/
873873
static int
874874
do_markup(SubString *input, PyObject *args, PyObject *kwargs,
875-
unicode_writer_t *writer, int recursion_depth, AutoNumber *auto_number)
875+
_PyUnicodeWriter *writer, int recursion_depth, AutoNumber *auto_number)
876876
{
877877
MarkupIterator iter;
878878
int format_spec_needs_expanding;
@@ -894,7 +894,7 @@ do_markup(SubString *input, PyObject *args, PyObject *kwargs,
894894
if (sublen) {
895895
maxchar = _PyUnicode_FindMaxChar(literal.str,
896896
literal.start, literal.end);
897-
err = unicode_writer_prepare(writer, sublen, maxchar);
897+
err = _PyUnicodeWriter_Prepare(writer, sublen, maxchar);
898898
if (err == -1)
899899
return 0;
900900
copy_characters(writer->buffer, writer->pos,
@@ -920,7 +920,7 @@ static PyObject *
920920
build_string(SubString *input, PyObject *args, PyObject *kwargs,
921921
int recursion_depth, AutoNumber *auto_number)
922922
{
923-
unicode_writer_t writer;
923+
_PyUnicodeWriter writer;
924924
Py_ssize_t initlen;
925925

926926
/* check the recursion level */
@@ -931,16 +931,16 @@ build_string(SubString *input, PyObject *args, PyObject *kwargs,
931931
}
932932

933933
initlen = PyUnicode_GET_LENGTH(input->str) + 100;
934-
if (unicode_writer_init(&writer, initlen, 127) == -1)
934+
if (_PyUnicodeWriter_Init(&writer, initlen, 127) == -1)
935935
return NULL;
936936

937937
if (!do_markup(input, args, kwargs, &writer, recursion_depth,
938938
auto_number)) {
939-
unicode_writer_dealloc(&writer);
939+
_PyUnicodeWriter_Dealloc(&writer);
940940
return NULL;
941941
}
942942

943-
return unicode_writer_finish(&writer);
943+
return _PyUnicodeWriter_Finish(&writer);
944944
}
945945

946946
/************************************************************************/

Objects/unicodeobject.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13207,30 +13207,30 @@ typedef struct {
1320713207
enum PyUnicode_Kind kind;
1320813208
Py_UCS4 maxchar;
1320913209
Py_ssize_t pos;
13210-
} unicode_writer_t;
13210+
} _PyUnicodeWriter ;
1321113211

1321213212
Py_LOCAL_INLINE(void)
13213-
unicode_writer_update(unicode_writer_t *writer)
13213+
_PyUnicodeWriter_Update(_PyUnicodeWriter *writer)
1321413214
{
1321513215
writer->maxchar = PyUnicode_MAX_CHAR_VALUE(writer->buffer);
1321613216
writer->data = PyUnicode_DATA(writer->buffer);
1321713217
writer->kind = PyUnicode_KIND(writer->buffer);
1321813218
}
1321913219

1322013220
Py_LOCAL(int)
13221-
unicode_writer_init(unicode_writer_t *writer,
13221+
_PyUnicodeWriter_Init(_PyUnicodeWriter *writer,
1322213222
Py_ssize_t length, Py_UCS4 maxchar)
1322313223
{
1322413224
writer->pos = 0;
1322513225
writer->buffer = PyUnicode_New(length, maxchar);
1322613226
if (writer->buffer == NULL)
1322713227
return -1;
13228-
unicode_writer_update(writer);
13228+
_PyUnicodeWriter_Update(writer);
1322913229
return 0;
1323013230
}
1323113231

1323213232
Py_LOCAL_INLINE(int)
13233-
unicode_writer_prepare(unicode_writer_t *writer,
13233+
_PyUnicodeWriter_Prepare(_PyUnicodeWriter *writer,
1323413234
Py_ssize_t length, Py_UCS4 maxchar)
1323513235
{
1323613236
Py_ssize_t newlen;
@@ -13262,18 +13262,18 @@ unicode_writer_prepare(unicode_writer_t *writer,
1326213262
return -1;
1326313263
}
1326413264
writer->buffer = newbuffer;
13265-
unicode_writer_update(writer);
13265+
_PyUnicodeWriter_Update(writer);
1326613266
}
1326713267
else if (maxchar > writer->maxchar) {
1326813268
if (unicode_widen(&writer->buffer, writer->pos, maxchar) < 0)
1326913269
return -1;
13270-
unicode_writer_update(writer);
13270+
_PyUnicodeWriter_Update(writer);
1327113271
}
1327213272
return 0;
1327313273
}
1327413274

1327513275
Py_LOCAL(PyObject *)
13276-
unicode_writer_finish(unicode_writer_t *writer)
13276+
_PyUnicodeWriter_Finish(_PyUnicodeWriter *writer)
1327713277
{
1327813278
if (PyUnicode_Resize(&writer->buffer, writer->pos) < 0) {
1327913279
Py_DECREF(writer->buffer);
@@ -13284,7 +13284,7 @@ unicode_writer_finish(unicode_writer_t *writer)
1328413284
}
1328513285

1328613286
Py_LOCAL(void)
13287-
unicode_writer_dealloc(unicode_writer_t *writer)
13287+
_PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer)
1328813288
{
1328913289
Py_CLEAR(writer->buffer);
1329013290
}
@@ -13749,7 +13749,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
1374913749
PyObject *uformat;
1375013750
void *fmt;
1375113751
enum PyUnicode_Kind kind, fmtkind;
13752-
unicode_writer_t writer;
13752+
_PyUnicodeWriter writer;
1375313753
Py_ssize_t sublen;
1375413754
Py_UCS4 maxchar;
1375513755

@@ -13768,7 +13768,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
1376813768
fmtcnt = PyUnicode_GET_LENGTH(uformat);
1376913769
fmtpos = 0;
1377013770

13771-
if (unicode_writer_init(&writer, fmtcnt + 100, 127) < 0)
13771+
if (_PyUnicodeWriter_Init(&writer, fmtcnt + 100, 127) < 0)
1377213772
goto onError;
1377313773

1377413774
if (PyTuple_Check(args)) {
@@ -13797,7 +13797,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
1379713797
sublen = fmtpos - nonfmtpos;
1379813798
maxchar = _PyUnicode_FindMaxChar(uformat,
1379913799
nonfmtpos, nonfmtpos + sublen);
13800-
if (unicode_writer_prepare(&writer, sublen, maxchar) == -1)
13800+
if (_PyUnicodeWriter_Prepare(&writer, sublen, maxchar) == -1)
1380113801
goto onError;
1380213802

1380313803
copy_characters(writer.buffer, writer.pos,
@@ -13961,7 +13961,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
1396113961
}
1396213962

1396313963
if (c == '%') {
13964-
if (unicode_writer_prepare(&writer, 1, '%') == -1)
13964+
if (_PyUnicodeWriter_Prepare(&writer, 1, '%') == -1)
1396513965
goto onError;
1396613966
PyUnicode_WRITE(writer.kind, writer.data, writer.pos, '%');
1396713967
writer.pos += 1;
@@ -14119,7 +14119,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
1411914119
if (sign && len == width)
1412014120
buflen++;
1412114121

14122-
if (unicode_writer_prepare(&writer, buflen, bufmaxchar) == -1)
14122+
if (_PyUnicodeWriter_Prepare(&writer, buflen, bufmaxchar) == -1)
1412314123
goto onError;
1412414124

1412514125
/* Write characters */
@@ -14195,13 +14195,13 @@ PyUnicode_Format(PyObject *format, PyObject *args)
1419514195
Py_DECREF(uformat);
1419614196
Py_XDECREF(temp);
1419714197
Py_XDECREF(second);
14198-
return unicode_writer_finish(&writer);
14198+
return _PyUnicodeWriter_Finish(&writer);
1419914199

1420014200
onError:
1420114201
Py_DECREF(uformat);
1420214202
Py_XDECREF(temp);
1420314203
Py_XDECREF(second);
14204-
unicode_writer_dealloc(&writer);
14204+
_PyUnicodeWriter_Dealloc(&writer);
1420514205
if (args_owned) {
1420614206
Py_DECREF(args);
1420714207
}

0 commit comments

Comments
 (0)