summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Parser/parsetok.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index 386b82f..bdd51f3 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -14,6 +14,7 @@ int Py_TabcheckFlag;
/* Forward */
static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int);
+static void initerr(perrdetail *err_ret);
/* Parse input coming from a string. Return error code, print some errors. */
node *
@@ -28,13 +29,7 @@ PyParser_ParseStringFlags(char *s, grammar *g, int start,
{
struct tok_state *tok;
- err_ret->error = E_OK;
- err_ret->filename = NULL;
- err_ret->lineno = 0;
- err_ret->offset = 0;
- err_ret->text = NULL;
- err_ret->token = -1;
- err_ret->expected = -1;
+ initerr(err_ret);
if ((tok = PyTokenizer_FromString(s)) == NULL) {
err_ret->error = E_NOMEM;
@@ -68,11 +63,7 @@ PyParser_ParseFileFlags(FILE *fp, char *filename, grammar *g, int start,
{
struct tok_state *tok;
- err_ret->error = E_OK;
- err_ret->filename = filename;
- err_ret->lineno = 0;
- err_ret->offset = 0;
- err_ret->text = NULL;
+ initerr(err_ret);
if ((tok = PyTokenizer_FromFile(fp, ps1, ps2)) == NULL) {
err_ret->error = E_NOMEM;
@@ -185,3 +176,15 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
return n;
}
+
+static void
+initerr(perrdetail *err_ret)
+{
+ err_ret->error = E_OK;
+ err_ret->filename = NULL;
+ err_ret->lineno = 0;
+ err_ret->offset = 0;
+ err_ret->text = NULL;
+ err_ret->token = -1;
+ err_ret->expected = -1;
+}