Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ce179bf6
Kaydet (Commit)
ce179bf6
authored
Eki 09, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add _PyBytesWriter_WriteBytes() to factorize the code
üst
ad771589
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
16 deletions
+35
-16
bytesobject.h
Include/bytesobject.h
+7
-0
bytesobject.c
Objects/bytesobject.c
+14
-0
codecs.h
Objects/stringlib/codecs.h
+11
-11
unicodeobject.c
Objects/unicodeobject.c
+3
-5
No files found.
Include/bytesobject.h
Dosyayı görüntüle @
ce179bf6
...
@@ -174,6 +174,13 @@ PyAPI_FUNC(char*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
...
@@ -174,6 +174,13 @@ PyAPI_FUNC(char*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
PyAPI_FUNC
(
char
*
)
_PyBytesWriter_Prepare
(
_PyBytesWriter
*
writer
,
PyAPI_FUNC
(
char
*
)
_PyBytesWriter_Prepare
(
_PyBytesWriter
*
writer
,
char
*
str
,
char
*
str
,
Py_ssize_t
size
);
Py_ssize_t
size
);
/* Write bytes.
Raise an exception and return NULL on error. */
PyAPI_FUNC
(
char
*
)
_PyBytesWriter_WriteBytes
(
_PyBytesWriter
*
writer
,
char
*
str
,
char
*
bytes
,
Py_ssize_t
size
);
#endif
/* Py_LIMITED_API */
#endif
/* Py_LIMITED_API */
#ifdef __cplusplus
#ifdef __cplusplus
...
...
Objects/bytesobject.c
Dosyayı görüntüle @
ce179bf6
...
@@ -3995,3 +3995,17 @@ _PyBytesWriter_Finish(_PyBytesWriter *writer, char *str)
...
@@ -3995,3 +3995,17 @@ _PyBytesWriter_Finish(_PyBytesWriter *writer, char *str)
return
result
;
return
result
;
}
}
char
*
_PyBytesWriter_WriteBytes
(
_PyBytesWriter
*
writer
,
char
*
str
,
char
*
bytes
,
Py_ssize_t
size
)
{
str
=
_PyBytesWriter_Prepare
(
writer
,
str
,
size
);
if
(
str
==
NULL
)
return
NULL
;
Py_MEMCPY
(
str
,
bytes
,
size
);
str
+=
size
;
return
str
;
}
Objects/stringlib/codecs.h
Dosyayı görüntüle @
ce179bf6
...
@@ -388,24 +388,24 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
...
@@ -388,24 +388,24 @@ STRINGLIB(utf8_encoder)(PyObject *unicode,
/* substract preallocated bytes */
/* substract preallocated bytes */
writer
.
min_size
-=
max_char_size
;
writer
.
min_size
-=
max_char_size
;
if
(
PyBytes_Check
(
rep
))
repsize
=
PyBytes_GET_SIZE
(
rep
);
else
repsize
=
PyUnicode_GET_LENGTH
(
rep
);
p
=
_PyBytesWriter_Prepare
(
&
writer
,
p
,
repsize
);
if
(
p
==
NULL
)
goto
error
;
if
(
PyBytes_Check
(
rep
))
{
if
(
PyBytes_Check
(
rep
))
{
memcpy
(
p
,
PyBytes_AS_STRING
(
rep
),
repsize
);
p
=
_PyBytesWriter_WriteBytes
(
&
writer
,
p
,
p
+=
repsize
;
PyBytes_AS_STRING
(
rep
),
PyBytes_GET_SIZE
(
rep
));
if
(
p
==
NULL
)
goto
error
;
}
}
else
{
else
{
/* rep is unicode */
/* rep is unicode */
if
(
PyUnicode_READY
(
rep
)
<
0
)
if
(
PyUnicode_READY
(
rep
)
<
0
)
goto
error
;
goto
error
;
repsize
=
PyUnicode_GET_LENGTH
(
rep
);
p
=
_PyBytesWriter_Prepare
(
&
writer
,
p
,
repsize
);
if
(
p
==
NULL
)
goto
error
;
if
(
!
PyUnicode_IS_ASCII
(
rep
))
{
if
(
!
PyUnicode_IS_ASCII
(
rep
))
{
raise_encode_exception
(
&
exc
,
"utf-8"
,
raise_encode_exception
(
&
exc
,
"utf-8"
,
unicode
,
unicode
,
...
...
Objects/unicodeobject.c
Dosyayı görüntüle @
ce179bf6
...
@@ -6706,14 +6706,12 @@ unicode_encode_ucs1(PyObject *unicode,
...
@@ -6706,14 +6706,12 @@ unicode_encode_ucs1(PyObject *unicode,
if (PyBytes_Check(repunicode)) {
if (PyBytes_Check(repunicode)) {
/* Directly copy bytes result to output. */
/* Directly copy bytes result to output. */
repsize = PyBytes_Size(repunicode);
str = _PyBytesWriter_WriteBytes(&writer, str,
PyBytes_AS_STRING(repunicode),
str = _PyBytesWriter_Prepare(&writer, str, repsize
);
PyBytes_GET_SIZE(repunicode)
);
if (str == NULL)
if (str == NULL)
goto onError;
goto onError;
memcpy(str, PyBytes_AsString(repunicode), repsize);
str += repsize;
pos = newpos;
pos = newpos;
Py_DECREF(repunicode);
Py_DECREF(repunicode);
break;
break;
...
...
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