mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
updated for version 7.3.1059
Problem: Python: Using fixed size buffers. Solution: Python patch 18: Use python's own formatter. (ZyX)
This commit is contained in:
@@ -2006,24 +2006,17 @@ TabPageAttr(TabPageObject *self, char *name)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
TabPageRepr(TabPageObject *self)
|
TabPageRepr(TabPageObject *self)
|
||||||
{
|
{
|
||||||
static char repr[100];
|
|
||||||
|
|
||||||
if (self->tab == INVALID_TABPAGE_VALUE)
|
if (self->tab == INVALID_TABPAGE_VALUE)
|
||||||
{
|
return PyString_FromFormat("<tabpage object (deleted) at %p>", (self));
|
||||||
vim_snprintf(repr, 100, _("<tabpage object (deleted) at %p>"), (self));
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int t = get_tab_number(self->tab);
|
int t = get_tab_number(self->tab);
|
||||||
|
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
vim_snprintf(repr, 100, _("<tabpage object (unknown) at %p>"),
|
return PyString_FromFormat("<tabpage object (unknown) at %p>",
|
||||||
(self));
|
(self));
|
||||||
else
|
else
|
||||||
vim_snprintf(repr, 100, _("<tabpage %d>"), t - 1);
|
return PyString_FromFormat("<tabpage %d>", t - 1);
|
||||||
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2344,24 +2337,17 @@ WindowSetattr(WindowObject *self, char *name, PyObject *val)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
WindowRepr(WindowObject *self)
|
WindowRepr(WindowObject *self)
|
||||||
{
|
{
|
||||||
static char repr[100];
|
|
||||||
|
|
||||||
if (self->win == INVALID_WINDOW_VALUE)
|
if (self->win == INVALID_WINDOW_VALUE)
|
||||||
{
|
return PyString_FromFormat("<window object (deleted) at %p>", (self));
|
||||||
vim_snprintf(repr, 100, _("<window object (deleted) at %p>"), (self));
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int w = get_win_number(self->win, firstwin);
|
int w = get_win_number(self->win, firstwin);
|
||||||
|
|
||||||
if (w == 0)
|
if (w == 0)
|
||||||
vim_snprintf(repr, 100, _("<window object (unknown) at %p>"),
|
return PyString_FromFormat("<window object (unknown) at %p>",
|
||||||
(self));
|
(self));
|
||||||
else
|
else
|
||||||
vim_snprintf(repr, 100, _("<window %d>"), w - 1);
|
return PyString_FromFormat("<window %d>", w - 1);
|
||||||
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3281,31 +3267,18 @@ RangeAppend(RangeObject *self, PyObject *args)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
RangeRepr(RangeObject *self)
|
RangeRepr(RangeObject *self)
|
||||||
{
|
{
|
||||||
static char repr[100];
|
|
||||||
|
|
||||||
if (self->buf->buf == INVALID_BUFFER_VALUE)
|
if (self->buf->buf == INVALID_BUFFER_VALUE)
|
||||||
{
|
return PyString_FromFormat("<range object (for deleted buffer) at %p>",
|
||||||
vim_snprintf(repr, 100, "<range object (for deleted buffer) at %p>",
|
(self));
|
||||||
(self));
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *name = (char *)self->buf->buf->b_fname;
|
char *name = (char *)self->buf->buf->b_fname;
|
||||||
int len;
|
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "";
|
name = "";
|
||||||
len = (int)strlen(name);
|
|
||||||
|
|
||||||
if (len > 45)
|
return PyString_FromFormat("<range %s (%d:%d)>",
|
||||||
name = name + (45 - len);
|
name, self->start, self->end);
|
||||||
|
|
||||||
vim_snprintf(repr, 100, "<range %s%s (%d:%d)>",
|
|
||||||
len > 45 ? "..." : "", name,
|
|
||||||
self->start, self->end);
|
|
||||||
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3534,28 +3507,16 @@ BufferRange(BufferObject *self, PyObject *args)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
BufferRepr(BufferObject *self)
|
BufferRepr(BufferObject *self)
|
||||||
{
|
{
|
||||||
static char repr[100];
|
|
||||||
|
|
||||||
if (self->buf == INVALID_BUFFER_VALUE)
|
if (self->buf == INVALID_BUFFER_VALUE)
|
||||||
{
|
return PyString_FromFormat("<buffer object (deleted) at %p>", self);
|
||||||
vim_snprintf(repr, 100, _("<buffer object (deleted) at %p>"), (self));
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *name = (char *)self->buf->b_fname;
|
char *name = (char *)self->buf->b_fname;
|
||||||
PyInt len;
|
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "";
|
name = "";
|
||||||
len = strlen(name);
|
|
||||||
|
|
||||||
if (len > 35)
|
return PyString_FromFormat("<buffer %s>", name);
|
||||||
name = name + (35 - len);
|
|
||||||
|
|
||||||
vim_snprintf(repr, 100, "<buffer %s%s>", len > 35 ? "..." : "", name);
|
|
||||||
|
|
||||||
return PyString_FromString(repr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -212,6 +212,7 @@ struct PyMethodDef { Py_ssize_t a; };
|
|||||||
# define PyString_AsString dll_PyString_AsString
|
# define PyString_AsString dll_PyString_AsString
|
||||||
# define PyString_AsStringAndSize dll_PyString_AsStringAndSize
|
# define PyString_AsStringAndSize dll_PyString_AsStringAndSize
|
||||||
# define PyString_FromString dll_PyString_FromString
|
# define PyString_FromString dll_PyString_FromString
|
||||||
|
# define PyString_FromFormat dll_PyString_FromFormat
|
||||||
# define PyString_FromStringAndSize dll_PyString_FromStringAndSize
|
# define PyString_FromStringAndSize dll_PyString_FromStringAndSize
|
||||||
# define PyString_Size dll_PyString_Size
|
# define PyString_Size dll_PyString_Size
|
||||||
# define PyString_Type (*dll_PyString_Type)
|
# define PyString_Type (*dll_PyString_Type)
|
||||||
@@ -340,6 +341,7 @@ static PyObject* (*dll_PyObject_CallFunctionObjArgs)(PyObject *, ...);
|
|||||||
static char*(*dll_PyString_AsString)(PyObject *);
|
static char*(*dll_PyString_AsString)(PyObject *);
|
||||||
static int(*dll_PyString_AsStringAndSize)(PyObject *, char **, int *);
|
static int(*dll_PyString_AsStringAndSize)(PyObject *, char **, int *);
|
||||||
static PyObject*(*dll_PyString_FromString)(const char *);
|
static PyObject*(*dll_PyString_FromString)(const char *);
|
||||||
|
static PyObject*(*dll_PyString_FromFormat)(const char *, ...);
|
||||||
static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
|
static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
|
||||||
static PyInt(*dll_PyString_Size)(PyObject *);
|
static PyInt(*dll_PyString_Size)(PyObject *);
|
||||||
static PyTypeObject* dll_PyString_Type;
|
static PyTypeObject* dll_PyString_Type;
|
||||||
@@ -499,6 +501,7 @@ static struct
|
|||||||
{"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
|
{"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
|
||||||
{"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize},
|
{"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize},
|
||||||
{"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
|
{"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
|
||||||
|
{"PyString_FromFormat", (PYTHON_PROC*)&dll_PyString_FromFormat},
|
||||||
{"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize},
|
{"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize},
|
||||||
{"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
|
{"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
|
||||||
{"PyString_Type", (PYTHON_PROC*)&dll_PyString_Type},
|
{"PyString_Type", (PYTHON_PROC*)&dll_PyString_Type},
|
||||||
|
@@ -90,6 +90,7 @@
|
|||||||
#define PyString_AsString(obj) PyBytes_AsString(obj)
|
#define PyString_AsString(obj) PyBytes_AsString(obj)
|
||||||
#define PyString_Size(obj) PyBytes_GET_SIZE(bytes)
|
#define PyString_Size(obj) PyBytes_GET_SIZE(bytes)
|
||||||
#define PyString_FromString(repr) PyUnicode_FromString(repr)
|
#define PyString_FromString(repr) PyUnicode_FromString(repr)
|
||||||
|
#define PyString_FromFormat PyUnicode_FromFormat
|
||||||
#define PyString_AsStringAndSize(obj, buffer, len) PyBytes_AsStringAndSize(obj, buffer, len)
|
#define PyString_AsStringAndSize(obj, buffer, len) PyBytes_AsStringAndSize(obj, buffer, len)
|
||||||
#define PyInt_Check(obj) PyLong_Check(obj)
|
#define PyInt_Check(obj) PyLong_Check(obj)
|
||||||
#define PyInt_FromLong(i) PyLong_FromLong(i)
|
#define PyInt_FromLong(i) PyLong_FromLong(i)
|
||||||
@@ -230,6 +231,16 @@
|
|||||||
# define PyType_GenericNew py3_PyType_GenericNew
|
# define PyType_GenericNew py3_PyType_GenericNew
|
||||||
# undef PyUnicode_FromString
|
# undef PyUnicode_FromString
|
||||||
# define PyUnicode_FromString py3_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
|
# undef PyUnicode_Decode
|
||||||
# define PyUnicode_Decode py3_PyUnicode_Decode
|
# define PyUnicode_Decode py3_PyUnicode_Decode
|
||||||
# define PyType_IsSubtype py3_PyType_IsSubtype
|
# 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_PyType_Ready)(PyTypeObject *type);
|
||||||
static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
|
static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
|
||||||
static PyObject* (*py3_PyUnicode_FromString)(const char *u);
|
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,
|
static PyObject* (*py3_PyUnicode_Decode)(const char *u, Py_ssize_t size,
|
||||||
const char *encoding, const char *errors);
|
const char *encoding, const char *errors);
|
||||||
static long (*py3_PyLong_AsLong)(PyObject *);
|
static long (*py3_PyLong_AsLong)(PyObject *);
|
||||||
@@ -457,6 +477,15 @@ static struct
|
|||||||
{"PyUnicode_AsUTF8", (PYTHON_PROC*)&py3_PyUnicode_AsUTF8},
|
{"PyUnicode_AsUTF8", (PYTHON_PROC*)&py3_PyUnicode_AsUTF8},
|
||||||
# else
|
# else
|
||||||
{"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString},
|
{"_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
|
# endif
|
||||||
{"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
|
{"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
|
||||||
{"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize},
|
{"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize},
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1059,
|
||||||
/**/
|
/**/
|
||||||
1058,
|
1058,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user