diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 11 | ||||
-rw-r--r-- | Modules/mathmodule.c | 6 | ||||
-rw-r--r-- | Modules/mmapmodule.c | 44 |
3 files changed, 34 insertions, 27 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index a4536e4..06202e0 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1711,11 +1711,20 @@ NoArgTrueFalseFunction(has_colors) NoArgTrueFalseFunction(has_ic) NoArgTrueFalseFunction(has_il) NoArgTrueFalseFunction(isendwin) -NoArgNoReturnVoidFunction(filter) NoArgNoReturnVoidFunction(flushinp) NoArgNoReturnVoidFunction(noqiflush) static PyObject * +PyCurses_filter(PyObject *self) +{ + /* not checking for PyCursesInitialised here since filter() must + be called before initscr() */ + filter(); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * PyCurses_Color_Content(PyObject *self, PyObject *args) { short color,r,g,b; diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 4730680..873059f 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -291,9 +291,9 @@ loghelper(PyObject* arg, double (*func)(double), char *funcname) "math domain error"); return NULL; } - /* Value is ~= x * 2**(e*SHIFT), so the log ~= - log(x) + log(2) * e * SHIFT. - CAUTION: e*SHIFT may overflow using int arithmetic, + /* Value is ~= x * 2**(e*PyLong_SHIFT), so the log ~= + log(x) + log(2) * e * PyLong_SHIFT. + CAUTION: e*PyLong_SHIFT may overflow using int arithmetic, so force use of double. */ x = func(x) + (e * (double)PyLong_SHIFT) * func(2.0); return PyFloat_FromDouble(x); diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index f50347c..c83af0d 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -259,8 +259,8 @@ mmap_gfind(mmap_object *self, int reverse) { Py_ssize_t start = self->pos; - Py_ssize_t end = self->size; - char *needle; + Py_ssize_t end = self->size; + const char *needle; Py_ssize_t len; CHECK_VALID(NULL); @@ -268,8 +268,8 @@ mmap_gfind(mmap_object *self, &needle, &len, &start, &end)) { return NULL; } else { - char *p; - char sign = reverse ? -1 : 1; + const char *p, *start_p, *end_p; + int sign = reverse ? -1 : 1; if (start < 0) start += self->size; @@ -285,11 +285,11 @@ mmap_gfind(mmap_object *self, else if ((size_t)end > self->size) end = self->size; - start += (Py_ssize_t)self->data; - end += (Py_ssize_t)self->data; + start_p = self->data + start; + end_p = self->data + end; - for (p = (char *)(reverse ? end - len : start); - p >= (char *)start && p + len <= (char *)end; p+=sign) { + for (p = (reverse ? end_p - len : start_p); + (p >= start_p) && (p + len <= end_p); p += sign) { Py_ssize_t i; for (i = 0; i < len && needle[i] == p[i]; ++i) /* nothing */; @@ -543,23 +543,21 @@ mmap_flush_method(mmap_object *self, PyObject *args) if ((size_t)(offset + size) > self->size) { PyErr_SetString(PyExc_ValueError, "flush values out of range"); return NULL; - } else { + } #ifdef MS_WINDOWS - return PyLong_FromLong((long) - FlushViewOfFile(self->data+offset, size)); -#endif /* MS_WINDOWS */ -#ifdef UNIX - /* XXX semantics of return value? */ - /* XXX flags for msync? */ - if (-1 == msync(self->data + offset, size, - MS_SYNC)) - { - PyErr_SetFromErrno(mmap_module_error); - return NULL; - } - return PyLong_FromLong(0); -#endif /* UNIX */ + return PyLong_FromLong((long) FlushViewOfFile(self->data+offset, size)); +#elif defined(UNIX) + /* XXX semantics of return value? */ + /* XXX flags for msync? */ + if (-1 == msync(self->data + offset, size, MS_SYNC)) { + PyErr_SetFromErrno(mmap_module_error); + return NULL; } + return PyLong_FromLong(0); +#else + PyErr_SetString(PyExc_ValueError, "flush not supported on this system"); + return NULL; +#endif } static PyObject * |