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
995026a8
Kaydet (Commit)
995026a8
authored
Eyl 14, 2016
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge 3.5 (#28119)
üst
f6365e38
59e5e0dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
22 deletions
+14
-22
formatter_unicode.c
Python/formatter_unicode.c
+14
-22
No files found.
Python/formatter_unicode.c
Dosyayı görüntüle @
995026a8
...
@@ -115,11 +115,13 @@ is_sign_element(Py_UCS4 c)
...
@@ -115,11 +115,13 @@ is_sign_element(Py_UCS4 c)
}
}
/* Locale type codes. LT_NO_LOCALE must be zero. */
/* Locale type codes. LT_NO_LOCALE must be zero. */
#define LT_NO_LOCALE 0
enum
LocaleType
{
#define LT_DEFAULT_LOCALE 1
LT_NO_LOCALE
=
0
,
#define LT_UNDERSCORE_LOCALE 2
LT_DEFAULT_LOCALE
,
#define LT_UNDER_FOUR_LOCALE 3
LT_UNDERSCORE_LOCALE
,
#define LT_CURRENT_LOCALE 4
LT_UNDER_FOUR_LOCALE
,
LT_CURRENT_LOCALE
};
typedef
struct
{
typedef
struct
{
Py_UCS4
fill_char
;
Py_UCS4
fill_char
;
...
@@ -127,7 +129,7 @@ typedef struct {
...
@@ -127,7 +129,7 @@ typedef struct {
int
alternate
;
int
alternate
;
Py_UCS4
sign
;
Py_UCS4
sign
;
Py_ssize_t
width
;
Py_ssize_t
width
;
int
thousands_separators
;
enum
LocaleType
thousands_separators
;
Py_ssize_t
precision
;
Py_ssize_t
precision
;
Py_UCS4
type
;
Py_UCS4
type
;
}
InternalFormatSpec
;
}
InternalFormatSpec
;
...
@@ -180,7 +182,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
...
@@ -180,7 +182,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
format
->
alternate
=
0
;
format
->
alternate
=
0
;
format
->
sign
=
'\0'
;
format
->
sign
=
'\0'
;
format
->
width
=
-
1
;
format
->
width
=
-
1
;
format
->
thousands_separators
=
0
;
format
->
thousands_separators
=
LT_NO_LOCALE
;
format
->
precision
=
-
1
;
format
->
precision
=
-
1
;
format
->
type
=
default_type
;
format
->
type
=
default_type
;
...
@@ -240,7 +242,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
...
@@ -240,7 +242,7 @@ parse_internal_render_format_spec(PyObject *format_spec,
}
}
/* Underscore signifies add thousands separators */
/* Underscore signifies add thousands separators */
if
(
end
-
pos
&&
READ_spec
(
pos
)
==
'_'
)
{
if
(
end
-
pos
&&
READ_spec
(
pos
)
==
'_'
)
{
if
(
format
->
thousands_separators
!=
0
)
{
if
(
format
->
thousands_separators
!=
LT_NO_LOCALE
)
{
invalid_comma_and_underscore
();
invalid_comma_and_underscore
();
return
0
;
return
0
;
}
}
...
@@ -700,7 +702,7 @@ static const char no_grouping[1] = {CHAR_MAX};
...
@@ -700,7 +702,7 @@ static const char no_grouping[1] = {CHAR_MAX};
LT_CURRENT_LOCALE, a hard-coded locale if LT_DEFAULT_LOCALE or
LT_CURRENT_LOCALE, a hard-coded locale if LT_DEFAULT_LOCALE or
LT_UNDERSCORE_LOCALE/LT_UNDER_FOUR_LOCALE, or none if LT_NO_LOCALE. */
LT_UNDERSCORE_LOCALE/LT_UNDER_FOUR_LOCALE, or none if LT_NO_LOCALE. */
static
int
static
int
get_locale_info
(
int
type
,
LocaleInfo
*
locale_info
)
get_locale_info
(
enum
LocaleType
type
,
LocaleInfo
*
locale_info
)
{
{
switch
(
type
)
{
switch
(
type
)
{
case
LT_CURRENT_LOCALE
:
{
case
LT_CURRENT_LOCALE
:
{
...
@@ -713,10 +715,8 @@ get_locale_info(int type, LocaleInfo *locale_info)
...
@@ -713,10 +715,8 @@ get_locale_info(int type, LocaleInfo *locale_info)
locale_info
->
thousands_sep
=
PyUnicode_DecodeLocale
(
locale_info
->
thousands_sep
=
PyUnicode_DecodeLocale
(
locale_data
->
thousands_sep
,
locale_data
->
thousands_sep
,
NULL
);
NULL
);
if
(
locale_info
->
thousands_sep
==
NULL
)
{
if
(
locale_info
->
thousands_sep
==
NULL
)
Py_DECREF
(
locale_info
->
decimal_point
);
return
-
1
;
return
-
1
;
}
locale_info
->
grouping
=
locale_data
->
grouping
;
locale_info
->
grouping
=
locale_data
->
grouping
;
break
;
break
;
}
}
...
@@ -726,11 +726,8 @@ get_locale_info(int type, LocaleInfo *locale_info)
...
@@ -726,11 +726,8 @@ get_locale_info(int type, LocaleInfo *locale_info)
locale_info
->
decimal_point
=
PyUnicode_FromOrdinal
(
'.'
);
locale_info
->
decimal_point
=
PyUnicode_FromOrdinal
(
'.'
);
locale_info
->
thousands_sep
=
PyUnicode_FromOrdinal
(
locale_info
->
thousands_sep
=
PyUnicode_FromOrdinal
(
type
==
LT_DEFAULT_LOCALE
?
','
:
'_'
);
type
==
LT_DEFAULT_LOCALE
?
','
:
'_'
);
if
(
!
locale_info
->
decimal_point
||
!
locale_info
->
thousands_sep
)
{
if
(
!
locale_info
->
decimal_point
||
!
locale_info
->
thousands_sep
)
Py_XDECREF
(
locale_info
->
decimal_point
);
Py_XDECREF
(
locale_info
->
thousands_sep
);
return
-
1
;
return
-
1
;
}
if
(
type
!=
LT_UNDER_FOUR_LOCALE
)
if
(
type
!=
LT_UNDER_FOUR_LOCALE
)
locale_info
->
grouping
=
"
\3
"
;
/* Group every 3 characters. The
locale_info
->
grouping
=
"
\3
"
;
/* Group every 3 characters. The
(implicit) trailing 0 means repeat
(implicit) trailing 0 means repeat
...
@@ -741,15 +738,10 @@ get_locale_info(int type, LocaleInfo *locale_info)
...
@@ -741,15 +738,10 @@ get_locale_info(int type, LocaleInfo *locale_info)
case
LT_NO_LOCALE
:
case
LT_NO_LOCALE
:
locale_info
->
decimal_point
=
PyUnicode_FromOrdinal
(
'.'
);
locale_info
->
decimal_point
=
PyUnicode_FromOrdinal
(
'.'
);
locale_info
->
thousands_sep
=
PyUnicode_New
(
0
,
0
);
locale_info
->
thousands_sep
=
PyUnicode_New
(
0
,
0
);
if
(
!
locale_info
->
decimal_point
||
!
locale_info
->
thousands_sep
)
{
if
(
!
locale_info
->
decimal_point
||
!
locale_info
->
thousands_sep
)
Py_XDECREF
(
locale_info
->
decimal_point
);
Py_XDECREF
(
locale_info
->
thousands_sep
);
return
-
1
;
return
-
1
;
}
locale_info
->
grouping
=
no_grouping
;
locale_info
->
grouping
=
no_grouping
;
break
;
break
;
default:
assert
(
0
);
}
}
return
0
;
return
0
;
}
}
...
...
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