@@ -13,10 +13,10 @@ const char *_Py_PackageContext = NULL;
1313
1414/* Helper for mkvalue() to scan the length of a format */
1515
16- static int
16+ static Py_ssize_t
1717countformat (const char * format , int endchar )
1818{
19- int count = 0 ;
19+ Py_ssize_t count = 0 ;
2020 int level = 0 ;
2121 while (level > 0 || * format != endchar ) {
2222 switch (* format ) {
@@ -28,8 +28,9 @@ countformat(const char *format, int endchar)
2828 case '(' :
2929 case '[' :
3030 case '{' :
31- if (level == 0 )
31+ if (level == 0 ) {
3232 count ++ ;
33+ }
3334 level ++ ;
3435 break ;
3536 case ')' :
@@ -45,8 +46,9 @@ countformat(const char *format, int endchar)
4546 case '\t' :
4647 break ;
4748 default :
48- if (level == 0 )
49+ if (level == 0 ) {
4950 count ++ ;
51+ }
5052 }
5153 format ++ ;
5254 }
@@ -57,17 +59,17 @@ countformat(const char *format, int endchar)
5759/* Generic function to create a value -- the inverse of getargs() */
5860/* After an original idea and first implementation by Steven Miale */
5961
60- static PyObject * do_mktuple (const char * * , va_list * , int , int , int );
61- static PyObject * do_mklist (const char * * , va_list * , int , int , int );
62- static PyObject * do_mkdict (const char * * , va_list * , int , int , int );
62+ static PyObject * do_mktuple (const char * * , va_list * , int , Py_ssize_t , int );
63+ static PyObject * do_mklist (const char * * , va_list * , int , Py_ssize_t , int );
64+ static PyObject * do_mkdict (const char * * , va_list * , int , Py_ssize_t , int );
6365static PyObject * do_mkvalue (const char * * , va_list * , int );
6466
6567
6668static void
67- do_ignore (const char * * p_format , va_list * p_va , int endchar , int n , int flags )
69+ do_ignore (const char * * p_format , va_list * p_va , int endchar , Py_ssize_t n , int flags )
6870{
6971 PyObject * v ;
70- int i ;
72+ Py_ssize_t i ;
7173 assert (PyErr_Occurred ());
7274 v = PyTuple_New (n );
7375 for (i = 0 ; i < n ; i ++ ) {
@@ -91,15 +93,16 @@ do_ignore(const char **p_format, va_list *p_va, int endchar, int n, int flags)
9193 "Unmatched paren in format" );
9294 return ;
9395 }
94- if (endchar )
96+ if (endchar ) {
9597 ++ * p_format ;
98+ }
9699}
97100
98101static PyObject *
99- do_mkdict (const char * * p_format , va_list * p_va , int endchar , int n , int flags )
102+ do_mkdict (const char * * p_format , va_list * p_va , int endchar , Py_ssize_t n , int flags )
100103{
101104 PyObject * d ;
102- int i ;
105+ Py_ssize_t i ;
103106 if (n < 0 )
104107 return NULL ;
105108 if (n % 2 ) {
@@ -146,10 +149,10 @@ do_mkdict(const char **p_format, va_list *p_va, int endchar, int n, int flags)
146149}
147150
148151static PyObject *
149- do_mklist (const char * * p_format , va_list * p_va , int endchar , int n , int flags )
152+ do_mklist (const char * * p_format , va_list * p_va , int endchar , Py_ssize_t n , int flags )
150153{
151154 PyObject * v ;
152- int i ;
155+ Py_ssize_t i ;
153156 if (n < 0 )
154157 return NULL ;
155158 /* Note that we can't bail immediately on error as this will leak
@@ -180,10 +183,10 @@ do_mklist(const char **p_format, va_list *p_va, int endchar, int n, int flags)
180183}
181184
182185static PyObject *
183- do_mktuple (const char * * p_format , va_list * p_va , int endchar , int n , int flags )
186+ do_mktuple (const char * * p_format , va_list * p_va , int endchar , Py_ssize_t n , int flags )
184187{
185188 PyObject * v ;
186- int i ;
189+ Py_ssize_t i ;
187190 if (n < 0 )
188191 return NULL ;
189192 /* Note that we can't bail immediately on error as this will leak
@@ -465,7 +468,7 @@ static PyObject *
465468va_build_value (const char * format , va_list va , int flags )
466469{
467470 const char * f = format ;
468- int n = countformat (f , '\0' );
471+ Py_ssize_t n = countformat (f , '\0' );
469472 va_list lva ;
470473 PyObject * retval ;
471474
0 commit comments