Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3b1a74a9
Commit
3b1a74a9
authored
May 09, 2012
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename unicode_write_t structure and its methods to "_PyUnicodeWriter"
parent
ee4544c9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
Objects/stringlib/unicode_format.h
Objects/stringlib/unicode_format.h
+9
-9
Objects/unicodeobject.c
Objects/unicodeobject.c
+16
-16
No files found.
Objects/stringlib/unicode_format.h
View file @
3b1a74a9
...
...
@@ -494,7 +494,7 @@ error:
appends to the output.
*/
static
int
render_field
(
PyObject
*
fieldobj
,
SubString
*
format_spec
,
unicode_writer_t
*
writer
)
render_field
(
PyObject
*
fieldobj
,
SubString
*
format_spec
,
_PyUnicodeWriter
*
writer
)
{
int
ok
=
0
;
PyObject
*
result
=
NULL
;
...
...
@@ -540,7 +540,7 @@ render_field(PyObject *fieldobj, SubString *format_spec, unicode_writer_t *write
goto
done
;
len
=
PyUnicode_GET_LENGTH
(
result
);
if
(
unicode_writer_p
repare
(
writer
,
if
(
_PyUnicodeWriter_P
repare
(
writer
,
len
,
PyUnicode_MAX_CHAR_VALUE
(
result
))
==
-
1
)
goto
done
;
copy_characters
(
writer
->
buffer
,
writer
->
pos
,
...
...
@@ -811,7 +811,7 @@ do_conversion(PyObject *obj, Py_UCS4 conversion)
static
int
output_markup
(
SubString
*
field_name
,
SubString
*
format_spec
,
int
format_spec_needs_expanding
,
Py_UCS4
conversion
,
unicode_writer_t
*
writer
,
PyObject
*
args
,
PyObject
*
kwargs
,
_PyUnicodeWriter
*
writer
,
PyObject
*
args
,
PyObject
*
kwargs
,
int
recursion_depth
,
AutoNumber
*
auto_number
)
{
PyObject
*
tmp
=
NULL
;
...
...
@@ -872,7 +872,7 @@ done:
*/
static
int
do_markup
(
SubString
*
input
,
PyObject
*
args
,
PyObject
*
kwargs
,
unicode_writer_t
*
writer
,
int
recursion_depth
,
AutoNumber
*
auto_number
)
_PyUnicodeWriter
*
writer
,
int
recursion_depth
,
AutoNumber
*
auto_number
)
{
MarkupIterator
iter
;
int
format_spec_needs_expanding
;
...
...
@@ -894,7 +894,7 @@ do_markup(SubString *input, PyObject *args, PyObject *kwargs,
if
(
sublen
)
{
maxchar
=
_PyUnicode_FindMaxChar
(
literal
.
str
,
literal
.
start
,
literal
.
end
);
err
=
unicode_writer_p
repare
(
writer
,
sublen
,
maxchar
);
err
=
_PyUnicodeWriter_P
repare
(
writer
,
sublen
,
maxchar
);
if
(
err
==
-
1
)
return
0
;
copy_characters
(
writer
->
buffer
,
writer
->
pos
,
...
...
@@ -920,7 +920,7 @@ static PyObject *
build_string
(
SubString
*
input
,
PyObject
*
args
,
PyObject
*
kwargs
,
int
recursion_depth
,
AutoNumber
*
auto_number
)
{
unicode_writer_t
writer
;
_PyUnicodeWriter
writer
;
Py_ssize_t
initlen
;
/* check the recursion level */
...
...
@@ -931,16 +931,16 @@ build_string(SubString *input, PyObject *args, PyObject *kwargs,
}
initlen
=
PyUnicode_GET_LENGTH
(
input
->
str
)
+
100
;
if
(
unicode_writer_i
nit
(
&
writer
,
initlen
,
127
)
==
-
1
)
if
(
_PyUnicodeWriter_I
nit
(
&
writer
,
initlen
,
127
)
==
-
1
)
return
NULL
;
if
(
!
do_markup
(
input
,
args
,
kwargs
,
&
writer
,
recursion_depth
,
auto_number
))
{
unicode_writer_d
ealloc
(
&
writer
);
_PyUnicodeWriter_D
ealloc
(
&
writer
);
return
NULL
;
}
return
unicode_writer_f
inish
(
&
writer
);
return
_PyUnicodeWriter_F
inish
(
&
writer
);
}
/************************************************************************/
...
...
Objects/unicodeobject.c
View file @
3b1a74a9
...
...
@@ -13207,10 +13207,10 @@ typedef struct {
enum
PyUnicode_Kind
kind
;
Py_UCS4
maxchar
;
Py_ssize_t
pos
;
}
unicode_writer_t
;
}
_PyUnicodeWriter
;
Py_LOCAL_INLINE
(
void
)
unicode_writer_update
(
unicode_writer_t
*
writer
)
_PyUnicodeWriter_Update
(
_PyUnicodeWriter
*
writer
)
{
writer
->
maxchar
=
PyUnicode_MAX_CHAR_VALUE
(
writer
->
buffer
);
writer
->
data
=
PyUnicode_DATA
(
writer
->
buffer
);
...
...
@@ -13218,19 +13218,19 @@ unicode_writer_update(unicode_writer_t *writer)
}
Py_LOCAL
(
int
)
unicode_writer_init
(
unicode_writer_t
*
writer
,
_PyUnicodeWriter_Init
(
_PyUnicodeWriter
*
writer
,
Py_ssize_t
length
,
Py_UCS4
maxchar
)
{
writer
->
pos
=
0
;
writer
->
buffer
=
PyUnicode_New
(
length
,
maxchar
);
if
(
writer
->
buffer
==
NULL
)
return
-
1
;
unicode_writer_u
pdate
(
writer
);
_PyUnicodeWriter_U
pdate
(
writer
);
return
0
;
}
Py_LOCAL_INLINE
(
int
)
unicode_writer_prepare
(
unicode_writer_t
*
writer
,
_PyUnicodeWriter_Prepare
(
_PyUnicodeWriter
*
writer
,
Py_ssize_t
length
,
Py_UCS4
maxchar
)
{
Py_ssize_t
newlen
;
...
...
@@ -13262,18 +13262,18 @@ unicode_writer_prepare(unicode_writer_t *writer,
return
-
1
;
}
writer
->
buffer
=
newbuffer
;
unicode_writer_u
pdate
(
writer
);
_PyUnicodeWriter_U
pdate
(
writer
);
}
else
if
(
maxchar
>
writer
->
maxchar
)
{
if
(
unicode_widen
(
&
writer
->
buffer
,
writer
->
pos
,
maxchar
)
<
0
)
return
-
1
;
unicode_writer_u
pdate
(
writer
);
_PyUnicodeWriter_U
pdate
(
writer
);
}
return
0
;
}
Py_LOCAL
(
PyObject
*
)
unicode_writer_finish
(
unicode_writer_t
*
writer
)
_PyUnicodeWriter_Finish
(
_PyUnicodeWriter
*
writer
)
{
if
(
PyUnicode_Resize
(
&
writer
->
buffer
,
writer
->
pos
)
<
0
)
{
Py_DECREF
(
writer
->
buffer
);
...
...
@@ -13284,7 +13284,7 @@ unicode_writer_finish(unicode_writer_t *writer)
}
Py_LOCAL
(
void
)
unicode_writer_dealloc
(
unicode_writer_t
*
writer
)
_PyUnicodeWriter_Dealloc
(
_PyUnicodeWriter
*
writer
)
{
Py_CLEAR
(
writer
->
buffer
);
}
...
...
@@ -13749,7 +13749,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
PyObject
*
uformat
;
void
*
fmt
;
enum
PyUnicode_Kind
kind
,
fmtkind
;
unicode_writer_t
writer
;
_PyUnicodeWriter
writer
;
Py_ssize_t
sublen
;
Py_UCS4
maxchar
;
...
...
@@ -13768,7 +13768,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
fmtcnt
=
PyUnicode_GET_LENGTH
(
uformat
);
fmtpos
=
0
;
if
(
unicode_writer_i
nit
(
&
writer
,
fmtcnt
+
100
,
127
)
<
0
)
if
(
_PyUnicodeWriter_I
nit
(
&
writer
,
fmtcnt
+
100
,
127
)
<
0
)
goto
onError
;
if
(
PyTuple_Check
(
args
))
{
...
...
@@ -13797,7 +13797,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
sublen
=
fmtpos
-
nonfmtpos
;
maxchar
=
_PyUnicode_FindMaxChar
(
uformat
,
nonfmtpos
,
nonfmtpos
+
sublen
);
if
(
unicode_writer_p
repare
(
&
writer
,
sublen
,
maxchar
)
==
-
1
)
if
(
_PyUnicodeWriter_P
repare
(
&
writer
,
sublen
,
maxchar
)
==
-
1
)
goto
onError
;
copy_characters
(
writer
.
buffer
,
writer
.
pos
,
...
...
@@ -13961,7 +13961,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
}
if
(
c
==
'%'
)
{
if
(
unicode_writer_p
repare
(
&
writer
,
1
,
'%'
)
==
-
1
)
if
(
_PyUnicodeWriter_P
repare
(
&
writer
,
1
,
'%'
)
==
-
1
)
goto
onError
;
PyUnicode_WRITE
(
writer
.
kind
,
writer
.
data
,
writer
.
pos
,
'%'
);
writer
.
pos
+=
1
;
...
...
@@ -14119,7 +14119,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
if
(
sign
&&
len
==
width
)
buflen
++
;
if
(
unicode_writer_p
repare
(
&
writer
,
buflen
,
bufmaxchar
)
==
-
1
)
if
(
_PyUnicodeWriter_P
repare
(
&
writer
,
buflen
,
bufmaxchar
)
==
-
1
)
goto
onError
;
/* Write characters */
...
...
@@ -14195,13 +14195,13 @@ PyUnicode_Format(PyObject *format, PyObject *args)
Py_DECREF
(
uformat
);
Py_XDECREF
(
temp
);
Py_XDECREF
(
second
);
return
unicode_writer_f
inish
(
&
writer
);
return
_PyUnicodeWriter_F
inish
(
&
writer
);
onError:
Py_DECREF
(
uformat
);
Py_XDECREF
(
temp
);
Py_XDECREF
(
second
);
unicode_writer_d
ealloc
(
&
writer
);
_PyUnicodeWriter_D
ealloc
(
&
writer
);
if
(
args_owned
)
{
Py_DECREF
(
args
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment