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
a04d47b3
Kaydet (Commit)
a04d47b3
authored
Ock 21, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Don't use static buffers internally for formatstring().
üst
70d44787
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
stringobject.c
Objects/stringobject.c
+26
-25
No files found.
Objects/stringobject.c
Dosyayı görüntüle @
a04d47b3
...
@@ -580,18 +580,18 @@ getnextarg(args, arglen, p_argidx)
...
@@ -580,18 +580,18 @@ getnextarg(args, arglen, p_argidx)
extern
double
fabs
PROTO
((
double
));
extern
double
fabs
PROTO
((
double
));
static
char
*
static
int
formatfloat
(
flags
,
prec
,
type
,
v
)
formatfloat
(
buf
,
flags
,
prec
,
type
,
v
)
char
*
buf
;
int
flags
;
int
flags
;
int
prec
;
int
prec
;
int
type
;
int
type
;
object
*
v
;
object
*
v
;
{
{
char
fmt
[
20
];
char
fmt
[
20
];
static
char
buf
[
120
];
double
x
;
double
x
;
if
(
!
getargs
(
v
,
"d;float argument required"
,
&
x
))
if
(
!
getargs
(
v
,
"d;float argument required"
,
&
x
))
return
NULL
;
return
-
1
;
if
(
prec
<
0
)
if
(
prec
<
0
)
prec
=
6
;
prec
=
6
;
if
(
prec
>
50
)
if
(
prec
>
50
)
...
@@ -600,43 +600,43 @@ formatfloat(flags, prec, type, v)
...
@@ -600,43 +600,43 @@ formatfloat(flags, prec, type, v)
type
=
'g'
;
type
=
'g'
;
sprintf
(
fmt
,
"%%%s.%d%c"
,
(
flags
&
F_ALT
)
?
"#"
:
""
,
prec
,
type
);
sprintf
(
fmt
,
"%%%s.%d%c"
,
(
flags
&
F_ALT
)
?
"#"
:
""
,
prec
,
type
);
sprintf
(
buf
,
fmt
,
x
);
sprintf
(
buf
,
fmt
,
x
);
return
buf
;
return
strlen
(
buf
)
;
}
}
static
char
*
static
int
formatint
(
flags
,
prec
,
type
,
v
)
formatint
(
buf
,
flags
,
prec
,
type
,
v
)
char
*
buf
;
int
flags
;
int
flags
;
int
prec
;
int
prec
;
int
type
;
int
type
;
object
*
v
;
object
*
v
;
{
{
char
fmt
[
20
];
char
fmt
[
20
];
static
char
buf
[
50
];
long
x
;
long
x
;
if
(
!
getargs
(
v
,
"l;int argument required"
,
&
x
))
if
(
!
getargs
(
v
,
"l;int argument required"
,
&
x
))
return
NULL
;
return
-
1
;
if
(
prec
<
0
)
if
(
prec
<
0
)
prec
=
1
;
prec
=
1
;
sprintf
(
fmt
,
"%%%s.%dl%c"
,
(
flags
&
F_ALT
)
?
"#"
:
""
,
prec
,
type
);
sprintf
(
fmt
,
"%%%s.%dl%c"
,
(
flags
&
F_ALT
)
?
"#"
:
""
,
prec
,
type
);
sprintf
(
buf
,
fmt
,
x
);
sprintf
(
buf
,
fmt
,
x
);
return
buf
;
return
strlen
(
buf
)
;
}
}
static
char
*
static
int
formatchar
(
v
)
formatchar
(
buf
,
v
)
char
*
buf
;
object
*
v
;
object
*
v
;
{
{
static
char
buf
[
2
];
if
(
is_stringobject
(
v
))
{
if
(
is_stringobject
(
v
))
{
if
(
!
getargs
(
v
,
"c;%c requires int or char"
,
&
buf
[
0
]))
if
(
!
getargs
(
v
,
"c;%c requires int or char"
,
&
buf
[
0
]))
return
NULL
;
return
-
1
;
}
}
else
{
else
{
if
(
!
getargs
(
v
,
"b;%c requires int or char"
,
&
buf
[
0
]))
if
(
!
getargs
(
v
,
"b;%c requires int or char"
,
&
buf
[
0
]))
return
NULL
;
return
-
1
;
}
}
buf
[
1
]
=
'\0'
;
buf
[
1
]
=
'\0'
;
return
buf
;
return
1
;
}
}
...
@@ -698,6 +698,7 @@ formatstring(format, args)
...
@@ -698,6 +698,7 @@ formatstring(format, args)
char
*
buf
;
char
*
buf
;
int
sign
;
int
sign
;
int
len
;
int
len
;
char
tmpbuf
[
120
];
/* For format{float,int,char}() */
fmt
++
;
fmt
++
;
if
(
*
fmt
==
'('
)
{
if
(
*
fmt
==
'('
)
{
char
*
keystart
;
char
*
keystart
;
...
@@ -849,10 +850,10 @@ formatstring(format, args)
...
@@ -849,10 +850,10 @@ formatstring(format, args)
case
'X'
:
case
'X'
:
if
(
c
==
'i'
)
if
(
c
==
'i'
)
c
=
'd'
;
c
=
'd'
;
buf
=
formatint
(
flags
,
prec
,
c
,
v
);
buf
=
tmpbuf
;
if
(
buf
==
NULL
)
len
=
formatint
(
buf
,
flags
,
prec
,
c
,
v
);
if
(
len
<
0
)
goto
error
;
goto
error
;
len
=
strlen
(
buf
);
sign
=
(
c
==
'd'
);
sign
=
(
c
==
'd'
);
if
(
flags
&
F_ZERO
)
if
(
flags
&
F_ZERO
)
fill
=
'0'
;
fill
=
'0'
;
...
@@ -862,19 +863,19 @@ formatstring(format, args)
...
@@ -862,19 +863,19 @@ formatstring(format, args)
case
'f'
:
case
'f'
:
case
'g'
:
case
'g'
:
case
'G'
:
case
'G'
:
buf
=
formatfloat
(
flags
,
prec
,
c
,
v
);
buf
=
tmpbuf
;
if
(
buf
==
NULL
)
len
=
formatfloat
(
buf
,
flags
,
prec
,
c
,
v
);
if
(
len
<
0
)
goto
error
;
goto
error
;
len
=
strlen
(
buf
);
sign
=
1
;
sign
=
1
;
if
(
flags
&
F_ZERO
)
if
(
flags
&
F_ZERO
)
fill
=
'0'
;
fill
=
'0'
;
break
;
break
;
case
'c'
:
case
'c'
:
buf
=
formatchar
(
v
);
buf
=
tmpbuf
;
if
(
buf
==
NULL
)
len
=
formatchar
(
buf
,
v
);
if
(
len
<
0
)
goto
error
;
goto
error
;
len
=
1
;
break
;
break
;
default
:
default
:
err_setstr
(
ValueError
,
err_setstr
(
ValueError
,
...
...
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