@@ -108,7 +108,7 @@ static char *
108108error_ret (struct tok_state * tok ) /* XXX */
109109{
110110 tok -> decoding_erred = 1 ;
111- if (tok -> fp != NULL && tok -> buf != NULL ) /* see PyTokenizer_Free */
111+ if (tok -> fp != NULL && tok -> buf != NULL ) /* see _PyTokenizer_Free */
112112 PyMem_Free (tok -> buf );
113113 tok -> buf = tok -> cur = tok -> inp = NULL ;
114114 tok -> start = NULL ;
@@ -702,7 +702,7 @@ decode_str(const char *input, int single, struct tok_state *tok)
702702/* Set up tokenizer for string */
703703
704704struct tok_state *
705- PyTokenizer_FromString (const char * str , int exec_input )
705+ _PyTokenizer_FromString (const char * str , int exec_input )
706706{
707707 struct tok_state * tok = tok_new ();
708708 char * decoded ;
@@ -711,7 +711,7 @@ PyTokenizer_FromString(const char *str, int exec_input)
711711 return NULL ;
712712 decoded = decode_str (str , exec_input , tok );
713713 if (decoded == NULL ) {
714- PyTokenizer_Free (tok );
714+ _PyTokenizer_Free (tok );
715715 return NULL ;
716716 }
717717
@@ -723,23 +723,23 @@ PyTokenizer_FromString(const char *str, int exec_input)
723723/* Set up tokenizer for UTF-8 string */
724724
725725struct tok_state *
726- PyTokenizer_FromUTF8 (const char * str , int exec_input )
726+ _PyTokenizer_FromUTF8 (const char * str , int exec_input )
727727{
728728 struct tok_state * tok = tok_new ();
729729 char * translated ;
730730 if (tok == NULL )
731731 return NULL ;
732732 tok -> input = translated = translate_newlines (str , exec_input , tok );
733733 if (translated == NULL ) {
734- PyTokenizer_Free (tok );
734+ _PyTokenizer_Free (tok );
735735 return NULL ;
736736 }
737737 tok -> decoding_state = STATE_NORMAL ;
738738 tok -> enc = NULL ;
739739 tok -> str = translated ;
740740 tok -> encoding = new_string ("utf-8" , 5 , tok );
741741 if (!tok -> encoding ) {
742- PyTokenizer_Free (tok );
742+ _PyTokenizer_Free (tok );
743743 return NULL ;
744744 }
745745
@@ -751,14 +751,14 @@ PyTokenizer_FromUTF8(const char *str, int exec_input)
751751/* Set up tokenizer for file */
752752
753753struct tok_state *
754- PyTokenizer_FromFile (FILE * fp , const char * enc ,
755- const char * ps1 , const char * ps2 )
754+ _PyTokenizer_FromFile (FILE * fp , const char * enc ,
755+ const char * ps1 , const char * ps2 )
756756{
757757 struct tok_state * tok = tok_new ();
758758 if (tok == NULL )
759759 return NULL ;
760760 if ((tok -> buf = (char * )PyMem_Malloc (BUFSIZ )) == NULL ) {
761- PyTokenizer_Free (tok );
761+ _PyTokenizer_Free (tok );
762762 return NULL ;
763763 }
764764 tok -> cur = tok -> inp = tok -> buf ;
@@ -771,7 +771,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
771771 gets copied into the parse tree. */
772772 tok -> encoding = new_string (enc , strlen (enc ), tok );
773773 if (!tok -> encoding ) {
774- PyTokenizer_Free (tok );
774+ _PyTokenizer_Free (tok );
775775 return NULL ;
776776 }
777777 tok -> decoding_state = STATE_NORMAL ;
@@ -782,7 +782,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
782782/* Free a tok_state structure */
783783
784784void
785- PyTokenizer_Free (struct tok_state * tok )
785+ _PyTokenizer_Free (struct tok_state * tok )
786786{
787787 if (tok -> encoding != NULL ) {
788788 PyMem_Free (tok -> encoding );
@@ -2049,7 +2049,8 @@ tok_get(struct tok_state *tok, const char **p_start, const char **p_end)
20492049}
20502050
20512051int
2052- PyTokenizer_Get (struct tok_state * tok , const char * * p_start , const char * * p_end )
2052+ _PyTokenizer_Get (struct tok_state * tok ,
2053+ const char * * p_start , const char * * p_end )
20532054{
20542055 int result = tok_get (tok , p_start , p_end );
20552056 if (tok -> decoding_erred ) {
@@ -2062,15 +2063,15 @@ PyTokenizer_Get(struct tok_state *tok, const char **p_start, const char **p_end)
20622063/* Get the encoding of a Python file. Check for the coding cookie and check if
20632064 the file starts with a BOM.
20642065
2065- PyTokenizer_FindEncodingFilename () returns NULL when it can't find the
2066+ _PyTokenizer_FindEncodingFilename () returns NULL when it can't find the
20662067 encoding in the first or second line of the file (in which case the encoding
20672068 should be assumed to be UTF-8).
20682069
20692070 The char* returned is malloc'ed via PyMem_Malloc() and thus must be freed
20702071 by the caller. */
20712072
20722073char *
2073- PyTokenizer_FindEncodingFilename (int fd , PyObject * filename )
2074+ _PyTokenizer_FindEncodingFilename (int fd , PyObject * filename )
20742075{
20752076 struct tok_state * tok ;
20762077 FILE * fp ;
@@ -2087,7 +2088,7 @@ PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
20872088 if (fp == NULL ) {
20882089 return NULL ;
20892090 }
2090- tok = PyTokenizer_FromFile (fp , NULL , NULL , NULL );
2091+ tok = _PyTokenizer_FromFile (fp , NULL , NULL , NULL );
20912092 if (tok == NULL ) {
20922093 fclose (fp );
20932094 return NULL ;
@@ -2100,12 +2101,12 @@ PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
21002101 tok -> filename = PyUnicode_FromString ("<string>" );
21012102 if (tok -> filename == NULL ) {
21022103 fclose (fp );
2103- PyTokenizer_Free (tok );
2104+ _PyTokenizer_Free (tok );
21042105 return encoding ;
21052106 }
21062107 }
21072108 while (tok -> lineno < 2 && tok -> done == E_OK ) {
2108- PyTokenizer_Get (tok , & p_start , & p_end );
2109+ _PyTokenizer_Get (tok , & p_start , & p_end );
21092110 }
21102111 fclose (fp );
21112112 if (tok -> encoding ) {
@@ -2114,24 +2115,16 @@ PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
21142115 strcpy (encoding , tok -> encoding );
21152116 }
21162117 }
2117- PyTokenizer_Free (tok );
2118+ _PyTokenizer_Free (tok );
21182119 return encoding ;
21192120}
21202121
2121- char *
2122- PyTokenizer_FindEncoding (int fd )
2123- {
2124- return PyTokenizer_FindEncodingFilename (fd , NULL );
2125- }
2126-
21272122#ifdef Py_DEBUG
2128-
21292123void
21302124tok_dump (int type , char * start , char * end )
21312125{
21322126 printf ("%s" , _PyParser_TokenNames [type ]);
21332127 if (type == NAME || type == NUMBER || type == STRING || type == OP )
21342128 printf ("(%.*s)" , (int )(end - start ), start );
21352129}
2136-
2137- #endif
2130+ #endif // Py_DEBUG
0 commit comments