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
6364927c
Commit
6364927c
authored
Sep 29, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PyLocale_strxfrm() uses the new Unicode API
parent
fe9a861e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
24 deletions
+15
-24
Modules/_localemodule.c
Modules/_localemodule.c
+15
-24
No files found.
Modules/_localemodule.c
View file @
6364927c
...
...
@@ -271,31 +271,22 @@ Return a string that can be used as a key for locale-aware comparisons.");
static
PyObject
*
PyLocale_strxfrm
(
PyObject
*
self
,
PyObject
*
args
)
{
Py
_UNICODE
*
s0
;
Py_ssize_t
n
0
;
wchar_t
*
s
,
*
buf
=
NULL
;
size_t
n
1
,
n
2
;
Py
Object
*
str
;
Py_ssize_t
n
1
;
wchar_t
*
s
=
NULL
,
*
buf
=
NULL
;
size_t
n2
;
PyObject
*
result
=
NULL
;
#if Py_UNICODE_SIZE != SIZEOF_WCHAR_T
Py_ssize_t
i
;
#endif
if
(
!
PyArg_ParseTuple
(
args
,
"
u#:strxfrm"
,
&
s0
,
&
n0
))
if
(
!
PyArg_ParseTuple
(
args
,
"
U:strxfrm"
,
&
str
))
return
NULL
;
#if Py_UNICODE_SIZE == SIZEOF_WCHAR_T
s
=
(
wchar_t
*
)
s0
;
#else
s
=
PyMem_Malloc
((
n0
+
1
)
*
sizeof
(
wchar_t
));
if
(
!
s
)
return
PyErr_NoMemory
();
for
(
i
=
0
;
i
<=
n0
;
i
++
)
s
[
i
]
=
s0
[
i
];
#endif
s
=
PyUnicode_AsWideCharString
(
str
,
&
n1
);
if
(
s
==
NULL
)
goto
exit
;
/* assume no change in size, first */
n1
=
wcslen
(
s
)
+
1
;
buf
=
PyMem_Malloc
(
n1
*
sizeof
(
wchar_t
));
n1
=
n1
+
1
;
buf
=
PyMem_Malloc
(
n1
*
sizeof
(
wchar_t
));
if
(
!
buf
)
{
PyErr_NoMemory
();
goto
exit
;
...
...
@@ -311,11 +302,11 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
n2
=
wcsxfrm
(
buf
,
s
,
n2
+
1
);
}
result
=
PyUnicode_FromWideChar
(
buf
,
n2
);
exit:
if
(
buf
)
PyMem_Free
(
buf
);
#if Py_UNICODE_SIZE != SIZEOF_WCHAR_T
PyMem_Free
(
s
);
#endif
exit:
if
(
buf
)
PyMem_Free
(
buf
);
if
(
s
)
PyMem_Free
(
s
);
return
result
;
}
#endif
...
...
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