diff options
-rw-r--r-- | src/if_py_both.h | 67 | ||||
-rw-r--r-- | src/if_python.c | 3 | ||||
-rw-r--r-- | src/if_python3.c | 29 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 48 insertions, 53 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h index 7d3a26ebf..97721b20f 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -2006,24 +2006,17 @@ TabPageAttr(TabPageObject *self, char *name) static PyObject * TabPageRepr(TabPageObject *self) { - static char repr[100]; - if (self->tab == INVALID_TABPAGE_VALUE) - { - vim_snprintf(repr, 100, _("<tabpage object (deleted) at %p>"), (self)); - return PyString_FromString(repr); - } + return PyString_FromFormat("<tabpage object (deleted) at %p>", (self)); else { int t = get_tab_number(self->tab); if (t == 0) - vim_snprintf(repr, 100, _("<tabpage object (unknown) at %p>"), - (self)); + return PyString_FromFormat("<tabpage object (unknown) at %p>", + (self)); else - vim_snprintf(repr, 100, _("<tabpage %d>"), t - 1); - - return PyString_FromString(repr); + return PyString_FromFormat("<tabpage %d>", t - 1); } } @@ -2344,24 +2337,17 @@ WindowSetattr(WindowObject *self, char *name, PyObject *val) static PyObject * WindowRepr(WindowObject *self) { - static char repr[100]; - if (self->win == INVALID_WINDOW_VALUE) - { - vim_snprintf(repr, 100, _("<window object (deleted) at %p>"), (self)); - return PyString_FromString(repr); - } + return PyString_FromFormat("<window object (deleted) at %p>", (self)); else { int w = get_win_number(self->win, firstwin); if (w == 0) - vim_snprintf(repr, 100, _("<window object (unknown) at %p>"), + return PyString_FromFormat("<window object (unknown) at %p>", (self)); else - vim_snprintf(repr, 100, _("<window %d>"), w - 1); - - return PyString_FromString(repr); + return PyString_FromFormat("<window %d>", w - 1); } } @@ -3281,31 +3267,18 @@ RangeAppend(RangeObject *self, PyObject *args) static PyObject * RangeRepr(RangeObject *self) { - static char repr[100]; - if (self->buf->buf == INVALID_BUFFER_VALUE) - { - vim_snprintf(repr, 100, "<range object (for deleted buffer) at %p>", - (self)); - return PyString_FromString(repr); - } + return PyString_FromFormat("<range object (for deleted buffer) at %p>", + (self)); else { char *name = (char *)self->buf->buf->b_fname; - int len; if (name == NULL) name = ""; - len = (int)strlen(name); - - if (len > 45) - name = name + (45 - len); - vim_snprintf(repr, 100, "<range %s%s (%d:%d)>", - len > 45 ? "..." : "", name, - self->start, self->end); - - return PyString_FromString(repr); + return PyString_FromFormat("<range %s (%d:%d)>", + name, self->start, self->end); } } @@ -3534,28 +3507,16 @@ BufferRange(BufferObject *self, PyObject *args) static PyObject * BufferRepr(BufferObject *self) { - static char repr[100]; - if (self->buf == INVALID_BUFFER_VALUE) - { - vim_snprintf(repr, 100, _("<buffer object (deleted) at %p>"), (self)); - return PyString_FromString(repr); - } + return PyString_FromFormat("<buffer object (deleted) at %p>", self); else { - char *name = (char *)self->buf->b_fname; - PyInt len; + char *name = (char *)self->buf->b_fname; if (name == NULL) name = ""; - len = strlen(name); - - if (len > 35) - name = name + (35 - len); - - vim_snprintf(repr, 100, "<buffer %s%s>", len > 35 ? "..." : "", name); - return PyString_FromString(repr); + return PyString_FromFormat("<buffer %s>", name); } } diff --git a/src/if_python.c b/src/if_python.c index 889ff05d3..16874e855 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -212,6 +212,7 @@ struct PyMethodDef { Py_ssize_t a; }; # define PyString_AsString dll_PyString_AsString # define PyString_AsStringAndSize dll_PyString_AsStringAndSize # define PyString_FromString dll_PyString_FromString +# define PyString_FromFormat dll_PyString_FromFormat # define PyString_FromStringAndSize dll_PyString_FromStringAndSize # define PyString_Size dll_PyString_Size # define PyString_Type (*dll_PyString_Type) @@ -340,6 +341,7 @@ static PyObject* (*dll_PyObject_CallFunctionObjArgs)(PyObject *, ...); static char*(*dll_PyString_AsString)(PyObject *); static int(*dll_PyString_AsStringAndSize)(PyObject *, char **, int *); static PyObject*(*dll_PyString_FromString)(const char *); +static PyObject*(*dll_PyString_FromFormat)(const char *, ...); static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt); static PyInt(*dll_PyString_Size)(PyObject *); static PyTypeObject* dll_PyString_Type; @@ -499,6 +501,7 @@ static struct {"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString}, {"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize}, {"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString}, + {"PyString_FromFormat", (PYTHON_PROC*)&dll_PyString_FromFormat}, {"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize}, {"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size}, {"PyString_Type", (PYTHON_PROC*)&dll_PyString_Type}, diff --git a/src/if_python3.c b/src/if_python3.c index 02132d63d..5d87fa384 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -90,6 +90,7 @@ #define PyString_AsString(obj) PyBytes_AsString(obj) #define PyString_Size(obj) PyBytes_GET_SIZE(bytes) #define PyString_FromString(repr) PyUnicode_FromString(repr) +#define PyString_FromFormat PyUnicode_FromFormat #define PyString_AsStringAndSize(obj, buffer, len) PyBytes_AsStringAndSize(obj, buffer, len) #define PyInt_Check(obj) PyLong_Check(obj) #define PyInt_FromLong(i) PyLong_FromLong(i) @@ -230,6 +231,16 @@ # define PyType_GenericNew py3_PyType_GenericNew # undef PyUnicode_FromString # define PyUnicode_FromString py3_PyUnicode_FromString +# ifndef PyUnicode_FromFormat +# define PyUnicode_FromFormat py3_PyUnicode_FromFormat +# else +# define Py_UNICODE_USE_UCS_FUNCTIONS +# ifdef Py_UNICODE_WIDE +# define PyUnicodeUCS4_FromFormat py3_PyUnicodeUCS4_FromFormat +# else +# define PyUnicodeUCS2_FromFormat py3_PyUnicodeUCS2_FromFormat +# endif +# endif # undef PyUnicode_Decode # define PyUnicode_Decode py3_PyUnicode_Decode # define PyType_IsSubtype py3_PyType_IsSubtype @@ -293,6 +304,15 @@ static PyObject* (*py3_Py_BuildValue)(char *, ...); static int (*py3_PyType_Ready)(PyTypeObject *type); static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item); static PyObject* (*py3_PyUnicode_FromString)(const char *u); +# ifndef Py_UNICODE_USE_UCS_FUNCTIONS +static PyObject* (*py3_PyUnicode_FromFormat)(const char *u, ...); +# else +# ifdef Py_UNICODE_WIDE +static PyObject* (*py3_PyUnicodeUCS4_FromFormat)(const char *u, ...); +# else +static PyObject* (*py3_PyUnicodeUCS2_FromFormat)(const char *u, ...); +# endif +# endif static PyObject* (*py3_PyUnicode_Decode)(const char *u, Py_ssize_t size, const char *encoding, const char *errors); static long (*py3_PyLong_AsLong)(PyObject *); @@ -458,6 +478,15 @@ static struct # else {"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString}, # endif +# ifndef Py_UNICODE_USE_UCS_FUNCTIONS + {"PyUnicode_FromFormat", (PYTHON_PROC*)&py3_PyUnicode_FromFormat}, +# else +# ifdef Py_UNICODE_WIDE + {"PyUnicodeUCS4_FromFormat", (PYTHON_PROC*)&py3_PyUnicodeUCS4_FromFormat}, +# else + {"PyUnicodeUCS2_FromFormat", (PYTHON_PROC*)&py3_PyUnicodeUCS2_FromFormat}, +# endif +# endif {"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString}, {"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize}, {"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString}, diff --git a/src/version.c b/src/version.c index 33af9b35d..b8f82f1d7 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1059, +/**/ 1058, /**/ 1057, |