Commit 6cb29351 authored by Guido van Rossum's avatar Guido van Rossum

Minor cleanup of parsename() and parsestr(): the 'struct compiling *'

argument should be called 'c', like everywhere else.  Renamed a
complex variable 'c' to 'z' and moved it inside the only scope where
it's used.
parent b5ca6570
...@@ -1133,13 +1133,12 @@ com_addopname(struct compiling *c, int op, node *n) ...@@ -1133,13 +1133,12 @@ com_addopname(struct compiling *c, int op, node *n)
} }
static PyObject * static PyObject *
parsenumber(struct compiling *co, char *s) parsenumber(struct compiling *c, char *s)
{ {
char *end; char *end;
long x; long x;
double dx; double dx;
#ifndef WITHOUT_COMPLEX #ifndef WITHOUT_COMPLEX
Py_complex c;
int imflag; int imflag;
#endif #endif
...@@ -1158,8 +1157,8 @@ parsenumber(struct compiling *co, char *s) ...@@ -1158,8 +1157,8 @@ parsenumber(struct compiling *co, char *s)
"hex/oct constants > sys.maxint " "hex/oct constants > sys.maxint "
"will return positive values " "will return positive values "
"in Python 2.4 and up", "in Python 2.4 and up",
co->c_filename, c->c_filename,
co->c_lineno, c->c_lineno,
NULL, NULL,
NULL) < 0) NULL) < 0)
return NULL; return NULL;
...@@ -1176,11 +1175,12 @@ parsenumber(struct compiling *co, char *s) ...@@ -1176,11 +1175,12 @@ parsenumber(struct compiling *co, char *s)
/* XXX Huge floats may silently fail */ /* XXX Huge floats may silently fail */
#ifndef WITHOUT_COMPLEX #ifndef WITHOUT_COMPLEX
if (imflag) { if (imflag) {
c.real = 0.; Py_complex z;
z.real = 0.;
PyFPE_START_PROTECT("atof", return 0) PyFPE_START_PROTECT("atof", return 0)
c.imag = atof(s); z.imag = atof(s);
PyFPE_END_PROTECT(c) PyFPE_END_PROTECT(z)
return PyComplex_FromCComplex(c); return PyComplex_FromCComplex(z);
} }
else else
#endif #endif
...@@ -1215,7 +1215,7 @@ decode_utf8(char **sPtr, char *end, char* encoding) ...@@ -1215,7 +1215,7 @@ decode_utf8(char **sPtr, char *end, char* encoding)
} }
static PyObject * static PyObject *
parsestr(struct compiling *com, char *s) parsestr(struct compiling *c, char *s)
{ {
PyObject *v; PyObject *v;
size_t len; size_t len;
...@@ -1224,7 +1224,7 @@ parsestr(struct compiling *com, char *s) ...@@ -1224,7 +1224,7 @@ parsestr(struct compiling *com, char *s)
char *end; char *end;
int quote = *s; int quote = *s;
int rawmode = 0; int rawmode = 0;
char* encoding = ((com == NULL) ? NULL : com->c_encoding); char* encoding = ((c == NULL) ? NULL : c->c_encoding);
int need_encoding; int need_encoding;
int unicode = 0; int unicode = 0;
...@@ -1245,7 +1245,7 @@ parsestr(struct compiling *com, char *s) ...@@ -1245,7 +1245,7 @@ parsestr(struct compiling *com, char *s)
s++; s++;
len = strlen(s); len = strlen(s);
if (len > INT_MAX) { if (len > INT_MAX) {
com_error(com, PyExc_OverflowError, com_error(c, PyExc_OverflowError,
"string to parse is too long"); "string to parse is too long");
return NULL; return NULL;
} }
...@@ -1315,7 +1315,7 @@ parsestr(struct compiling *com, char *s) ...@@ -1315,7 +1315,7 @@ parsestr(struct compiling *com, char *s)
v = PyUnicode_DecodeUnicodeEscape(buf, len, NULL); v = PyUnicode_DecodeUnicodeEscape(buf, len, NULL);
Py_XDECREF(u); Py_XDECREF(u);
if (v == NULL) if (v == NULL)
PyErr_SyntaxLocation(com->c_filename, com->c_lineno); PyErr_SyntaxLocation(c->c_filename, c->c_lineno);
return v; return v;
} }
...@@ -1345,7 +1345,7 @@ parsestr(struct compiling *com, char *s) ...@@ -1345,7 +1345,7 @@ parsestr(struct compiling *com, char *s)
v = PyString_DecodeEscape(s, len, NULL, unicode, v = PyString_DecodeEscape(s, len, NULL, unicode,
need_encoding ? encoding : NULL); need_encoding ? encoding : NULL);
if (v == NULL) if (v == NULL)
PyErr_SyntaxLocation(com->c_filename, com->c_lineno); PyErr_SyntaxLocation(c->c_filename, c->c_lineno);
return v; return v;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment