mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
tokenizer: Remove unused tabs options (#4422)
Remove the following fields from tok_state structure which are now used unused: * altwarning: "Issue warning if alternate tabs don't match" * alterror: "Issue error if alternate tabs don't match" * alttabsize: "Alternate tab spacing" Replace alttabsize variable with ALTTABSIZE define.
This commit is contained in:
parent
fd0fa67464
commit
f2ddc6ac93
2 changed files with 11 additions and 34 deletions
|
|
@ -18,6 +18,9 @@
|
||||||
#include "abstract.h"
|
#include "abstract.h"
|
||||||
#endif /* PGEN */
|
#endif /* PGEN */
|
||||||
|
|
||||||
|
/* Alternate tab spacing */
|
||||||
|
#define ALTTABSIZE 1
|
||||||
|
|
||||||
#define is_potential_identifier_start(c) (\
|
#define is_potential_identifier_start(c) (\
|
||||||
(c >= 'a' && c <= 'z')\
|
(c >= 'a' && c <= 'z')\
|
||||||
|| (c >= 'A' && c <= 'Z')\
|
|| (c >= 'A' && c <= 'Z')\
|
||||||
|
|
@ -133,9 +136,6 @@ tok_new(void)
|
||||||
tok->prompt = tok->nextprompt = NULL;
|
tok->prompt = tok->nextprompt = NULL;
|
||||||
tok->lineno = 0;
|
tok->lineno = 0;
|
||||||
tok->level = 0;
|
tok->level = 0;
|
||||||
tok->altwarning = 1;
|
|
||||||
tok->alterror = 1;
|
|
||||||
tok->alttabsize = 1;
|
|
||||||
tok->altindstack[0] = 0;
|
tok->altindstack[0] = 0;
|
||||||
tok->decoding_state = STATE_INIT;
|
tok->decoding_state = STATE_INIT;
|
||||||
tok->decoding_erred = 0;
|
tok->decoding_erred = 0;
|
||||||
|
|
@ -1283,22 +1283,9 @@ PyToken_ThreeChars(int c1, int c2, int c3)
|
||||||
static int
|
static int
|
||||||
indenterror(struct tok_state *tok)
|
indenterror(struct tok_state *tok)
|
||||||
{
|
{
|
||||||
if (tok->alterror) {
|
tok->done = E_TABSPACE;
|
||||||
tok->done = E_TABSPACE;
|
tok->cur = tok->inp;
|
||||||
tok->cur = tok->inp;
|
return ERRORTOKEN;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (tok->altwarning) {
|
|
||||||
#ifdef PGEN
|
|
||||||
PySys_WriteStderr("inconsistent use of tabs and spaces "
|
|
||||||
"in indentation\n");
|
|
||||||
#else
|
|
||||||
PySys_FormatStderr("%U: inconsistent use of tabs and spaces "
|
|
||||||
"in indentation\n", tok->filename);
|
|
||||||
#endif
|
|
||||||
tok->altwarning = 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PGEN
|
#ifdef PGEN
|
||||||
|
|
@ -1378,9 +1365,8 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
|
||||||
col++, altcol++;
|
col++, altcol++;
|
||||||
}
|
}
|
||||||
else if (c == '\t') {
|
else if (c == '\t') {
|
||||||
col = (col/tok->tabsize + 1) * tok->tabsize;
|
col = (col / tok->tabsize + 1) * tok->tabsize;
|
||||||
altcol = (altcol/tok->alttabsize + 1)
|
altcol = (altcol / ALTTABSIZE + 1) * ALTTABSIZE;
|
||||||
* tok->alttabsize;
|
|
||||||
}
|
}
|
||||||
else if (c == '\014') {/* Control-L (formfeed) */
|
else if (c == '\014') {/* Control-L (formfeed) */
|
||||||
col = altcol = 0; /* For Emacs users */
|
col = altcol = 0; /* For Emacs users */
|
||||||
|
|
@ -1409,9 +1395,7 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
|
||||||
if (col == tok->indstack[tok->indent]) {
|
if (col == tok->indstack[tok->indent]) {
|
||||||
/* No change */
|
/* No change */
|
||||||
if (altcol != tok->altindstack[tok->indent]) {
|
if (altcol != tok->altindstack[tok->indent]) {
|
||||||
if (indenterror(tok)) {
|
return indenterror(tok);
|
||||||
return ERRORTOKEN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (col > tok->indstack[tok->indent]) {
|
else if (col > tok->indstack[tok->indent]) {
|
||||||
|
|
@ -1422,9 +1406,7 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
|
||||||
return ERRORTOKEN;
|
return ERRORTOKEN;
|
||||||
}
|
}
|
||||||
if (altcol <= tok->altindstack[tok->indent]) {
|
if (altcol <= tok->altindstack[tok->indent]) {
|
||||||
if (indenterror(tok)) {
|
return indenterror(tok);
|
||||||
return ERRORTOKEN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tok->pendin++;
|
tok->pendin++;
|
||||||
tok->indstack[++tok->indent] = col;
|
tok->indstack[++tok->indent] = col;
|
||||||
|
|
@ -1443,9 +1425,7 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
|
||||||
return ERRORTOKEN;
|
return ERRORTOKEN;
|
||||||
}
|
}
|
||||||
if (altcol != tok->altindstack[tok->indent]) {
|
if (altcol != tok->altindstack[tok->indent]) {
|
||||||
if (indenterror(tok)) {
|
return indenterror(tok);
|
||||||
return ERRORTOKEN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,6 @@ struct tok_state {
|
||||||
(Grammar/Grammar). */
|
(Grammar/Grammar). */
|
||||||
PyObject *filename;
|
PyObject *filename;
|
||||||
#endif
|
#endif
|
||||||
int altwarning; /* Issue warning if alternate tabs don't match */
|
|
||||||
int alterror; /* Issue error if alternate tabs don't match */
|
|
||||||
int alttabsize; /* Alternate tab spacing */
|
|
||||||
int altindstack[MAXINDENT]; /* Stack of alternate indents */
|
int altindstack[MAXINDENT]; /* Stack of alternate indents */
|
||||||
/* Stuff for PEP 0263 */
|
/* Stuff for PEP 0263 */
|
||||||
enum decoding_state decoding_state;
|
enum decoding_state decoding_state;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue