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
1f803f78
Kaydet (Commit)
1f803f78
authored
Ock 16, 2002
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Updated patch #487906: Revise inline docs.
üst
fdc8d758
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
28 deletions
+25
-28
stringobject.c
Objects/stringobject.c
+25
-28
No files found.
Objects/stringobject.c
Dosyayı görüntüle @
1f803f78
...
@@ -19,32 +19,29 @@ static PyStringObject *nullstring;
...
@@ -19,32 +19,29 @@ static PyStringObject *nullstring;
#endif
#endif
/*
/*
PyString_FromStringAndSize() and PyString_FromString() try in certain cases
For both PyString_FromString() and PyString_FromStringAndSize(), the
to share string objects. When the size of the string is zero, these
parameter `size' denotes number of characters to allocate, not counting any
routines always return a pointer to the same string object; when the size
null terminating character.
is one, they return a pointer to an already existing object if the contents
of the string is known. For PyString_FromString() this is always the case,
For PyString_FromString(), the parameter `str' points to a null-terminated
for PyString_FromStringAndSize() this is the case when the first argument
string containing exactly `size' bytes.
in not NULL.
For PyString_FromStringAndSize(), the parameter the parameter `str' is
A common practice of allocating a string and then filling it in or changing
either NULL or else points to a string containing at least `size' bytes. For
it must be done carefully. It is only allowed to change the contents of
PyString_FromStringAndSize(), the string in the `str' parameter does not
the string if the object was gotten from PyString_FromStringAndSize() with
have to be null-terminated. (Therefore it is safe to construct a substring
a NULL first argument, because in the future these routines may try to do
by calling `PyString_FromStringAndSize(origstring, substrlen)'.) If `str'
even more sharing of objects.
is NULL then PyString_FromStringAndSize() will allocate `size+1' bytes
(setting the last byte to the null terminating character) and you can fill in
The string in the `str' parameter does not have to be null-character
the data yourself. If `str' is non-NULL then the resulting PyString object
terminated. (Therefore it is safe to construct a substring by using
must be treated as immutable and you must not fill in nor alter the data
`PyString_FromStringAndSize(origstring, substrlen)'.)
yourself, since the strings may be shared.
The parameter `size' denotes number of characters to allocate, not
The PyObject member `op->ob_size', which denotes the number of "extra items"
counting the null terminating character. If the `str' argument is
in a variable-size object, will contain the number of bytes allocated for
not NULL, then it points to a of length `size'. For
string data, not counting the null terminating character. It is therefore
PyString_FromString, this string must be null-terminated.
equal to the equal to the `size' parameter (for PyString_FromStringAndSize())
or the length of the string in the `str' parameter (for PyString_FromString()).
The member `op->ob_size' denotes the number of bytes of data in the string,
not counting the null terminating character, and is therefore equal to the
`size' parameter.
*/
*/
PyObject
*
PyObject
*
PyString_FromStringAndSize
(
const
char
*
str
,
int
size
)
PyString_FromStringAndSize
(
const
char
*
str
,
int
size
)
...
@@ -605,7 +602,7 @@ string_print(PyStringObject *op, FILE *fp, int flags)
...
@@ -605,7 +602,7 @@ string_print(PyStringObject *op, FILE *fp, int flags)
/* figure out which quote to use; single is preferred */
/* figure out which quote to use; single is preferred */
quote
=
'\''
;
quote
=
'\''
;
if
(
strchr
(
op
->
ob_sval
,
'\''
)
&&
!
strchr
(
op
->
ob_sval
,
'"'
))
if
(
memchr
(
op
->
ob_sval
,
'\''
,
op
->
ob_size
)
&&
!
memchr
(
op
->
ob_sval
,
'"'
,
op
->
ob_size
))
quote
=
'"'
;
quote
=
'"'
;
fputc
(
quote
,
fp
);
fputc
(
quote
,
fp
);
...
@@ -649,7 +646,7 @@ string_repr(register PyStringObject *op)
...
@@ -649,7 +646,7 @@ string_repr(register PyStringObject *op)
/* figure out which quote to use; single is preferred */
/* figure out which quote to use; single is preferred */
quote
=
'\''
;
quote
=
'\''
;
if
(
strchr
(
op
->
ob_sval
,
'\''
)
&&
!
strchr
(
op
->
ob_sval
,
'"'
))
if
(
memchr
(
op
->
ob_sval
,
'\''
,
op
->
ob_size
)
&&
!
memchr
(
op
->
ob_sval
,
'"'
,
op
->
ob_size
))
quote
=
'"'
;
quote
=
'"'
;
p
=
PyString_AS_STRING
(
v
);
p
=
PyString_AS_STRING
(
v
);
...
...
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