[PATCH 1 of 3] inotify: _inotify.c: readability: do not mix tabs and spaces

Nicolas Dumazet nicdumz at gmail.com
Thu Aug 27 05:01:07 CDT 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1251365120 -7200
# Node ID 4ebca3c60760c06da691a96b3a81014be99d3316
# Parent  7345fa5e572e029362bc6f2f96af452607ebb1ff
inotify: _inotify.c: readability: do not mix tabs and spaces

diff --git a/hgext/inotify/linux/_inotify.c b/hgext/inotify/linux/_inotify.c
--- a/hgext/inotify/linux/_inotify.c
+++ b/hgext/inotify/linux/_inotify.c
@@ -21,26 +21,26 @@
     int fd = -1;
 
      if (!PyArg_ParseTuple(args, ":init"))
-	goto bail;
+        goto bail;
 
     Py_BEGIN_ALLOW_THREADS
     fd = inotify_init();
     Py_END_ALLOW_THREADS
 
     if (fd == -1) {
-	PyErr_SetFromErrno(PyExc_OSError);
-	goto bail;
+        PyErr_SetFromErrno(PyExc_OSError);
+        goto bail;
     }
 
     ret = PyInt_FromLong(fd);
     if (ret == NULL)
-	goto bail;
+        goto bail;
 
     goto done;
 
 bail:
     if (fd != -1)
-	close(fd);
+        close(fd);
 
     Py_CLEAR(ret);
 
@@ -64,26 +64,26 @@
     int fd;
 
     if (!PyArg_ParseTuple(args, "isI:add_watch", &fd, &path, &mask))
-	goto bail;
+        goto bail;
 
     Py_BEGIN_ALLOW_THREADS
     wd = inotify_add_watch(fd, path, mask);
     Py_END_ALLOW_THREADS
 
     if (wd == -1) {
-	PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
-	goto bail;
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
+        goto bail;
     }
 
     ret = PyInt_FromLong(wd);
     if (ret == NULL)
-	goto bail;
+        goto bail;
 
     goto done;
 
 bail:
     if (wd != -1)
-	inotify_rm_watch(fd, wd);
+        inotify_rm_watch(fd, wd);
 
     Py_CLEAR(ret);
 
@@ -112,15 +112,15 @@
     int r;
 
     if (!PyArg_ParseTuple(args, "iI:remove_watch", &fd, &wd))
-	goto bail;
+        goto bail;
 
     Py_BEGIN_ALLOW_THREADS
     r = inotify_rm_watch(fd, wd);
     Py_END_ALLOW_THREADS
 
     if (r == -1) {
-	PyErr_SetFromErrno(PyExc_OSError);
-	goto bail;
+        PyErr_SetFromErrno(PyExc_OSError);
+        goto bail;
     }
 
     Py_INCREF(Py_None);
@@ -183,19 +183,19 @@
     int i;
 
     if (ret == NULL)
-	goto bail;
+        goto bail;
 
     for (i = 0; bit_names[i].bit; i++) {
-	if (mask & bit_names[i].bit) {
-	    if (bit_names[i].pyname == NULL) {
-		bit_names[i].pyname = PyString_FromString(bit_names[i].name);
-		if (bit_names[i].pyname == NULL)
-		    goto bail;
-	    }
-	    Py_INCREF(bit_names[i].pyname);
-	    if (PyList_Append(ret, bit_names[i].pyname) == -1)
-		goto bail;
-	}
+        if (mask & bit_names[i].bit) {
+            if (bit_names[i].pyname == NULL) {
+                bit_names[i].pyname = PyString_FromString(bit_names[i].name);
+                if (bit_names[i].pyname == NULL)
+                    goto bail;
+            }
+            Py_INCREF(bit_names[i].pyname);
+            if (PyList_Append(ret, bit_names[i].pyname) == -1)
+                goto bail;
+        }
     }
 
     goto done;
@@ -212,7 +212,7 @@
     int mask;
 
     if (!PyArg_ParseTuple(args, "i:decode_mask", &mask))
-	return NULL;
+        return NULL;
 
     return decode_mask(mask);
 }
@@ -232,7 +232,7 @@
     PyObject *pyname = PyString_FromString(name);
 
     if (!pyname || !pyval)
-	goto bail;
+        goto bail;
 
     PyDict_SetItem(dict, pyname, pyval);
 
@@ -348,39 +348,39 @@
 
     join = PyString_FromString("|");
     if (join == NULL)
-	goto bail;
+        goto bail;
 
     pymasks = decode_mask(PyInt_AsLong(evt->mask));
     if (pymasks == NULL)
-	goto bail;
+        goto bail;
 
     pymask = _PyString_Join(join, pymasks);
     if (pymask == NULL)
-	goto bail;
+        goto bail;
 
     maskstr = PyString_AsString(pymask);
 
     if (evt->name != Py_None) {
-	PyObject *pyname = PyString_Repr(evt->name, 1);
-	char *name = pyname ? PyString_AsString(pyname) : "???";
+        PyObject *pyname = PyString_Repr(evt->name, 1);
+        char *name = pyname ? PyString_AsString(pyname) : "???";
 
-	if (cookie == -1)
-	    ret = PyString_FromFormat("event(wd=%d, mask=%s, name=%s)",
-				      wd, maskstr, name);
-	else
-	    ret = PyString_FromFormat("event(wd=%d, mask=%s, "
-				      "cookie=0x%x, name=%s)",
-				      wd, maskstr, cookie, name);
+        if (cookie == -1)
+            ret = PyString_FromFormat("event(wd=%d, mask=%s, name=%s)",
+                                      wd, maskstr, name);
+        else
+            ret = PyString_FromFormat("event(wd=%d, mask=%s, "
+                                      "cookie=0x%x, name=%s)",
+                                      wd, maskstr, cookie, name);
 
-	Py_XDECREF(pyname);
+        Py_XDECREF(pyname);
     } else {
-	if (cookie == -1)
-	    ret = PyString_FromFormat("event(wd=%d, mask=%s)",
-				      wd, maskstr);
-	else {
-	    ret = PyString_FromFormat("event(wd=%d, mask=%s, cookie=0x%x)",
-				      wd, maskstr, cookie);
-	}
+        if (cookie == -1)
+            ret = PyString_FromFormat("event(wd=%d, mask=%s)",
+                                      wd, maskstr);
+        else {
+            ret = PyString_FromFormat("event(wd=%d, mask=%s, cookie=0x%x)",
+                                      wd, maskstr, cookie);
+        }
     }
 
     goto done;
@@ -448,48 +448,48 @@
     int fd;
 
     if (!PyArg_ParseTuple(args, "i|O:read", &fd, &pybufsize))
-	goto bail;
+        goto bail;
 
     if (pybufsize && pybufsize != Py_None)
-	bufsize = PyInt_AsLong(pybufsize);
+        bufsize = PyInt_AsLong(pybufsize);
 
     ret = PyList_New(0);
     if (ret == NULL)
-	goto bail;
+        goto bail;
 
     if (bufsize <= 0) {
-	int r;
+        int r;
 
-	Py_BEGIN_ALLOW_THREADS
-	r = ioctl(fd, FIONREAD, &bufsize);
-	Py_END_ALLOW_THREADS
+        Py_BEGIN_ALLOW_THREADS
+        r = ioctl(fd, FIONREAD, &bufsize);
+        Py_END_ALLOW_THREADS
 
-	if (r == -1) {
-	    PyErr_SetFromErrno(PyExc_OSError);
-	    goto bail;
-	}
-	if (bufsize == 0)
-	    goto done;
+        if (r == -1) {
+            PyErr_SetFromErrno(PyExc_OSError);
+            goto bail;
+        }
+        if (bufsize == 0)
+            goto done;
     }
     else {
-	static long name_max;
-	static long name_fd = -1;
-	long min;
+        static long name_max;
+        static long name_fd = -1;
+        long min;
 
-	if (name_fd != fd) {
-	    name_fd = fd;
-	    Py_BEGIN_ALLOW_THREADS
-	    name_max = fpathconf(fd, _PC_NAME_MAX);
-	    Py_END_ALLOW_THREADS
-	}
+        if (name_fd != fd) {
+            name_fd = fd;
+            Py_BEGIN_ALLOW_THREADS
+            name_max = fpathconf(fd, _PC_NAME_MAX);
+            Py_END_ALLOW_THREADS
+        }
 
-	min = sizeof(struct inotify_event) + name_max + 1;
+        min = sizeof(struct inotify_event) + name_max + 1;
 
-	if (bufsize < min) {
-	    PyErr_Format(PyExc_ValueError, "bufsize must be at least %d",
-			 (int) min);
-	    goto bail;
-	}
+        if (bufsize < min) {
+            PyErr_Format(PyExc_ValueError, "bufsize must be at least %d",
+                         (int) min);
+            goto bail;
+        }
     }
 
     buf = alloca(bufsize);
