[PATCH 5 of 6] parsers.c: parse_manifest: use return NULL instead of gotos
Nicolas Dumazet
nicdumz at gmail.com
Thu Aug 27 08:09:14 CDT 2009
# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1251376177 -7200
# Node ID db94fcccdc32e00906851addc469e6f7275ce274
# Parent 391c057f3497bab711c70afedfabafd45f2f3698
parsers.c: parse_manifest: use return NULL instead of gotos
* "return NULL" _is_ cleaner "goto quit"
* For file, "goto bail" was not necessary since no Python objects
are initialized at that point. Returning NULL has the same effect.
diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -61,7 +61,7 @@
&PyDict_Type, &mfdict,
&PyDict_Type, &fdict,
&str, &len))
- goto quit;
+ return NULL;
for (start = cur = str, zero = NULL; cur < str + len; cur++) {
PyObject *file = NULL, *node = NULL;
@@ -77,12 +77,12 @@
if (!zero) {
PyErr_SetString(PyExc_ValueError,
"manifest entry has no separator");
- goto quit;
+ return NULL;
}
file = PyString_FromStringAndSize(start, zero - start);
if (!file)
- goto bail;
+ return NULL;
nlen = cur - zero - 1;
@@ -116,19 +116,17 @@
bail:
Py_XDECREF(node);
Py_XDECREF(file);
- goto quit;
+ return NULL;
}
if (len > 0 && *(cur - 1) != '\n') {
PyErr_SetString(PyExc_ValueError,
"manifest contains trailing garbage");
- goto quit;
+ return NULL;
}
Py_INCREF(Py_None);
return Py_None;
-quit:
- return NULL;
}
#ifdef _WIN32
More information about the Mercurial-devel
mailing list