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
bd304aa3
Commit
bd304aa3
authored
Oct 30, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28561: Clean up UTF-8 encoder: remove dead code, update comments, etc.
Patch by Xiang Zhang.
parent
d9dd5918
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
+4
-10
Objects/stringlib/codecs.h
Objects/stringlib/codecs.h
+4
-10
No files found.
Objects/stringlib/codecs.h
View file @
bd304aa3
...
...
@@ -262,9 +262,7 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
Py_ssize_t
size
,
const
char
*
errors
)
{
#define MAX_SHORT_UNICHARS 300
/* largest size we'll do on the stack */
Py_ssize_t
i
;
/* index into s of next input byte */
Py_ssize_t
i
;
/* index into data of next input character */
char
*
p
;
/* next free byte in output buffer */
#if STRINGLIB_SIZEOF_CHAR > 1
PyObject
*
error_handler_obj
=
NULL
;
...
...
@@ -389,7 +387,7 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
goto
error
;
/* subtract preallocated bytes */
writer
.
min_size
-=
max_char_size
;
writer
.
min_size
-=
max_char_size
*
(
newpos
-
startpos
)
;
if
(
PyBytes_Check
(
rep
))
{
p
=
_PyBytesWriter_WriteBytes
(
&
writer
,
p
,
...
...
@@ -402,14 +400,12 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
goto
error
;
if
(
!
PyUnicode_IS_ASCII
(
rep
))
{
raise_encode_exception
(
&
exc
,
"utf-8"
,
unicode
,
i
-
1
,
i
,
raise_encode_exception
(
&
exc
,
"utf-8"
,
unicode
,
startpos
,
endpos
,
"surrogates not allowed"
);
goto
error
;
}
assert
(
PyUnicode_KIND
(
rep
)
==
PyUnicode_1BYTE_KIND
);
p
=
_PyBytesWriter_WriteBytes
(
&
writer
,
p
,
PyUnicode_DATA
(
rep
),
PyUnicode_GET_LENGTH
(
rep
));
...
...
@@ -463,8 +459,6 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
_PyBytesWriter_Dealloc
(
&
writer
);
return
NULL
;
#endif
#undef MAX_SHORT_UNICHARS
}
/* The pattern for constructing UCS2-repeated masks. */
...
...
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