@@ -499,61 +499,61 @@
     Py_END_ALLOW_THREADS
 
     if (nread == -1) {
-	PyErr_SetFromErrno(PyExc_OSError);
-	goto bail;
+        PyErr_SetFromErrno(PyExc_OSError);
+        goto bail;
     }
 
     ctor_args = PyTuple_New(0);
 
     if (ctor_args == NULL)
-	goto bail;
+        goto bail;
 
     pos = 0;
 
     while (pos < nread) {
-	struct inotify_event *in = (struct inotify_event *) (buf + pos);
-	struct event *evt;
-	PyObject *obj;
+        struct inotify_event *in = (struct inotify_event *) (buf + pos);
+        struct event *evt;
+        PyObject *obj;
 
-	obj = PyObject_CallObject((PyObject *) &event_type, ctor_args);
+        obj = PyObject_CallObject((PyObject *) &event_type, ctor_args);
 
-	if (obj == NULL)
-	    goto bail;
+        if (obj == NULL)
+            goto bail;
 
-	evt = (struct event *) obj;
+        evt = (struct event *) obj;
 
-	evt->wd = PyInt_FromLong(in->wd);
-	evt->mask = PyInt_FromLong(in->mask);
-	if (in->mask & IN_MOVE)
-	    evt->cookie = PyInt_FromLong(in->cookie);
-	else {
-	    Py_INCREF(Py_None);
-	    evt->cookie = Py_None;
-	}
-	if (in->len)
-	    evt->name = PyString_FromString(in->name);
-	else {
-	    Py_INCREF(Py_None);
-	    evt->name = Py_None;
-	}
+        evt->wd = PyInt_FromLong(in->wd);
+        evt->mask = PyInt_FromLong(in->mask);
+        if (in->mask & IN_MOVE)
+            evt->cookie = PyInt_FromLong(in->cookie);
+        else {
+            Py_INCREF(Py_None);
+            evt->cookie = Py_None;
+        }
+        if (in->len)
+            evt->name = PyString_FromString(in->name);
+        else {
+            Py_INCREF(Py_None);
+            evt->name = Py_None;
+        }
 
-	if (!evt->wd || !evt->mask || !evt->cookie || !evt->name)
-	    goto mybail;
+        if (!evt->wd || !evt->mask || !evt->cookie || !evt->name)
+            goto mybail;
 
-	if (PyList_Append(ret, obj) == -1)
-	    goto mybail;
+        if (PyList_Append(ret, obj) == -1)
+            goto mybail;
 
-	pos += sizeof(struct inotify_event) + in->len;
-	continue;
+        pos += sizeof(struct inotify_event) + in->len;
+        continue;
 
     mybail:
-	Py_CLEAR(evt->wd);
-	Py_CLEAR(evt->mask);
-	Py_CLEAR(evt->cookie);
-	Py_CLEAR(evt->name);
-	Py_DECREF(obj);
+        Py_CLEAR(evt->wd);
+        Py_CLEAR(evt->mask);
+        Py_CLEAR(evt->cookie);
+        Py_CLEAR(evt->name);
+        Py_DECREF(obj);
 
-	goto bail;
+        goto bail;
     }
 
     goto done;
@@ -597,12 +597,12 @@
     PyObject *mod, *dict;
 
     if (PyType_Ready(&event_type) == -1)
-	return;
+        return;
 
     mod = Py_InitModule3("_inotify", methods, doc);
 
     dict = PyModule_GetDict(mod);
 
     if (dict)
-	define_consts(dict);
+        define_consts(dict);
 }


More information about the Mercurial-devel mailing list