From 9d356a0c361caa356f7e249459900cd92c3419eb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 16:35:18 +0200 Subject: [PATCH 01/24] updated for version 7.3.1157 Problem: New regexp engine fails on "\(\state->out1->out->c; + int directly = FALSE; - /* Do it directly when what follows is possibly end of - * match (closing paren). - * Do it directly if there already is a PIM. - * Postpone when it is \@<= or \@= NFA_MCLOSE && cout <= NFA_MCLOSE9) -#ifdef FEAT_SYN_HL - || (cout >= NFA_ZCLOSE && cout <= NFA_ZCLOSE9) +#ifdef ENABLE_LOG + fprintf(log_fd, "Failure chance invisible: %d, what follows: %d\n", + failure_chance(t->state->out, 0), + failure_chance(t->state->out1->out, 0)); #endif - || t->pim.result != NFA_PIM_UNUSED - || (t->state->c != NFA_START_INVISIBLE_BEFORE - && t->state->c != NFA_START_INVISIBLE_BEFORE_NEG - && failure_chance(t->state->out1->out, 0) - < failure_chance(t->state->out, 0))) + /* Do it directly when what follows is possibly the end of + * the match. + * Do it directly if there already is a PIM. + * Postpone when the invisible match is expensive or has a + * lower chance of failing. */ + if (match_follows(t->state->out1->out, 0) + || t->pim.result != NFA_PIM_UNUSED) + directly = TRUE; + else + { + int ch_invisible = failure_chance(t->state->out, 0); + int ch_follows = failure_chance(t->state->out1->out, 0); + + if (t->state->c == NFA_START_INVISIBLE_BEFORE + || t->state->c == NFA_START_INVISIBLE_BEFORE_NEG) + { + /* "before" matches are very expensive when + * unbounded, always prefer what follows then, + * unless what follows will always match. + * Otherwise strongly prefer what follows. */ + if (t->state->val <= 0 && ch_follows > 0) + directly = FALSE; + else + directly = ch_follows * 10 < ch_invisible; + } + else + { + /* normal invisible, first do the one with the + * highest failure chance */ + directly = ch_follows < ch_invisible; + } + } + if (directly) { /* * First try matching the invisible match, then what diff --git a/src/testdir/test64.in b/src/testdir/test64.in index 42703c2e2e..8100436f16 100644 --- a/src/testdir/test64.in +++ b/src/testdir/test64.in @@ -392,6 +392,7 @@ STARTTEST :call add(tl, [2, '\v\C%(', 'foobar']) :call add(tl, [2, '\(foo\)\@<=\>', 'barfoo', '', 'foo']) +:call add(tl, [2, '\(foo\)\@<=.*', 'foobar', 'bar', 'foo']) :" :""""" \@> :call add(tl, [2, '\(a*\)\@>a', 'aaaa']) diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok index 0e25737dd0..8e90cb8f85 100644 --- a/src/testdir/test64.ok +++ b/src/testdir/test64.ok @@ -890,6 +890,9 @@ OK 2 - \(foo\)\@<=\> OK 0 - \(foo\)\@<=\> OK 1 - \(foo\)\@<=\> OK 2 - \(foo\)\@<=\> +OK 0 - \(foo\)\@<=.* +OK 1 - \(foo\)\@<=.* +OK 2 - \(foo\)\@<=.* OK 0 - \(a*\)\@>a OK 1 - \(a*\)\@>a OK 2 - \(a*\)\@>a diff --git a/src/version.c b/src/version.c index 3b2fc8340d..4ec8b3ef86 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1157, /**/ 1156, /**/ From f8b6ff99c9b2e79aabb03d63d38208c0efd1b102 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 16:35:18 +0200 Subject: [PATCH 02/24] Added tag v7-3-1157 for changeset 2f1ee97f5f23 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 4436e90573..e38452f0d4 100644 --- a/.hgtags +++ b/.hgtags @@ -2493,3 +2493,4 @@ bc3f4804cf470cec5773d8842743efb760f69102 v7-3-1153 6419ee8098c80f0418081c73b790b09c61f13c3a v7-3-1154 bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 8c4324e6f4779ee316361511ff783f6344750be9 v7-3-1156 +2f1ee97f5f23a5f9e1c572ed4afb50fb79ce7a35 v7-3-1157 From 202c057bc5065e2f7e6e550b4f5361ae71c79af2 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 18:36:24 +0200 Subject: [PATCH 03/24] updated for version 7.3.1158 Problem: Crash when running test 86. (Jun Takimoto) Solution: Define PY_SSIZE_T_CLEAN early. (Elimar Riesebieter) --- src/if_python.c | 11 +++++++---- src/if_python3.c | 11 +++++------ src/version.c | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/if_python.c b/src/if_python.c index 254f01a75b..318b170ee2 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -53,7 +53,14 @@ # undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */ #endif +#define PY_SSIZE_T_CLEAN + #include + +#if !defined(PY_VERSION_HEX) || PY_VERSION_HEX < 0x02050000 +# undef PY_SSIZE_T_CLEAN +#endif + #if defined(MACOS) && !defined(MACOS_X_UNIX) # include "macglue.h" # include @@ -61,10 +68,6 @@ #undef main /* Defined in python.h - aargh */ #undef HAVE_FCNTL_H /* Clash with os_win32.h */ -#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 -# define PY_SSIZE_T_CLEAN -#endif - #define PyBytes_FromString PyString_FromString #define PyBytes_Check PyString_Check diff --git a/src/if_python3.c b/src/if_python3.c index 915d3f83d9..637ecd1960 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -24,9 +24,9 @@ /* uncomment this if used with the debug version of python */ /* #define Py_DEBUG */ -/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting +/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting */ -/* uncomment this if used with the debug version of python, but without its +/* uncomment this if used with the debug version of python, but without its * allocator */ /* #define Py_DEBUG_NO_PYMALLOC */ @@ -61,7 +61,10 @@ # undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */ #endif +#define PY_SSIZE_T_CLEAN + #include + #if defined(MACOS) && !defined(MACOS_X_UNIX) # include "macglue.h" # include @@ -69,10 +72,6 @@ #undef main /* Defined in python.h - aargh */ #undef HAVE_FCNTL_H /* Clash with os_win32.h */ -#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 -# define PY_SSIZE_T_CLEAN -#endif - /* The "surrogateescape" error handler is new in Python 3.1 */ #if PY_VERSION_HEX >= 0x030100f0 # define CODEC_ERROR_HANDLER "surrogateescape" diff --git a/src/version.c b/src/version.c index 4ec8b3ef86..46b9c54c2f 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1158, /**/ 1157, /**/ From 86481c77a154bf79e6b60f5975e84c87269daeb0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 18:36:24 +0200 Subject: [PATCH 04/24] Added tag v7-3-1158 for changeset 46077370bc60 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index e38452f0d4..2a2191205a 100644 --- a/.hgtags +++ b/.hgtags @@ -2494,3 +2494,4 @@ bc3f4804cf470cec5773d8842743efb760f69102 v7-3-1153 bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 8c4324e6f4779ee316361511ff783f6344750be9 v7-3-1156 2f1ee97f5f23a5f9e1c572ed4afb50fb79ce7a35 v7-3-1157 +46077370bc605815f5e41cbfc925120a913acbaa v7-3-1158 From d07f0db64c4d82e2b7c3cf44f0f319bf556b5478 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:10:44 +0200 Subject: [PATCH 05/24] updated for version 7.3.1159 Problem: The round() function is not always available. (Christ van Willegen) Solution: Use the solution from f_round(). --- src/eval.c | 14 ++++++++++++-- src/ex_cmds2.c | 2 +- src/proto/eval.pro | 7 ++++--- src/version.c | 2 ++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/eval.c b/src/eval.c index 7250556fc2..38893c795d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -15774,6 +15774,17 @@ theend: } #ifdef FEAT_FLOAT + +/* + * round() is not in C90, use ceil() or floor() instead. + */ + float_T +vim_round(f) + float_T f; +{ + return f > 0 ? floor(f + 0.5) : ceil(f - 0.5); +} + /* * "round({float})" function */ @@ -15786,8 +15797,7 @@ f_round(argvars, rettv) rettv->v_type = VAR_FLOAT; if (get_float_arg(argvars, &f) == OK) - /* round() is not in C90, use ceil() or floor() instead. */ - rettv->vval.v_float = f > 0 ? floor(f + 0.5) : ceil(f - 0.5); + rettv->vval.v_float = vim_round(f); else rettv->vval.v_float = 0.0; } diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 66b7e4e167..353ae8981f 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -982,7 +982,7 @@ profile_divide(tm, count, tm2) double usec = (tm->tv_sec * 1000000.0 + tm->tv_usec) / count; tm2->tv_sec = floor(usec / 1000000.0); - tm2->tv_usec = round(usec - (tm2->tv_sec * 1000000.0)); + tm2->tv_usec = vim_round(usec - (tm2->tv_sec * 1000000.0)); # endif } } diff --git a/src/proto/eval.pro b/src/proto/eval.pro index 3f2816ec2a..ee2da1b026 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -75,13 +75,12 @@ int dict_add_list __ARGS((dict_T *d, char *key, list_T *list)); dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len)); char_u *get_dict_string __ARGS((dict_T *d, char_u *key, int save)); long get_dict_number __ARGS((dict_T *d, char_u *key)); -void dict_extend __ARGS((dict_T *d1, dict_T *d2, char_u *action)); char_u *get_function_name __ARGS((expand_T *xp, int idx)); char_u *get_expr_name __ARGS((expand_T *xp, int idx)); -char_u *get_expanded_name __ARGS((char_u *name, int check)); -int translated_function_exists __ARGS((char_u *name)); int func_call __ARGS((char_u *name, typval_T *args, dict_T *selfdict, typval_T *rettv)); +void dict_extend __ARGS((dict_T *d1, dict_T *d2, char_u *action)); void mzscheme_call_vim __ARGS((char_u *name, typval_T *args, typval_T *rettv)); +float_T vim_round __ARGS((float_T f)); long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit)); void set_vim_var_nr __ARGS((int idx, long val)); long get_vim_var_nr __ARGS((int idx)); @@ -110,6 +109,8 @@ void ex_echohl __ARGS((exarg_T *eap)); void ex_execute __ARGS((exarg_T *eap)); void ex_function __ARGS((exarg_T *eap)); void free_all_functions __ARGS((void)); +int translated_function_exists __ARGS((char_u *name)); +char_u *get_expanded_name __ARGS((char_u *name, int check)); void func_dump_profile __ARGS((FILE *fd)); char_u *get_user_func_name __ARGS((expand_T *xp, int idx)); void ex_delfunction __ARGS((exarg_T *eap)); diff --git a/src/version.c b/src/version.c index 46b9c54c2f..394e6d5744 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1159, /**/ 1158, /**/ From 2f77d5a12ba146536e11140b6d166bcdbfa9f646 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:10:44 +0200 Subject: [PATCH 06/24] Added tag v7-3-1159 for changeset 208a6c04e6b8 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 2a2191205a..dd326802e1 100644 --- a/.hgtags +++ b/.hgtags @@ -2495,3 +2495,4 @@ bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 8c4324e6f4779ee316361511ff783f6344750be9 v7-3-1156 2f1ee97f5f23a5f9e1c572ed4afb50fb79ce7a35 v7-3-1157 46077370bc605815f5e41cbfc925120a913acbaa v7-3-1158 +208a6c04e6b8221c1f5187391d86c5b57e61445b v7-3-1159 From c573162dc91d154a6e5b6e332ae2512c6239e766 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:25:10 +0200 Subject: [PATCH 07/24] updated for version 7.3.1160 Problem: Mixing long and pointer doesn't always work. Solution: Avoid cast to pointer. --- src/undo.c | 6 ++++-- src/version.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/undo.c b/src/undo.c index ba6ab379f0..3acfad1ffa 100644 --- a/src/undo.c +++ b/src/undo.c @@ -1514,8 +1514,10 @@ u_write_undo(name, forceit, buf, hash) write_ok = TRUE; #ifdef U_DEBUG if (headers_written != buf->b_u_numhead) - EMSG3("Written %ld headers, but numhead is %ld", - headers_written, buf->b_u_numhead); + { + EMSGN("Written %ld headers, ...", headers_written); + EMSGN("... but numhead is %ld", buf->b_u_numhead); + } #endif write_error: diff --git a/src/version.c b/src/version.c index 394e6d5744..5268d54f2f 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1160, /**/ 1159, /**/ From 50d6c734ab6bc5481978f661ec0fe3fd578f5145 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:25:10 +0200 Subject: [PATCH 08/24] Added tag v7-3-1160 for changeset 60301d4d1682 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index dd326802e1..75b8413ada 100644 --- a/.hgtags +++ b/.hgtags @@ -2496,3 +2496,4 @@ bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 2f1ee97f5f23a5f9e1c572ed4afb50fb79ce7a35 v7-3-1157 46077370bc605815f5e41cbfc925120a913acbaa v7-3-1158 208a6c04e6b8221c1f5187391d86c5b57e61445b v7-3-1159 +60301d4d16827a961019d72a78e811f41326c680 v7-3-1160 From 6428a98399a56fbfa6572450b8991c7448d193cf Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:39:03 +0200 Subject: [PATCH 09/24] updated for version 7.3.1161 Problem: Python: PyList_SetItem() is inefficient. Solution: Use PyList_SET_ITEM() (ZyX) --- src/if_py_both.h | 46 ++++++++++++++++------------------------------ src/version.c | 2 ++ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/if_py_both.h b/src/if_py_both.h index ae2c6bc968..be75cc8433 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -375,8 +375,10 @@ static OutputObject Error = static int PythonIO_Init_io(void) { - PySys_SetObject("stdout", (PyObject *)(void *)&Output); - PySys_SetObject("stderr", (PyObject *)(void *)&Error); + if (PySys_SetObject("stdout", (PyObject *)(void *)&Output)) + return -1; + if (PySys_SetObject("stderr", (PyObject *)(void *)&Error)) + return -1; if (PyErr_Occurred()) { @@ -1319,12 +1321,7 @@ DictionaryListObjects(DictionaryObject *self, hi_to_py hiconvert) Py_DECREF(r); return NULL; } - if (PyList_SetItem(r, i, newObj)) - { - Py_DECREF(r); - Py_DECREF(newObj); - return NULL; - } + PyList_SET_ITEM(r, i, newObj); --todo; ++i; } @@ -1808,12 +1805,7 @@ ListSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last) return NULL; } - if ((PyList_SetItem(list, ((reversed)?(n-i-1):(i)), item))) - { - Py_DECREF(item); - Py_DECREF(list); - return NULL; - } + PyList_SET_ITEM(list, ((reversed)?(n-i-1):(i)), item); } return list; @@ -3164,13 +3156,7 @@ GetBufferLineList(buf_T *buf, PyInt lo, PyInt hi) return NULL; } - /* Set the list item */ - if (PyList_SetItem(list, i, str)) - { - Py_DECREF(str); - Py_DECREF(list); - return NULL; - } + PyList_SET_ITEM(list, i, str); } /* The ownership of the Python list is passed to the caller (ie, @@ -5366,8 +5352,8 @@ typedef PyObject *(*attr_getter)(PyObject *, const char *); static int populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) { - int i; - PyObject *os; + int i; + PyObject *other_module; for (i = 0; i < (int)(sizeof(numeric_constants) / sizeof(struct numeric_constant)); @@ -5395,24 +5381,24 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) ADD_CHECKED_OBJECT(m, "options", OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL)); - if (!(os = PyImport_ImportModule("os"))) + if (!(other_module = PyImport_ImportModule("os"))) return -1; - ADD_OBJECT(m, "os", os); + ADD_OBJECT(m, "os", other_module); - if (!(py_getcwd = PyObject_GetAttrString(os, "getcwd"))) + if (!(py_getcwd = PyObject_GetAttrString(other_module, "getcwd"))) return -1; ADD_OBJECT(m, "_getcwd", py_getcwd) - if (!(py_chdir = PyObject_GetAttrString(os, "chdir"))) + if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir"))) return -1; ADD_OBJECT(m, "_chdir", py_chdir); - if (PyObject_SetAttrString(os, "chdir", get_attr(m, "chdir"))) + if (PyObject_SetAttrString(other_module, "chdir", get_attr(m, "chdir"))) return -1; - if ((py_fchdir = PyObject_GetAttrString(os, "fchdir"))) + if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir"))) { ADD_OBJECT(m, "_fchdir", py_fchdir); - if (PyObject_SetAttrString(os, "fchdir", get_attr(m, "fchdir"))) + if (PyObject_SetAttrString(other_module,"fchdir",get_attr(m,"fchdir"))) return -1; } else diff --git a/src/version.c b/src/version.c index 5268d54f2f..ba277a0a80 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1161, /**/ 1160, /**/ From fe4be3969405815229886e66950159108c4f9d84 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:39:03 +0200 Subject: [PATCH 10/24] Added tag v7-3-1161 for changeset ff3935926449 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 75b8413ada..c4978e6706 100644 --- a/.hgtags +++ b/.hgtags @@ -2497,3 +2497,4 @@ bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 46077370bc605815f5e41cbfc925120a913acbaa v7-3-1158 208a6c04e6b8221c1f5187391d86c5b57e61445b v7-3-1159 60301d4d16827a961019d72a78e811f41326c680 v7-3-1160 +ff393592644960783e9a1c7c7959a8cbb0954673 v7-3-1161 From 9579fa5689075fe093a987eff2375cca3d76f4c3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:47:36 +0200 Subject: [PATCH 11/24] updated for version 7.3.1162 Problem: Python: Memory leaks Solution: Add more Py_DECREF(). (ZyX) --- src/if_py_both.h | 17 +++++++++++++++-- src/if_python.c | 16 ++++------------ src/version.c | 2 ++ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/if_py_both.h b/src/if_py_both.h index be75cc8433..287191a4ea 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -5354,6 +5354,7 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) { int i; PyObject *other_module; + PyObject *attr; for (i = 0; i < (int)(sizeof(numeric_constants) / sizeof(struct numeric_constant)); @@ -5392,14 +5393,26 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir"))) return -1; ADD_OBJECT(m, "_chdir", py_chdir); - if (PyObject_SetAttrString(other_module, "chdir", get_attr(m, "chdir"))) + if (!(attr = get_attr(m, "chdir"))) return -1; + if (PyObject_SetAttrString(other_module, "chdir", attr)) + { + Py_DECREF(attr); + return -1; + } + Py_DECREF(attr); if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir"))) { ADD_OBJECT(m, "_fchdir", py_fchdir); - if (PyObject_SetAttrString(other_module,"fchdir",get_attr(m,"fchdir"))) + if (!(attr = get_attr(m, "fchdir"))) return -1; + if (PyObject_SetAttrString(other_module, "fchdir", attr)) + { + Py_DECREF(attr); + return -1; + } + Py_DECREF(attr); } else PyErr_Clear(); diff --git a/src/if_python.c b/src/if_python.c index 318b170ee2..518b4e3f11 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -210,6 +210,7 @@ struct PyMethodDef { Py_ssize_t a; }; # define PyMapping_Check dll_PyMapping_Check # define PyIter_Next dll_PyIter_Next # define PyModule_GetDict dll_PyModule_GetDict +# define PyModule_AddObject dll_PyModule_AddObject # define PyRun_SimpleString dll_PyRun_SimpleString # define PyRun_String dll_PyRun_String # define PyObject_GetAttrString dll_PyObject_GetAttrString @@ -344,6 +345,7 @@ static PyObject* (*dll_PyObject_CallMethod)(PyObject *, char *, PyObject *); static int (*dll_PyMapping_Check)(PyObject *); static PyObject* (*dll_PyIter_Next)(PyObject *); static PyObject*(*dll_PyModule_GetDict)(PyObject *); +static int(*dll_PyModule_AddObject)(PyObject *, const char *, PyObject *); static int(*dll_PyRun_SimpleString)(char *); static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *); static PyObject* (*dll_PyObject_GetAttrString)(PyObject *, const char *); @@ -509,6 +511,7 @@ static struct {"PyMapping_Check", (PYTHON_PROC*)&dll_PyMapping_Check}, {"PyIter_Next", (PYTHON_PROC*)&dll_PyIter_Next}, {"PyModule_GetDict", (PYTHON_PROC*)&dll_PyModule_GetDict}, + {"PyModule_AddObject", (PYTHON_PROC*)&dll_PyModule_AddObject}, {"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString}, {"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String}, {"PyObject_GetAttrString", (PYTHON_PROC*)&dll_PyObject_GetAttrString}, @@ -1356,20 +1359,10 @@ python_tabpage_free(tabpage_T *tab) } #endif - static int -add_object(PyObject *dict, const char *name, PyObject *object) -{ - if (PyDict_SetItemString(dict, (char *) name, object)) - return -1; - Py_DECREF(object); - return 0; -} - static int PythonMod_Init(void) { PyObject *mod; - PyObject *dict; /* The special value is removed from sys.path in Python_Init(). */ static char *(argv[2]) = {"/must>not&exist/foo", NULL}; @@ -1382,9 +1375,8 @@ PythonMod_Init(void) mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION); - dict = PyModule_GetDict(mod); - return populate_module(dict, add_object, PyDict_GetItemString); + return populate_module(mod, PyModule_AddObject, PyObject_GetAttrString); } /************************************************************************* diff --git a/src/version.c b/src/version.c index ba277a0a80..1bdba0201f 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1162, /**/ 1161, /**/ From 6ac15d6fab7deb903f035b08f5bc06f8199ef9f2 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 20:47:37 +0200 Subject: [PATCH 12/24] Added tag v7-3-1162 for changeset b8eabb6a9687 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index c4978e6706..e8d59b0e16 100644 --- a/.hgtags +++ b/.hgtags @@ -2498,3 +2498,4 @@ bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 208a6c04e6b8221c1f5187391d86c5b57e61445b v7-3-1159 60301d4d16827a961019d72a78e811f41326c680 v7-3-1160 ff393592644960783e9a1c7c7959a8cbb0954673 v7-3-1161 +b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162 From fe75785d8e16cd0921a38564770587c75649bbaa Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 21:27:29 +0200 Subject: [PATCH 13/24] updated for version 7.3.1163 Problem: Not easy to load Python modules. Solution: Search "python2", "python3" and "pythonx" directories in 'runtimepath' for Python modules. (ZyX) --- runtime/doc/if_pyth.txt | 113 +++++++++++++++++ src/auto/configure | 6 +- src/configure.in | 6 +- src/ex_cmds2.c | 16 ++- src/if_py_both.h | 267 ++++++++++++++++++++++++++++++++++++++-- src/if_python.c | 141 +++++++++++++++++++-- src/if_python3.c | 92 ++++++++++++-- src/testdir/test86.in | 8 ++ src/testdir/test87.in | 8 ++ src/version.c | 2 + 10 files changed, 627 insertions(+), 32 deletions(-) diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt index 165131e64b..c54f564209 100644 --- a/runtime/doc/if_pyth.txt +++ b/runtime/doc/if_pyth.txt @@ -180,6 +180,12 @@ vim.strwidth(str) *python-strwidth* Like |strwidth()|: returns number of display cells str occupies, tab is counted as one cell. +vim.foreach_rtp(callable) *python-foreach_rtp* + Call the given callable for each path in 'runtimepath' until either + callable returns something but None, the exception is raised or there + are no longer paths. If stopped in case callable returned non-None, + vim.foreach_rtp function returns the value returned by callable. + vim.chdir(*args, **kwargs) *python-chdir* vim.fchdir(*args, **kwargs) *python-fchdir* Run os.chdir or os.fchdir, then all appropriate vim stuff. @@ -300,6 +306,113 @@ Output from Python *python-output* supported, and may cause the program to crash. This should probably be fixed. + *python2-directory* *python3-directory* *pythonx-directory* +Python 'runtimepath' handling *python-special-path* + +In python vim.VIM_SPECIAL_PATH special directory is used as a replacement for +the list of paths found in 'runtimepath': with this directory in sys.path and +vim.path_hooks in sys.path_hooks python will try to load module from +{rtp}/python2 (or python3) and {rtp}/pythonx (for both python versions) for +each {rtp} found in 'runtimepath'. + +Implementation for python 2 is the following: usual importing code with empty +lists in place of sys.path_hooks and sys.meta_path. Code is similar to the +below, but written in C: > + + # Assuming vim variable is already accessible and is set to the current + # module + import sys + + def find_module(fullname): + return vim + + def load_module(fullname): + # see vim._get_paths below + new_path = _get_paths() + + try: old_path = sys.path + except: pass + try: old_meta_path = sys.meta_path + except: pass + try: old_path_hooks = sys.path_hooks + except: pass + + sys.meta_path = [] + sys.path_hooks = sys.meta_path + sys.path = new_path + + try: + exec ('import ' + fullname + ' as m') # No actual exec in C code + return m + finally: + e = None + try: sys.path = old_path + except Exception as e: pass + try: sys.meta_path = old_meta_path + except Exception as e: pass + try: sys.path_hooks = old_path_hooks + except Exception as e: pass + if e: + raise e + + def path_hook(d): + if d == VIM_SPECIAL_PATH: + return vim + raise ImportError + + sys.path_hooks.append(path_hook) + +Implementation for python 3 is cleaner: code is similar to the following, but, +again, written in C: > + + from importlib.machinery import PathFinder + import sys + + class Finder(PathFinder): + @classmethod + def find_module(cls, fullname): + # see vim._get_paths below + new_path = _get_paths() + + # super().find_module is also a class method + # super() is not used because this variant is easier to implement + # in C + return PathFinder.find_module(fullname, new_path) + + def path_hook(path): + if path == VIM_SPECIAL_PATH: + return Finder + raise ImportError + + sys.path_hooks.append(path_hook) + +vim.VIM_SPECIAL_PATH *python-VIM_SPECIAL_PATH* + String constant used in conjunction with vim path hook. If path hook + installed by vim is requested to handle anything but path equal to + vim.VIM_SPECIAL_PATH constant it raises ImportError. In the only other + case it uses special loader. + + Note: you must not use value of this constant directly, always use + vim.VIM_SPECIAL_PATH object. + +vim.load_module(name) *python-load_module* +vim.find_module(...) *python-find_module* +vim.path_hook(path) *python-path_hook* + Methods or objects used to implement path loading as described above. + You should not be using any of these directly except for vim.path_hook + in case you need to do something with sys.meta_path. It is not + guaranteed that any of the objects will exist in the future vim + versions. In fact, load_module and find_module methods do not exists + in python3. + +vim._get_paths *python-_get_paths* + Methods returning a list of paths which will be searched for by path + hook. You should not rely on this method being present in future + versions, but can use it for debugging. + + It returns a list of {rtp}/python2 (or {rtp}/python3) and + {rtp}/pythonx directories for each {rtp} in 'runtimepath'. + ============================================================================== 3. Buffer objects *python-buffer* diff --git a/src/auto/configure b/src/auto/configure index 2bbc9cf4ef..0a8f6f619e 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -5289,10 +5289,10 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python_version" >&5 $as_echo "$vi_cv_var_python_version" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python is 2.2 or better" >&5 -$as_echo_n "checking Python is 2.2 or better... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python is 2.3 or better" >&5 +$as_echo_n "checking Python is 2.3 or better... " >&6; } if ${vi_cv_path_python} -c \ - "import sys; sys.exit(${vi_cv_var_python_version} < 2.2)" + "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)" then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yep" >&5 $as_echo "yep" >&6; } diff --git a/src/configure.in b/src/configure.in index 08b8215fb7..17a80367be 100644 --- a/src/configure.in +++ b/src/configure.in @@ -863,10 +863,10 @@ if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; th ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'` ]]) - dnl -- it must be at least version 2.2 - AC_MSG_CHECKING(Python is 2.2 or better) + dnl -- it must be at least version 2.3 + AC_MSG_CHECKING(Python is 2.3 or better) if ${vi_cv_path_python} -c \ - "import sys; sys.exit(${vi_cv_var_python_version} < 2.2)" + "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)" then AC_MSG_RESULT(yep) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 353ae8981f..22b41f415e 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2737,6 +2737,10 @@ source_runtime(name, all) * When "all" is TRUE repeat for all matches, otherwise only the first one is * used. * Returns OK when at least one match found, FAIL otherwise. + * + * If "name" is NULL calls callback for each entry in runtimepath. Cookie is + * passed by reference in this case, setting it to NULL indicates that callback + * has done its job. */ int do_in_runtimepath(name, all, callback, cookie) @@ -2768,7 +2772,7 @@ do_in_runtimepath(name, all, callback, cookie) buf = alloc(MAXPATHL); if (buf != NULL && rtp_copy != NULL) { - if (p_verbose > 1) + if (p_verbose > 1 && name != NULL) { verbose_enter(); smsg((char_u *)_("Searching for \"%s\" in \"%s\""), @@ -2782,7 +2786,13 @@ do_in_runtimepath(name, all, callback, cookie) { /* Copy the path from 'runtimepath' to buf[]. */ copy_option_part(&rtp, buf, MAXPATHL, ","); - if (STRLEN(buf) + STRLEN(name) + 2 < MAXPATHL) + if (name == NULL) + { + (*callback)(buf, (void *) &cookie); + if (!did_one) + did_one = (cookie == NULL); + } + else if (STRLEN(buf) + STRLEN(name) + 2 < MAXPATHL) { add_pathsep(buf); tail = buf + STRLEN(buf); @@ -2821,7 +2831,7 @@ do_in_runtimepath(name, all, callback, cookie) } vim_free(buf); vim_free(rtp_copy); - if (p_verbose > 0 && !did_one) + if (p_verbose > 0 && !did_one && name != NULL) { verbose_enter(); smsg((char_u *)_("not found in 'runtimepath': \"%s\""), name); diff --git a/src/if_py_both.h b/src/if_py_both.h index 287191a4ea..1e5a151e71 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -24,6 +24,8 @@ typedef int Py_ssize_t; /* Python 2.4 and earlier don't have this type. */ #endif #define DOPY_FUNC "_vim_pydo" +static const char *vim_special_path = "_vim_path_"; + #define PyErr_SetVim(str) PyErr_SetString(VimError, str) #define RAISE_NO_EMPTY_KEYS PyErr_SetString(PyExc_ValueError, \ @@ -55,6 +57,8 @@ static PyObject *globals; static PyObject *py_chdir; static PyObject *py_fchdir; static PyObject *py_getcwd; +static PyObject *vim_module; +static PyObject *vim_special_path_object; /* * obtain a lock on the Vim data structures @@ -779,19 +783,168 @@ VimFchdir(PyObject *self UNUSED, PyObject *args, PyObject *kwargs) return _VimChdir(py_fchdir, args, kwargs); } +typedef struct { + PyObject *callable; + PyObject *result; +} map_rtp_data; + + static void +map_rtp_callback(char_u *path, void *_data) +{ + void **data = (void **) _data; + PyObject *pathObject; + map_rtp_data *mr_data = *((map_rtp_data **) data); + + if (!(pathObject = PyString_FromString((char *) path))) + { + *data = NULL; + return; + } + + mr_data->result = PyObject_CallFunctionObjArgs(mr_data->callable, + pathObject, NULL); + + Py_DECREF(pathObject); + + if (!mr_data->result || mr_data->result != Py_None) + *data = NULL; + else + { + Py_DECREF(mr_data->result); + mr_data->result = NULL; + } +} + + static PyObject * +VimForeachRTP(PyObject *self UNUSED, PyObject *args) +{ + map_rtp_data data; + + if (!PyArg_ParseTuple(args, "O", &data.callable)) + return NULL; + + data.result = NULL; + + do_in_runtimepath(NULL, FALSE, &map_rtp_callback, &data); + + if (data.result == NULL) + { + if (PyErr_Occurred()) + return NULL; + else + { + Py_INCREF(Py_None); + return Py_None; + } + } + return data.result; +} + +/* + * _vim_runtimepath_ special path implementation. + */ + + static void +map_finder_callback(char_u *path, void *_data) +{ + void **data = (void **) _data; + PyObject *list = *((PyObject **) data); + PyObject *pathObject1, *pathObject2; + char *pathbuf; + size_t pathlen; + + pathlen = STRLEN(path); + +#if PY_MAJOR_VERSION < 3 +# define PY_MAIN_DIR_STRING "python2" +#else +# define PY_MAIN_DIR_STRING "python3" +#endif +#define PY_ALTERNATE_DIR_STRING "pythonx" + +#define PYTHONX_STRING_LENGTH 7 /* STRLEN("pythonx") */ + if (!(pathbuf = PyMem_New(char, + pathlen + STRLEN(PATHSEPSTR) + PYTHONX_STRING_LENGTH + 1))) + { + PyErr_NoMemory(); + *data = NULL; + return; + } + + mch_memmove(pathbuf, path, pathlen + 1); + add_pathsep((char_u *) pathbuf); + + pathlen = STRLEN(pathbuf); + mch_memmove(pathbuf + pathlen, PY_MAIN_DIR_STRING, + PYTHONX_STRING_LENGTH + 1); + + if (!(pathObject1 = PyString_FromString(pathbuf))) + { + *data = NULL; + PyMem_Free(pathbuf); + return; + } + + mch_memmove(pathbuf + pathlen, PY_ALTERNATE_DIR_STRING, + PYTHONX_STRING_LENGTH + 1); + + if (!(pathObject2 = PyString_FromString(pathbuf))) + { + Py_DECREF(pathObject1); + PyMem_Free(pathbuf); + *data = NULL; + return; + } + + PyMem_Free(pathbuf); + + if (PyList_Append(list, pathObject1) + || PyList_Append(list, pathObject2)) + *data = NULL; + + Py_DECREF(pathObject1); + Py_DECREF(pathObject2); +} + + static PyObject * +Vim_GetPaths(PyObject *self UNUSED) +{ + PyObject *r; + + if (!(r = PyList_New(0))) + return NULL; + + do_in_runtimepath(NULL, FALSE, &map_finder_callback, r); + + if (PyErr_Occurred()) + { + Py_DECREF(r); + return NULL; + } + + return r; +} + /* * Vim module - Definitions */ static struct PyMethodDef VimMethods[] = { - /* name, function, calling, documentation */ - {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" }, - {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" }, - {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"}, - {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts as having width 1"}, - {"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, - {"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, - { NULL, NULL, 0, NULL } + /* name, function, calling, documentation */ + {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" }, + {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" }, + {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"}, + {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts as having width 1"}, + {"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, + {"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, + {"foreach_rtp", VimForeachRTP, METH_VARARGS, "Call given callable for each path in &rtp"}, +#if PY_MAJOR_VERSION < 3 + {"find_module", FinderFindModule, METH_VARARGS, "Internal use only, returns loader object for any input it receives"}, + {"load_module", LoaderLoadModule, METH_VARARGS, "Internal use only, tries importing the given module from &rtp by temporary mocking sys.path (to an rtp-based one) and unsetting sys.meta_path and sys.path_hooks"}, +#endif + {"path_hook", VimPathHook, METH_VARARGS, "Hook function to install in sys.path_hooks"}, + {"_get_paths", (PyCFunction)Vim_GetPaths, METH_NOARGS, "Get &rtp-based additions to sys.path"}, + { NULL, NULL, 0, NULL} }; /* @@ -5036,6 +5189,14 @@ typedef struct } CurrentObject; static PyTypeObject CurrentType; +#if PY_MAJOR_VERSION >= 3 +typedef struct +{ + PyObject_HEAD +} FinderObject; +static PyTypeObject FinderType; +#endif + static void init_structs(void) { @@ -5281,6 +5442,81 @@ init_types() PYTYPE_READY(FunctionType); PYTYPE_READY(OptionsType); PYTYPE_READY(OutputType); +#if PY_MAJOR_VERSION >= 3 + PYTYPE_READY(FinderType); +#endif + return 0; +} + + static int +init_sys_path() +{ + PyObject *path; + PyObject *path_hook; + PyObject *path_hooks; + + if (!(path_hook = PyObject_GetAttrString(vim_module, "path_hook"))) + return -1; + + if (!(path_hooks = PySys_GetObject("path_hooks"))) + { + PyErr_Clear(); + path_hooks = PyList_New(1); + PyList_SET_ITEM(path_hooks, 0, path_hook); + if (PySys_SetObject("path_hooks", path_hooks)) + { + Py_DECREF(path_hooks); + return -1; + } + Py_DECREF(path_hooks); + } + else if (PyList_Check(path_hooks)) + { + if (PyList_Append(path_hooks, path_hook)) + { + Py_DECREF(path_hook); + return -1; + } + Py_DECREF(path_hook); + } + else + { + VimTryStart(); + EMSG(_("Failed to set path hook: sys.path_hooks is not a list\n" + "You should now do the following:\n" + "- append vim.path_hook to sys.path_hooks\n" + "- append vim.VIM_SPECIAL_PATH to sys.path\n")); + VimTryEnd(); /* Discard the error */ + Py_DECREF(path_hook); + return 0; + } + + if (!(path = PySys_GetObject("path"))) + { + PyErr_Clear(); + path = PyList_New(1); + Py_INCREF(vim_special_path_object); + PyList_SET_ITEM(path, 0, vim_special_path_object); + if (PySys_SetObject("path", path)) + { + Py_DECREF(path); + return -1; + } + Py_DECREF(path); + } + else if (PyList_Check(path)) + { + if (PyList_Append(path, vim_special_path_object)) + return -1; + } + else + { + VimTryStart(); + EMSG(_("Failed to set path: sys.path is not a list\n" + "You should now append vim.VIM_SPECIAL_PATH to sys.path")); + VimTryEnd(); /* Discard the error */ + } + return 0; } @@ -5332,6 +5568,9 @@ static struct object_constant { {"List", (PyObject *)&ListType}, {"Function", (PyObject *)&FunctionType}, {"Options", (PyObject *)&OptionsType}, +#if PY_MAJOR_VERSION >= 3 + {"Finder", (PyObject *)&FinderType}, +#endif }; typedef int (*object_adder)(PyObject *, const char *, PyObject *); @@ -5417,5 +5656,17 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) else PyErr_Clear(); + if (!(vim_special_path_object = PyString_FromString(vim_special_path))) + return -1; + + ADD_OBJECT(m, "VIM_SPECIAL_PATH", vim_special_path_object); + +#if PY_MAJOR_VERSION >= 3 + ADD_OBJECT(m, "_PathFinder", path_finder); + ADD_CHECKED_OBJECT(m, "_find_module", + (py_find_module = PyObject_GetAttrString(path_finder, + "find_module"))); +#endif + return 0; } diff --git a/src/if_python.c b/src/if_python.c index 518b4e3f11..09b3ca5d23 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -24,9 +24,9 @@ /* uncomment this if used with the debug version of python. * Checked on 2.7.4. */ /* #define Py_DEBUG */ -/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting +/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting */ -/* uncomment this if used with the debug version of python, but without its +/* uncomment this if used with the debug version of python, but without its * allocator */ /* #define Py_DEBUG_NO_PYMALLOC */ @@ -168,6 +168,7 @@ struct PyMethodDef { Py_ssize_t a; }; # define PyErr_SetNone dll_PyErr_SetNone # define PyErr_SetString dll_PyErr_SetString # define PyErr_SetObject dll_PyErr_SetObject +# define PyErr_ExceptionMatches dll_PyErr_ExceptionMatches # define PyEval_InitThreads dll_PyEval_InitThreads # define PyEval_RestoreThread dll_PyEval_RestoreThread # define PyEval_SaveThread dll_PyEval_SaveThread @@ -184,6 +185,7 @@ struct PyMethodDef { Py_ssize_t a; }; # define PyLong_Type (*dll_PyLong_Type) # define PyList_GetItem dll_PyList_GetItem # define PyList_Append dll_PyList_Append +# define PyList_Insert dll_PyList_Insert # define PyList_New dll_PyList_New # define PyList_SetItem dll_PyList_SetItem # define PyList_Size dll_PyList_Size @@ -233,6 +235,7 @@ struct PyMethodDef { Py_ssize_t a; }; # define PyFloat_Type (*dll_PyFloat_Type) # define PyImport_AddModule (*dll_PyImport_AddModule) # define PySys_SetObject dll_PySys_SetObject +# define PySys_GetObject dll_PySys_GetObject # define PySys_SetArgv dll_PySys_SetArgv # define PyType_Type (*dll_PyType_Type) # define PyType_Ready (*dll_PyType_Ready) @@ -305,6 +308,7 @@ static PyObject*(*dll_PyErr_Occurred)(void); static void(*dll_PyErr_SetNone)(PyObject *); static void(*dll_PyErr_SetString)(PyObject *, const char *); static void(*dll_PyErr_SetObject)(PyObject *, PyObject *); +static int(*dll_PyErr_ExceptionMatches)(PyObject *); static void(*dll_PyEval_InitThreads)(void); static void(*dll_PyEval_RestoreThread)(PyThreadState *); static PyThreadState*(*dll_PyEval_SaveThread)(void); @@ -320,7 +324,8 @@ static PyTypeObject* dll_PyBool_Type; static PyTypeObject* dll_PyInt_Type; static PyTypeObject* dll_PyLong_Type; static PyObject*(*dll_PyList_GetItem)(PyObject *, PyInt); -static PyObject*(*dll_PyList_Append)(PyObject *, PyObject *); +static int(*dll_PyList_Append)(PyObject *, PyObject *); +static int(*dll_PyList_Insert)(PyObject *, int, PyObject *); static PyObject*(*dll_PyList_New)(PyInt size); static int(*dll_PyList_SetItem)(PyObject *, PyInt, PyObject *); static PyInt(*dll_PyList_Size)(PyObject *); @@ -366,6 +371,7 @@ static double(*dll_PyFloat_AsDouble)(PyObject *); static PyObject*(*dll_PyFloat_FromDouble)(double); static PyTypeObject* dll_PyFloat_Type; static int(*dll_PySys_SetObject)(char *, PyObject *); +static PyObject *(*dll_PySys_GetObject)(char *); static int(*dll_PySys_SetArgv)(int, char **); static PyTypeObject* dll_PyType_Type; static int (*dll_PyType_Ready)(PyTypeObject *type); @@ -431,6 +437,7 @@ static PyObject *imp_PyExc_KeyboardInterrupt; static PyObject *imp_PyExc_TypeError; static PyObject *imp_PyExc_ValueError; static PyObject *imp_PyExc_RuntimeError; +static PyObject *imp_PyExc_ImportError; # define PyExc_AttributeError imp_PyExc_AttributeError # define PyExc_IndexError imp_PyExc_IndexError @@ -439,6 +446,7 @@ static PyObject *imp_PyExc_RuntimeError; # define PyExc_TypeError imp_PyExc_TypeError # define PyExc_ValueError imp_PyExc_ValueError # define PyExc_RuntimeError imp_PyExc_RuntimeError +# define PyExc_ImportError imp_PyExc_ImportError /* * Table of name to function pointer of python. @@ -471,6 +479,7 @@ static struct {"PyErr_SetNone", (PYTHON_PROC*)&dll_PyErr_SetNone}, {"PyErr_SetString", (PYTHON_PROC*)&dll_PyErr_SetString}, {"PyErr_SetObject", (PYTHON_PROC*)&dll_PyErr_SetObject}, + {"PyErr_ExceptionMatches", (PYTHON_PROC*)&dll_PyErr_ExceptionMatches}, {"PyEval_InitThreads", (PYTHON_PROC*)&dll_PyEval_InitThreads}, {"PyEval_RestoreThread", (PYTHON_PROC*)&dll_PyEval_RestoreThread}, {"PyEval_SaveThread", (PYTHON_PROC*)&dll_PyEval_SaveThread}, @@ -487,6 +496,7 @@ static struct {"PyLong_Type", (PYTHON_PROC*)&dll_PyLong_Type}, {"PyList_GetItem", (PYTHON_PROC*)&dll_PyList_GetItem}, {"PyList_Append", (PYTHON_PROC*)&dll_PyList_Append}, + {"PyList_Insert", (PYTHON_PROC*)&dll_PyList_Insert}, {"PyList_New", (PYTHON_PROC*)&dll_PyList_New}, {"PyList_SetItem", (PYTHON_PROC*)&dll_PyList_SetItem}, {"PyList_Size", (PYTHON_PROC*)&dll_PyList_Size}, @@ -532,6 +542,7 @@ static struct {"PyFloat_FromDouble", (PYTHON_PROC*)&dll_PyFloat_FromDouble}, {"PyImport_AddModule", (PYTHON_PROC*)&dll_PyImport_AddModule}, {"PySys_SetObject", (PYTHON_PROC*)&dll_PySys_SetObject}, + {"PySys_GetObject", (PYTHON_PROC*)&dll_PySys_GetObject}, {"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv}, {"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type}, {"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready}, @@ -706,6 +717,7 @@ get_exceptions(void) imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError"); imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError"); imp_PyExc_RuntimeError = PyDict_GetItemString(exdict, "RuntimeError"); + imp_PyExc_ImportError = PyDict_GetItemString(exdict, "ImportError"); Py_XINCREF(imp_PyExc_AttributeError); Py_XINCREF(imp_PyExc_IndexError); Py_XINCREF(imp_PyExc_KeyError); @@ -713,6 +725,7 @@ get_exceptions(void) Py_XINCREF(imp_PyExc_TypeError); Py_XINCREF(imp_PyExc_ValueError); Py_XINCREF(imp_PyExc_RuntimeError); + Py_XINCREF(imp_PyExc_ImportError); Py_XDECREF(exmod); } #endif /* DYNAMIC_PYTHON */ @@ -735,6 +748,10 @@ static PyObject *DictionaryGetattr(PyObject *, char*); static PyObject *ListGetattr(PyObject *, char *); static PyObject *FunctionGetattr(PyObject *, char *); +static PyObject *LoaderLoadModule(PyObject *, PyObject *); +static PyObject *FinderFindModule(PyObject *, PyObject *); +static PyObject *VimPathHook(PyObject *, PyObject *); + #ifndef Py_VISIT # define Py_VISIT(obj) visit(obj, arg) #endif @@ -1359,11 +1376,112 @@ python_tabpage_free(tabpage_T *tab) } #endif + static PyObject * +LoaderLoadModule(PyObject *self, PyObject *args) +{ + char *fullname; + PyObject *path; + PyObject *meta_path; + PyObject *path_hooks; + PyObject *new_path; + PyObject *r; + PyObject *new_list; + + if (!PyArg_ParseTuple(args, "s", &fullname)) + return NULL; + + if (!(new_path = Vim_GetPaths(self))) + return NULL; + + if (!(new_list = PyList_New(0))) + return NULL; + +#define GET_SYS_OBJECT(objstr, obj) \ + obj = PySys_GetObject(objstr); \ + PyErr_Clear(); \ + Py_XINCREF(obj); + + GET_SYS_OBJECT("meta_path", meta_path); + if (PySys_SetObject("meta_path", new_list)) + { + Py_XDECREF(meta_path); + Py_DECREF(new_list); + return NULL; + } + Py_DECREF(new_list); /* Now it becomes a reference borrowed from + sys.meta_path */ + +#define RESTORE_SYS_OBJECT(objstr, obj) \ + if (obj) \ + { \ + PySys_SetObject(objstr, obj); \ + Py_DECREF(obj); \ + } + + GET_SYS_OBJECT("path_hooks", path_hooks); + if (PySys_SetObject("path_hooks", new_list)) + { + RESTORE_SYS_OBJECT("meta_path", meta_path); + Py_XDECREF(path_hooks); + return NULL; + } + + GET_SYS_OBJECT("path", path); + if (PySys_SetObject("path", new_path)) + { + RESTORE_SYS_OBJECT("meta_path", meta_path); + RESTORE_SYS_OBJECT("path_hooks", path_hooks); + Py_XDECREF(path); + return NULL; + } + Py_DECREF(new_path); + + r = PyImport_ImportModule(fullname); + + RESTORE_SYS_OBJECT("meta_path", meta_path); + RESTORE_SYS_OBJECT("path_hooks", path_hooks); + RESTORE_SYS_OBJECT("path", path); + + if (PyErr_Occurred()) + { + Py_XDECREF(r); + return NULL; + } + + return r; +} + + static PyObject * +FinderFindModule(PyObject *self UNUSED, PyObject *args UNUSED) +{ + /* + * Don't bother actually finding the module, it is delegated to the "loader" + * object (which is basically the same object: vim module). + */ + Py_INCREF(vim_module); + return vim_module; +} + + static PyObject * +VimPathHook(PyObject *self UNUSED, PyObject *args) +{ + char *path; + + if (PyArg_ParseTuple(args, "s", &path) + && STRCMP(path, vim_special_path) == 0) + { + Py_INCREF(vim_module); + return vim_module; + } + + PyErr_Clear(); + PyErr_SetNone(PyExc_ImportError); + return NULL; +} + static int PythonMod_Init(void) { - PyObject *mod; - /* The special value is removed from sys.path in Python_Init(). */ static char *(argv[2]) = {"/must>not&exist/foo", NULL}; @@ -1373,10 +1491,17 @@ PythonMod_Init(void) /* Set sys.argv[] to avoid a crash in warn(). */ PySys_SetArgv(1, argv); - mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, - PYTHON_API_VERSION); + vim_module = Py_InitModule4("vim", VimMethods, (char *)NULL, + (PyObject *)NULL, PYTHON_API_VERSION); - return populate_module(mod, PyModule_AddObject, PyObject_GetAttrString); + if (populate_module(vim_module, PyModule_AddObject, + PyObject_GetAttrString)) + return -1; + + if (init_sys_path()) + return -1; + + return 0; } /************************************************************************* diff --git a/src/if_python3.c b/src/if_python3.c index 637ecd1960..5c3c0b0d8a 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -134,6 +134,7 @@ # define PyErr_SetNone py3_PyErr_SetNone # define PyErr_SetString py3_PyErr_SetString # define PyErr_SetObject py3_PyErr_SetObject +# define PyErr_ExceptionMatches py3_PyErr_ExceptionMatches # define PyEval_InitThreads py3_PyEval_InitThreads # define PyEval_RestoreThread py3_PyEval_RestoreThread # define PyEval_SaveThread py3_PyEval_SaveThread @@ -143,6 +144,7 @@ # define PyLong_FromLong py3_PyLong_FromLong # define PyList_GetItem py3_PyList_GetItem # define PyList_Append py3_PyList_Append +# define PyList_Insert py3_PyList_Insert # define PyList_New py3_PyList_New # define PyList_SetItem py3_PyList_SetItem # define PyList_Size py3_PyList_Size @@ -177,6 +179,7 @@ # define PyEval_GetLocals py3_PyEval_GetLocals # define PyEval_GetGlobals py3_PyEval_GetGlobals # define PySys_SetObject py3_PySys_SetObject +# define PySys_GetObject py3_PySys_GetObject # define PySys_SetArgv py3_PySys_SetArgv # define PyType_Ready py3_PyType_Ready #undef Py_BuildValue @@ -268,7 +271,9 @@ static PyObject* (*py3_PyList_New)(Py_ssize_t size); static PyGILState_STATE (*py3_PyGILState_Ensure)(void); static void (*py3_PyGILState_Release)(PyGILState_STATE); static int (*py3_PySys_SetObject)(char *, PyObject *); -static PyObject* (*py3_PyList_Append)(PyObject *, PyObject *); +static PyObject* (*py3_PySys_GetObject)(char *); +static int (*py3_PyList_Append)(PyObject *, PyObject *); +static int (*py3_PyList_Insert)(PyObject *, int, PyObject *); static Py_ssize_t (*py3_PyList_Size)(PyObject *); static int (*py3_PySequence_Check)(PyObject *); static Py_ssize_t (*py3_PySequence_Size)(PyObject *); @@ -284,6 +289,7 @@ static PyObject* (*py3_PyErr_NoMemory)(void); static void (*py3_Py_Finalize)(void); static void (*py3_PyErr_SetString)(PyObject *, const char *); static void (*py3_PyErr_SetObject)(PyObject *, PyObject *); +static int (*py3_PyErr_ExceptionMatches)(PyObject *); static int (*py3_PyRun_SimpleString)(char *); static PyObject* (*py3_PyRun_String)(char *, int, PyObject *, PyObject *); static PyObject* (*py3_PyObject_GetAttrString)(PyObject *, const char *); @@ -393,6 +399,7 @@ static PyObject *p3imp_PyExc_KeyboardInterrupt; static PyObject *p3imp_PyExc_TypeError; static PyObject *p3imp_PyExc_ValueError; static PyObject *p3imp_PyExc_RuntimeError; +static PyObject *p3imp_PyExc_ImportError; # define PyExc_AttributeError p3imp_PyExc_AttributeError # define PyExc_IndexError p3imp_PyExc_IndexError @@ -401,6 +408,7 @@ static PyObject *p3imp_PyExc_RuntimeError; # define PyExc_TypeError p3imp_PyExc_TypeError # define PyExc_ValueError p3imp_PyExc_ValueError # define PyExc_RuntimeError p3imp_PyExc_RuntimeError +# define PyExc_ImportError p3imp_PyExc_ImportError /* * Table of name to function pointer of python. @@ -428,7 +436,9 @@ static struct {"PyGILState_Ensure", (PYTHON_PROC*)&py3_PyGILState_Ensure}, {"PyGILState_Release", (PYTHON_PROC*)&py3_PyGILState_Release}, {"PySys_SetObject", (PYTHON_PROC*)&py3_PySys_SetObject}, + {"PySys_GetObject", (PYTHON_PROC*)&py3_PySys_GetObject}, {"PyList_Append", (PYTHON_PROC*)&py3_PyList_Append}, + {"PyList_Insert", (PYTHON_PROC*)&py3_PyList_Insert}, {"PyList_Size", (PYTHON_PROC*)&py3_PyList_Size}, {"PySequence_Check", (PYTHON_PROC*)&py3_PySequence_Check}, {"PySequence_Size", (PYTHON_PROC*)&py3_PySequence_Size}, @@ -441,6 +451,7 @@ static struct {"Py_Finalize", (PYTHON_PROC*)&py3_Py_Finalize}, {"PyErr_SetString", (PYTHON_PROC*)&py3_PyErr_SetString}, {"PyErr_SetObject", (PYTHON_PROC*)&py3_PyErr_SetObject}, + {"PyErr_ExceptionMatches", (PYTHON_PROC*)&py3_PyErr_ExceptionMatches}, {"PyRun_SimpleString", (PYTHON_PROC*)&py3_PyRun_SimpleString}, {"PyRun_String", (PYTHON_PROC*)&py3_PyRun_String}, {"PyObject_GetAttrString", (PYTHON_PROC*)&py3_PyObject_GetAttrString}, @@ -664,6 +675,7 @@ get_py3_exceptions() p3imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError"); p3imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError"); p3imp_PyExc_RuntimeError = PyDict_GetItemString(exdict, "RuntimeError"); + p3imp_PyExc_ImportError = PyDict_GetItemString(exdict, "ImportError"); Py_XINCREF(p3imp_PyExc_AttributeError); Py_XINCREF(p3imp_PyExc_IndexError); Py_XINCREF(p3imp_PyExc_KeyError); @@ -671,6 +683,7 @@ get_py3_exceptions() Py_XINCREF(p3imp_PyExc_TypeError); Py_XINCREF(p3imp_PyExc_ValueError); Py_XINCREF(p3imp_PyExc_RuntimeError); + Py_XINCREF(p3imp_PyExc_ImportError); Py_XDECREF(exmod); } #endif /* DYNAMIC_PYTHON3 */ @@ -723,8 +736,13 @@ static PyObject *ListGetattro(PyObject *, PyObject *); static int ListSetattro(PyObject *, PyObject *, PyObject *); static PyObject *FunctionGetattro(PyObject *, PyObject *); +static PyObject *VimPathHook(PyObject *, PyObject *); + static struct PyModuleDef vimmodule; +static PyObject *path_finder; +static PyObject *py_find_module = NULL; + #define PY_CAN_RECURSE /* @@ -1584,13 +1602,71 @@ python3_tabpage_free(tabpage_T *tab) } #endif + static PyObject * +VimPathHook(PyObject *self UNUSED, PyObject *args) +{ + char *path; + + if (PyArg_ParseTuple(args, "s", &path) + && STRCMP(path, vim_special_path) == 0) + { + Py_INCREF(&FinderType); + return (PyObject *) &FinderType; + } + + PyErr_Clear(); + PyErr_SetNone(PyExc_ImportError); + return NULL; +} + + static PyObject * +FinderFindModule(PyObject *cls UNUSED, PyObject *fullname) +{ + PyObject *new_path; + PyObject *r; + + if (!(new_path = Vim_GetPaths(NULL))) + return NULL; + + /* call find_module of the super() class */ + r = PyObject_CallFunctionObjArgs(py_find_module, fullname, new_path, NULL); + + Py_DECREF(new_path); + + return r; +} + +static struct PyMethodDef FinderMethods[] = { + {"find_module", FinderFindModule, METH_CLASS|METH_O, ""}, + {NULL, NULL, 0, NULL} +}; + static PyObject * Py3Init_vim(void) { - PyObject *mod; - /* The special value is removed from sys.path in Python3_Init(). */ static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL}; + PyObject *importlib_machinery; + + if (!(importlib_machinery = PyImport_ImportModule("importlib.machinery"))) + return NULL; + + if (!(path_finder = PyObject_GetAttrString(importlib_machinery, + "PathFinder"))) + { + Py_DECREF(importlib_machinery); + return NULL; + } + + Py_DECREF(importlib_machinery); + + vim_memset(&FinderType, 0, sizeof(FinderObject)); + FinderType.tp_name = "vim.Finder"; + FinderType.tp_basicsize = sizeof(FinderObject); + FinderType.tp_base = (PyTypeObject *) path_finder; + FinderType.tp_flags = Py_TPFLAGS_DEFAULT; + FinderType.tp_doc = "Vim finder class, for use with path hook"; + FinderType.tp_methods = FinderMethods; if (init_types()) return NULL; @@ -1598,14 +1674,16 @@ Py3Init_vim(void) /* Set sys.argv[] to avoid a crash in warn(). */ PySys_SetArgv(1, argv); - mod = PyModule_Create(&vimmodule); - if (mod == NULL) + if ((vim_module = PyModule_Create(&vimmodule)) == NULL) return NULL; - if (populate_module(mod, PyModule_AddObject, PyObject_GetAttrString)) + if (populate_module(vim_module, PyModule_AddObject, PyObject_GetAttrString)) return NULL; - return mod; + if (init_sys_path()) + return NULL; + + return vim_module; } /************************************************************************* diff --git a/src/testdir/test86.in b/src/testdir/test86.in index a50480cd62..f2248c477e 100644 --- a/src/testdir/test86.in +++ b/src/testdir/test86.in @@ -1069,6 +1069,14 @@ ee('vim.current.tabpage = True') ee('vim.current.xxx = True') EOF :" +:" Test import TODO: BROKEN +:"py << EOF +:"vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') +:"from module import dir as d +:"from modulex import ddir +:"cb.append(d + ',' + ddir) +:"EOF +:" :" Test exceptions :fun Exe(e) : execute a:e diff --git a/src/testdir/test87.in b/src/testdir/test87.in index 5ebb4622af..986565e43a 100644 --- a/src/testdir/test87.in +++ b/src/testdir/test87.in @@ -1036,6 +1036,14 @@ ee('vim.current.tabpage = True') ee('vim.current.xxx = True') EOF :" +:" Test import TODO: BROKEN +:"py3 << EOF +:"vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') +:"from module import dir as d +:"from modulex import ddir +:"cb.append(d + ',' + ddir) +:"EOF +:" :" Test exceptions :fun Exe(e) : execute a:e diff --git a/src/version.c b/src/version.c index 1bdba0201f..6be6a6cffe 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1163, /**/ 1162, /**/ From ced8b1e6ee28ed871f63178931e17698e3a1799f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 10 Jun 2013 21:27:29 +0200 Subject: [PATCH 14/24] Added tag v7-3-1163 for changeset 70b1178dec79 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index e8d59b0e16..2b0fb5a057 100644 --- a/.hgtags +++ b/.hgtags @@ -2499,3 +2499,4 @@ bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 60301d4d16827a961019d72a78e811f41326c680 v7-3-1160 ff393592644960783e9a1c7c7959a8cbb0954673 v7-3-1161 b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162 +70b1178dec7919120632cdeee6056e38108356a7 v7-3-1163 From e4a19e5556e0e7f423d3bc8d78d5fa15a26dffd0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 18:40:13 +0200 Subject: [PATCH 15/24] updated for version 7.3.1164 Problem: Can't test what is actually displayed on screen. Solution: Add the screenchar() and screenattr() functions. --- runtime/doc/eval.txt | 17 +++++++++++++ src/eval.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 76 insertions(+) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index f7cc93b723..09eb22dbd5 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1906,6 +1906,8 @@ repeat( {expr}, {count}) String repeat {expr} {count} times resolve( {filename}) String get filename a shortcut points to reverse( {list}) List reverse {list} in-place round( {expr}) Float round off {expr} +screenattr( {row}, {col}) Number attribute at screen position +screenchar( {row}, {col}) Number character at screen position screencol() Number current cursor column screenrow() Number current cursor row search( {pattern} [, {flags} [, {stopline} [, {timeout}]]]) @@ -4890,6 +4892,21 @@ round({expr}) *round()* < -5.0 {only available when compiled with the |+float| feature} +screenattr(row, col) *screenattr()* + Like screenchar(), but return the attribute. This is a rather + arbitrary number that can only be used to compare to the + attribute at other positions. + +screenchar(row, col) *screenchar()* + The result is a Number, which is the character at position + [row, col] on the screen. This works for every possible + screen position, also status lines, window separators and the + command line. The top left position is row one, column one + The character excludes composing characters. For double-byte + encodings it may only be the first byte. + This is mainly to be used for testing. + Returns -1 when row or col is out of range. + screencol() *screencol()* The result is a Number, which is the current screen column of the cursor. The leftmost column has number 1. diff --git a/src/eval.c b/src/eval.c index 38893c795d..81c3ca278a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -654,6 +654,8 @@ static void f_reverse __ARGS((typval_T *argvars, typval_T *rettv)); #ifdef FEAT_FLOAT static void f_round __ARGS((typval_T *argvars, typval_T *rettv)); #endif +static void f_screenattr __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_screenchar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_screencol __ARGS((typval_T *argvars, typval_T *rettv)); static void f_screenrow __ARGS((typval_T *argvars, typval_T *rettv)); static void f_search __ARGS((typval_T *argvars, typval_T *rettv)); @@ -8037,6 +8039,8 @@ static struct fst #ifdef FEAT_FLOAT {"round", 1, 1, f_round}, #endif + {"screenattr", 2, 2, f_screenattr}, + {"screenchar", 2, 2, f_screenchar}, {"screencol", 0, 0, f_screencol}, {"screenrow", 0, 0, f_screenrow}, {"search", 1, 4, f_search}, @@ -15803,6 +15807,59 @@ f_round(argvars, rettv) } #endif +/* + * "screenattr()" function + */ + static void +f_screenattr(argvars, rettv) + typval_T *argvars UNUSED; + typval_T *rettv; +{ + int row; + int col; + int c; + + row = get_tv_number_chk(&argvars[0], NULL) - 1; + col = get_tv_number_chk(&argvars[1], NULL) - 1; + if (row < 0 || row >= screen_Rows + || col < 0 || col >= screen_Columns) + c = -1; + else + c = ScreenAttrs[LineOffset[row] + col]; + rettv->vval.v_number = c; +} + +/* + * "screenchar()" function + */ + static void +f_screenchar(argvars, rettv) + typval_T *argvars UNUSED; + typval_T *rettv; +{ + int row; + int col; + int off; + int c; + + row = get_tv_number_chk(&argvars[0], NULL) - 1; + col = get_tv_number_chk(&argvars[1], NULL) - 1; + if (row < 0 || row >= screen_Rows + || col < 0 || col >= screen_Columns) + c = -1; + else + { + off = LineOffset[row] + col; +#ifdef FEAT_MBYTE + if (enc_utf8 && ScreenLinesUC[off] != 0) + c = ScreenLinesUC[off]; + else +#endif + c = ScreenLines[off]; + } + rettv->vval.v_number = c; +} + /* * "screencol()" function * diff --git a/src/version.c b/src/version.c index 6be6a6cffe..0122a8092a 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1164, /**/ 1163, /**/ From 88c2210334e7b91f4ba06879ed71d35dd1c6d7b1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 18:40:13 +0200 Subject: [PATCH 16/24] Added tag v7-3-1164 for changeset 4db0bf9f1b44 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 2b0fb5a057..b5be68e58f 100644 --- a/.hgtags +++ b/.hgtags @@ -2500,3 +2500,4 @@ bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155 ff393592644960783e9a1c7c7959a8cbb0954673 v7-3-1161 b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162 70b1178dec7919120632cdeee6056e38108356a7 v7-3-1163 +4db0bf9f1b44d1f0d42a1863732dfaef73c9971d v7-3-1164 From 5d884c78e587654bdf016e2fecc2a58aae708a67 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 18:42:36 +0200 Subject: [PATCH 17/24] updated for version 7.3.1165 Problem: HP-UX compiler can't handle zero size array. (Charles Cooper) Solution: Make the array one item big. --- src/regexp.h | 2 +- src/regexp_nfa.c | 4 ++-- src/version.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/regexp.h b/src/regexp.h index 976927e04a..84e8d19b97 100644 --- a/src/regexp.h +++ b/src/regexp.h @@ -101,7 +101,7 @@ typedef struct #endif int nsubexp; /* number of () */ int nstate; - nfa_state_T state[0]; /* actually longer.. */ + nfa_state_T state[1]; /* actually longer.. */ } nfa_regprog_T; /* diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 40208d4092..df82ebf68f 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -6391,8 +6391,8 @@ nfa_regcomp(expr, re_flags) */ post2nfa(postfix, post_ptr, TRUE); - /* Space for compiled regexp */ - prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * nstate; + /* allocate the regprog with space for the compiled regexp */ + prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1); prog = (nfa_regprog_T *)lalloc(prog_size, TRUE); if (prog == NULL) goto fail; diff --git a/src/version.c b/src/version.c index 0122a8092a..8480261a3f 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1165, /**/ 1164, /**/ From 865eb415e594ec0b8015dd297990abfa6fc94e7e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 18:42:36 +0200 Subject: [PATCH 18/24] Added tag v7-3-1165 for changeset 05b8436873d4 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index b5be68e58f..1f0e7e096c 100644 --- a/.hgtags +++ b/.hgtags @@ -2501,3 +2501,4 @@ ff393592644960783e9a1c7c7959a8cbb0954673 v7-3-1161 b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162 70b1178dec7919120632cdeee6056e38108356a7 v7-3-1163 4db0bf9f1b44d1f0d42a1863732dfaef73c9971d v7-3-1164 +05b8436873d48055cbd24f043548092755d77be7 v7-3-1165 From da92dfc155314125048196596dc2d622b3214a9a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 18:48:21 +0200 Subject: [PATCH 19/24] updated for version 7.3.1166 Problem: Loading Python modules is not tested. Solution: Enable commented-out tests, add missing files. (ZyX) --- .hgignore | 1 + Filelist | 3 +++ src/testdir/python2/module.py | 1 + src/testdir/python3/module.py | 1 + src/testdir/pythonx/module.py | 1 + src/testdir/pythonx/modulex.py | 1 + src/testdir/test86.in | 14 +++++++------- src/testdir/test86.ok | 1 + src/testdir/test87.in | 14 +++++++------- src/testdir/test87.ok | 1 + src/version.c | 2 ++ 11 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 src/testdir/python2/module.py create mode 100644 src/testdir/python3/module.py create mode 100644 src/testdir/pythonx/module.py create mode 100644 src/testdir/pythonx/modulex.py diff --git a/.hgignore b/.hgignore index 1d089e292a..8c1deefe79 100644 --- a/.hgignore +++ b/.hgignore @@ -44,6 +44,7 @@ gvimext.lib *.mo *.swp *~ +*.pyc src/po/vim.pot # Generated by "make test" diff --git a/Filelist b/Filelist index ee5ad8f34b..1dea3f168b 100644 --- a/Filelist +++ b/Filelist @@ -84,6 +84,9 @@ SRC_ALL = \ src/testdir/test49.vim \ src/testdir/test60.vim \ src/testdir/test83-tags? \ + src/testdir/python2/*.py \ + src/testdir/python3/*.py \ + src/testdir/pythonx/*.py \ src/proto.h \ src/proto/blowfish.pro \ src/proto/buffer.pro \ diff --git a/src/testdir/python2/module.py b/src/testdir/python2/module.py new file mode 100644 index 0000000000..5f0a6f0a9f --- /dev/null +++ b/src/testdir/python2/module.py @@ -0,0 +1 @@ +dir = '2' diff --git a/src/testdir/python3/module.py b/src/testdir/python3/module.py new file mode 100644 index 0000000000..1ccfb094c0 --- /dev/null +++ b/src/testdir/python3/module.py @@ -0,0 +1 @@ +dir = '3' diff --git a/src/testdir/pythonx/module.py b/src/testdir/pythonx/module.py new file mode 100644 index 0000000000..6bf5a6498f --- /dev/null +++ b/src/testdir/pythonx/module.py @@ -0,0 +1 @@ +dir = 'x' diff --git a/src/testdir/pythonx/modulex.py b/src/testdir/pythonx/modulex.py new file mode 100644 index 0000000000..ec6a706330 --- /dev/null +++ b/src/testdir/pythonx/modulex.py @@ -0,0 +1 @@ +ddir = 'xx' diff --git a/src/testdir/test86.in b/src/testdir/test86.in index f2248c477e..26c7fe2178 100644 --- a/src/testdir/test86.in +++ b/src/testdir/test86.in @@ -1069,13 +1069,13 @@ ee('vim.current.tabpage = True') ee('vim.current.xxx = True') EOF :" -:" Test import TODO: BROKEN -:"py << EOF -:"vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') -:"from module import dir as d -:"from modulex import ddir -:"cb.append(d + ',' + ddir) -:"EOF +:" Test import +py << EOF +vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') +from module import dir as d +from modulex import ddir +cb.append(d + ',' + ddir) +EOF :" :" Test exceptions :fun Exe(e) diff --git a/src/testdir/test86.ok b/src/testdir/test86.ok index 3c22bf63d3..145979ff53 100644 --- a/src/testdir/test86.ok +++ b/src/testdir/test86.ok @@ -1083,6 +1083,7 @@ vim.current.buffer = True:(, TypeError('expected vi vim.current.window = True:(, TypeError('expected vim.Window object',)) vim.current.tabpage = True:(, TypeError('expected vim.TabPage object',)) vim.current.xxx = True:(, AttributeError('xxx',)) +2,xx vim.command("throw 'abc'"):(, error('abc',)) Exe("throw 'def'"):(, error('def',)) vim.eval("Exe('throw ''ghi''')"):(, error('ghi',)) diff --git a/src/testdir/test87.in b/src/testdir/test87.in index 986565e43a..7a3d583590 100644 --- a/src/testdir/test87.in +++ b/src/testdir/test87.in @@ -1036,13 +1036,13 @@ ee('vim.current.tabpage = True') ee('vim.current.xxx = True') EOF :" -:" Test import TODO: BROKEN -:"py3 << EOF -:"vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') -:"from module import dir as d -:"from modulex import ddir -:"cb.append(d + ',' + ddir) -:"EOF +:" Test import +py3 << EOF +vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') +from module import dir as d +from modulex import ddir +cb.append(d + ',' + ddir) +EOF :" :" Test exceptions :fun Exe(e) diff --git a/src/testdir/test87.ok b/src/testdir/test87.ok index 01ff127ec2..31c7df4b66 100644 --- a/src/testdir/test87.ok +++ b/src/testdir/test87.ok @@ -1092,6 +1092,7 @@ vim.current.buffer = True:(, TypeError('expected vim.Buffer o vim.current.window = True:(, TypeError('expected vim.Window object',)) vim.current.tabpage = True:(, TypeError('expected vim.TabPage object',)) vim.current.xxx = True:(, AttributeError('xxx',)) +3,xx vim.command("throw 'abc'"):(, error('abc',)) Exe("throw 'def'"):(, error('def',)) vim.eval("Exe('throw ''ghi''')"):(, error('ghi',)) diff --git a/src/version.c b/src/version.c index 8480261a3f..037b0a4529 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1166, /**/ 1165, /**/ From 7d406c332fc09e763b21e263fd794848c5a4557b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 18:48:22 +0200 Subject: [PATCH 20/24] Added tag v7-3-1166 for changeset d59ff2114733 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 1f0e7e096c..213f074379 100644 --- a/.hgtags +++ b/.hgtags @@ -2502,3 +2502,4 @@ b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162 70b1178dec7919120632cdeee6056e38108356a7 v7-3-1163 4db0bf9f1b44d1f0d42a1863732dfaef73c9971d v7-3-1164 05b8436873d48055cbd24f043548092755d77be7 v7-3-1165 +d59ff2114733a526847ea38d093897f496f73ffc v7-3-1166 From be0607e19d86b96e1b42dcb1b6e0cb87a3115496 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 19:53:45 +0200 Subject: [PATCH 21/24] updated for version 7.3.1167 Problem: Python configure check doesn't reject Python 2 when requesting Python 3. Some systems need -pthreads instead of -pthread. Solution: Adjust configure accordingly. (Andrei Olsen) --- src/auto/configure | 221 +++++++++++++++++--------------- src/configure.in | 307 ++++++++++++++++++++++++--------------------- src/version.c | 2 + 3 files changed, 282 insertions(+), 248 deletions(-) diff --git a/src/auto/configure b/src/auto/configure index 0a8f6f619e..d5819577f4 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -5431,6 +5431,9 @@ $as_echo_n "checking if -pthread should be used... " >&6; } threadsafe_flag="-D_THREAD_SAFE" thread_lib="-pthread" fi + if test "`(uname) 2>/dev/null`" = SunOS; then + threadsafe_flag="-pthreads" + fi fi libs_save_old=$LIBS if test -n "$threadsafe_flag"; then @@ -5502,7 +5505,6 @@ rm -f core conftest.err conftest.$ac_objext \ PYTHON_LIBS= PYTHON_CFLAGS= fi - fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: too old" >&5 @@ -5594,55 +5596,63 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python3_version" >&5 $as_echo "$vi_cv_var_python3_version" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's abiflags" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python is 3.0 or better" >&5 +$as_echo_n "checking Python is 3.0 or better... " >&6; } + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)" + then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yep" >&5 +$as_echo "yep" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's abiflags" >&5 $as_echo_n "checking Python's abiflags... " >&6; } if test "${vi_cv_var_python3_abiflags+set}" = set; then : $as_echo_n "(cached) " >&6 else - vi_cv_var_python3_abiflags= - if ${vi_cv_path_python3} -c \ - "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)" - then - vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \ - "import sys; print(sys.abiflags)"` - fi + vi_cv_var_python3_abiflags= + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)" + then + vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \ + "import sys; print(sys.abiflags)"` + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python3_abiflags" >&5 $as_echo "$vi_cv_var_python3_abiflags" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's install prefix" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's install prefix" >&5 $as_echo_n "checking Python's install prefix... " >&6; } if test "${vi_cv_path_python3_pfx+set}" = set; then : $as_echo_n "(cached) " >&6 else vi_cv_path_python3_pfx=` - ${vi_cv_path_python3} -c \ - "import sys; print(sys.prefix)"` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.prefix)"` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_python3_pfx" >&5 $as_echo "$vi_cv_path_python3_pfx" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's execution prefix" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's execution prefix" >&5 $as_echo_n "checking Python's execution prefix... " >&6; } if test "${vi_cv_path_python3_epfx+set}" = set; then : $as_echo_n "(cached) " >&6 else vi_cv_path_python3_epfx=` - ${vi_cv_path_python3} -c \ - "import sys; print(sys.exec_prefix)"` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.exec_prefix)"` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_python3_epfx" >&5 $as_echo "$vi_cv_path_python3_epfx" >&6; } - if test "${vi_cv_path_python3path+set}" = set; then : + if test "${vi_cv_path_python3path+set}" = set; then : $as_echo_n "(cached) " >&6 else vi_cv_path_python3path=` - unset PYTHONPATH; - ${vi_cv_path_python3} -c \ - "import sys, string; print(':'.join(sys.path))"` + unset PYTHONPATH; + ${vi_cv_path_python3} -c \ + "import sys, string; print(':'.join(sys.path))"` fi @@ -5654,49 +5664,49 @@ if test "${with_python3_config_dir+set}" = set; then : fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's configuration directory" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's configuration directory" >&5 $as_echo_n "checking Python's configuration directory... " >&6; } if test "${vi_cv_path_python3_conf+set}" = set; then : $as_echo_n "(cached) " >&6 else - vi_cv_path_python3_conf= - config_dir="config" - if test "${vi_cv_var_python3_abiflags}" != ""; then - config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" - fi - d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"` - if test -d "$d" && test -f "$d/config.c"; then - vi_cv_path_python3_conf="$d" - else - for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do - for subdir in lib64 lib share; do - d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}" - if test -d "$d" && test -f "$d/config.c"; then - vi_cv_path_python3_conf="$d" - fi - done - done - fi + vi_cv_path_python3_conf= + config_dir="config" + if test "${vi_cv_var_python3_abiflags}" != ""; then + config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + fi + d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"` + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python3_conf="$d" + else + for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do + for subdir in lib64 lib share; do + d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}" + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python3_conf="$d" + fi + done + done + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_python3_conf" >&5 $as_echo "$vi_cv_path_python3_conf" >&6; } - PYTHON3_CONFDIR="${vi_cv_path_python3_conf}" + PYTHON3_CONFDIR="${vi_cv_path_python3_conf}" - if test "X$PYTHON3_CONFDIR" = "X"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: can't find it!" >&5 + if test "X$PYTHON3_CONFDIR" = "X"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: can't find it!" >&5 $as_echo "can't find it!" >&6; } - else + else - if test "${vi_cv_path_python3_plibs+set}" = set; then : + if test "${vi_cv_path_python3_plibs+set}" = set; then : $as_echo_n "(cached) " >&6 else - pwd=`pwd` - tmp_mkf="$pwd/config-PyMake$$" - cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}" + pwd=`pwd` + tmp_mkf="$pwd/config-PyMake$$" + cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}" __: @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'" @echo "python3_LIBS='$(LIBS)'" @@ -5704,45 +5714,48 @@ __: @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'" @echo "python3_INSTSONAME='$(INSTSONAME)'" eof - eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" - rm -f -- "${tmp_mkf}" - vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" - vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}" - vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` - vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` + eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" + rm -f -- "${tmp_mkf}" + vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}" + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` fi - if test "X$python3_DLLLIBRARY" != "X"; then - python3_INSTSONAME="$python3_DLLLIBRARY" - fi - PYTHON3_LIBS="${vi_cv_path_python3_plibs}" - if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" - else - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" - fi - PYTHON3_SRC="if_python3.c" - PYTHON3_OBJ="objects/if_python3.o" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5 -$as_echo_n "checking if -pthread should be used... " >&6; } - threadsafe_flag= - thread_lib= - if test "`(uname) 2>/dev/null`" != Darwin; then - test "$GCC" = yes && threadsafe_flag="-pthread" - if test "`(uname) 2>/dev/null`" = FreeBSD; then - threadsafe_flag="-D_THREAD_SAFE" - thread_lib="-pthread" + if test "X$python3_DLLLIBRARY" != "X"; then + python3_INSTSONAME="$python3_DLLLIBRARY" fi - fi - libs_save_old=$LIBS - if test -n "$threadsafe_flag"; then - cflags_save=$CFLAGS - CFLAGS="$CFLAGS $threadsafe_flag" - LIBS="$LIBS $thread_lib" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + PYTHON3_LIBS="${vi_cv_path_python3_plibs}" + if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + else + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + fi + PYTHON3_SRC="if_python3.c" + PYTHON3_OBJ="objects/if_python3.o" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5 +$as_echo_n "checking if -pthread should be used... " >&6; } + threadsafe_flag= + thread_lib= + if test "`(uname) 2>/dev/null`" != Darwin; then + test "$GCC" = yes && threadsafe_flag="-pthread" + if test "`(uname) 2>/dev/null`" = FreeBSD; then + threadsafe_flag="-D_THREAD_SAFE" + thread_lib="-pthread" + fi + if test "`(uname) 2>/dev/null`" = SunOS; then + threadsafe_flag="-pthreads" + fi + fi + libs_save_old=$LIBS + if test -n "$threadsafe_flag"; then + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $threadsafe_flag" + LIBS="$LIBS $thread_lib" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -5763,19 +5776,19 @@ $as_echo "no" >&6; }; LIBS=$libs_save_old fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS=$cflags_save - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + CFLAGS=$cflags_save + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - fi + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compile and link flags for Python 3 are sane" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compile and link flags for Python 3 are sane" >&5 $as_echo_n "checking if compile and link flags for Python 3 are sane... " >&6; } - cflags_save=$CFLAGS - libs_save=$LIBS - CFLAGS="$CFLAGS $PYTHON3_CFLAGS" - LIBS="$LIBS $PYTHON3_LIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cflags_save=$CFLAGS + libs_save=$LIBS + CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + LIBS="$LIBS $PYTHON3_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -5795,18 +5808,22 @@ $as_echo "no: PYTHON3 DISABLED" >&6; }; python3_ok=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS=$cflags_save - LIBS=$libs_save - if test "$python3_ok" = yes; then - $as_echo "#define FEAT_PYTHON3 1" >>confdefs.h + CFLAGS=$cflags_save + LIBS=$libs_save + if test "$python3_ok" = yes; then + $as_echo "#define FEAT_PYTHON3 1" >>confdefs.h - else - LIBS=$libs_save_old - PYTHON3_SRC= - PYTHON3_OBJ= - PYTHON3_LIBS= - PYTHON3_CFLAGS= + else + LIBS=$libs_save_old + PYTHON3_SRC= + PYTHON3_OBJ= + PYTHON3_LIBS= + PYTHON3_CFLAGS= + fi fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: too old" >&5 +$as_echo "too old" >&6; } fi fi fi @@ -8780,7 +8797,7 @@ if test -z "$SKIP_MOTIF"; then xmheader="Xm/Xm.h" else xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h - Xm/UnhighlightT.h Xm/Notebook.h" + Xm/UnhighlightT.h Xm/Notebook.h" fi for ac_header in $xmheader do : @@ -11777,7 +11794,7 @@ int main () { struct sysinfo sinfo; - sinfo.mem_unit = 1; + sinfo.mem_unit = 1; ; return 0; diff --git a/src/configure.in b/src/configure.in index 17a80367be..1eac2e821a 100644 --- a/src/configure.in +++ b/src/configure.in @@ -986,6 +986,9 @@ eof threadsafe_flag="-D_THREAD_SAFE" thread_lib="-pthread" fi + if test "`(uname) 2>/dev/null`" = SunOS; then + threadsafe_flag="-pthreads" + fi fi libs_save_old=$LIBS if test -n "$threadsafe_flag"; then @@ -1022,7 +1025,6 @@ eof PYTHON_LIBS= PYTHON_CFLAGS= fi - fi else AC_MSG_RESULT(too old) @@ -1058,78 +1060,85 @@ if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'` ]]) - dnl -- get abiflags for python 3.2 or higher (PEP 3149) - AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags, - [ - vi_cv_var_python3_abiflags= - if ${vi_cv_path_python3} -c \ - "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)" - then - vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \ - "import sys; print(sys.abiflags)"` - fi ]) + dnl -- it must be at least version 3 + AC_MSG_CHECKING(Python is 3.0 or better) + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)" + then + AC_MSG_RESULT(yep) - dnl -- find where python3 thinks it was installed - AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx, - [ vi_cv_path_python3_pfx=` - ${vi_cv_path_python3} -c \ - "import sys; print(sys.prefix)"` ]) - - dnl -- and where it thinks it runs - AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx, - [ vi_cv_path_python3_epfx=` - ${vi_cv_path_python3} -c \ - "import sys; print(sys.exec_prefix)"` ]) - - dnl -- python3's internal library path - - AC_CACHE_VAL(vi_cv_path_python3path, - [ vi_cv_path_python3path=` - unset PYTHONPATH; - ${vi_cv_path_python3} -c \ - "import sys, string; print(':'.join(sys.path))"` ]) - - dnl -- where the Python implementation library archives are - - AC_ARG_WITH(python3-config-dir, - [ --with-python3-config-dir=PATH Python's config directory], - [ vi_cv_path_python3_conf="${withval}" ] ) - - AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf, - [ - vi_cv_path_python3_conf= - config_dir="config" - if test "${vi_cv_var_python3_abiflags}" != ""; then - config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" - fi - d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"` - if test -d "$d" && test -f "$d/config.c"; then - vi_cv_path_python3_conf="$d" - else - for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do - for subdir in lib64 lib share; do - d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}" - if test -d "$d" && test -f "$d/config.c"; then - vi_cv_path_python3_conf="$d" - fi - done - done - fi - ]) - - PYTHON3_CONFDIR="${vi_cv_path_python3_conf}" - - if test "X$PYTHON3_CONFDIR" = "X"; then - AC_MSG_RESULT([can't find it!]) - else - - dnl -- we need to examine Python's config/Makefile too - dnl see what the interpreter is built from - AC_CACHE_VAL(vi_cv_path_python3_plibs, + dnl -- get abiflags for python 3.2 or higher (PEP 3149) + AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags, [ - pwd=`pwd` - tmp_mkf="$pwd/config-PyMake$$" - cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}" + vi_cv_var_python3_abiflags= + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)" + then + vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \ + "import sys; print(sys.abiflags)"` + fi ]) + + dnl -- find where python3 thinks it was installed + AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx, + [ vi_cv_path_python3_pfx=` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.prefix)"` ]) + + dnl -- and where it thinks it runs + AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx, + [ vi_cv_path_python3_epfx=` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.exec_prefix)"` ]) + + dnl -- python3's internal library path + + AC_CACHE_VAL(vi_cv_path_python3path, + [ vi_cv_path_python3path=` + unset PYTHONPATH; + ${vi_cv_path_python3} -c \ + "import sys, string; print(':'.join(sys.path))"` ]) + + dnl -- where the Python implementation library archives are + + AC_ARG_WITH(python3-config-dir, + [ --with-python3-config-dir=PATH Python's config directory], + [ vi_cv_path_python3_conf="${withval}" ] ) + + AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf, + [ + vi_cv_path_python3_conf= + config_dir="config" + if test "${vi_cv_var_python3_abiflags}" != ""; then + config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + fi + d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"` + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python3_conf="$d" + else + for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do + for subdir in lib64 lib share; do + d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}" + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python3_conf="$d" + fi + done + done + fi + ]) + + PYTHON3_CONFDIR="${vi_cv_path_python3_conf}" + + if test "X$PYTHON3_CONFDIR" = "X"; then + AC_MSG_RESULT([can't find it!]) + else + + dnl -- we need to examine Python's config/Makefile too + dnl see what the interpreter is built from + AC_CACHE_VAL(vi_cv_path_python3_plibs, + [ + pwd=`pwd` + tmp_mkf="$pwd/config-PyMake$$" + cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}" __: @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'" @echo "python3_LIBS='$(LIBS)'" @@ -1137,81 +1146,87 @@ __: @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'" @echo "python3_INSTSONAME='$(INSTSONAME)'" eof - dnl -- delete the lines from make about Entering/Leaving directory - eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" - rm -f -- "${tmp_mkf}" - vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" - vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}" - dnl remove -ltermcap, it can conflict with an earlier -lncurses - vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` - vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` - ]) - - if test "X$python3_DLLLIBRARY" != "X"; then - python3_INSTSONAME="$python3_DLLLIBRARY" - fi - PYTHON3_LIBS="${vi_cv_path_python3_plibs}" - if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" - else - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" - fi - PYTHON3_SRC="if_python3.c" - PYTHON3_OBJ="objects/if_python3.o" - - dnl On FreeBSD linking with "-pthread" is required to use threads. - dnl _THREAD_SAFE must be used for compiling then. - dnl The "-pthread" is added to $LIBS, so that the following check for - dnl sigaltstack() will look in libc_r (it's there in libc!). - dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC - dnl will then define target-specific defines, e.g., -D_REENTRANT. - dnl Don't do this for Mac OSX, -pthread will generate a warning. - AC_MSG_CHECKING([if -pthread should be used]) - threadsafe_flag= - thread_lib= - dnl if test "x$MACOSX" != "xyes"; then - if test "`(uname) 2>/dev/null`" != Darwin; then - test "$GCC" = yes && threadsafe_flag="-pthread" - if test "`(uname) 2>/dev/null`" = FreeBSD; then - threadsafe_flag="-D_THREAD_SAFE" - thread_lib="-pthread" + dnl -- delete the lines from make about Entering/Leaving directory + eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" + rm -f -- "${tmp_mkf}" + vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}" + dnl remove -ltermcap, it can conflict with an earlier -lncurses + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` + ]) + + if test "X$python3_DLLLIBRARY" != "X"; then + python3_INSTSONAME="$python3_DLLLIBRARY" + fi + PYTHON3_LIBS="${vi_cv_path_python3_plibs}" + if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + else + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + fi + PYTHON3_SRC="if_python3.c" + PYTHON3_OBJ="objects/if_python3.o" + + dnl On FreeBSD linking with "-pthread" is required to use threads. + dnl _THREAD_SAFE must be used for compiling then. + dnl The "-pthread" is added to $LIBS, so that the following check for + dnl sigaltstack() will look in libc_r (it's there in libc!). + dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC + dnl will then define target-specific defines, e.g., -D_REENTRANT. + dnl Don't do this for Mac OSX, -pthread will generate a warning. + AC_MSG_CHECKING([if -pthread should be used]) + threadsafe_flag= + thread_lib= + dnl if test "x$MACOSX" != "xyes"; then + if test "`(uname) 2>/dev/null`" != Darwin; then + test "$GCC" = yes && threadsafe_flag="-pthread" + if test "`(uname) 2>/dev/null`" = FreeBSD; then + threadsafe_flag="-D_THREAD_SAFE" + thread_lib="-pthread" + fi + if test "`(uname) 2>/dev/null`" = SunOS; then + threadsafe_flag="-pthreads" + fi + fi + libs_save_old=$LIBS + if test -n "$threadsafe_flag"; then + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $threadsafe_flag" + LIBS="$LIBS $thread_lib" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag", + AC_MSG_RESULT(no); LIBS=$libs_save_old + ) + CFLAGS=$cflags_save + else + AC_MSG_RESULT(no) + fi + + dnl check that compiling a simple program still works with the flags + dnl added for Python. + AC_MSG_CHECKING([if compile and link flags for Python 3 are sane]) + cflags_save=$CFLAGS + libs_save=$LIBS + CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + LIBS="$LIBS $PYTHON3_LIBS" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); python3_ok=yes, + AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no) + CFLAGS=$cflags_save + LIBS=$libs_save + if test "$python3_ok" = yes; then + AC_DEFINE(FEAT_PYTHON3) + else + LIBS=$libs_save_old + PYTHON3_SRC= + PYTHON3_OBJ= + PYTHON3_LIBS= + PYTHON3_CFLAGS= fi fi - libs_save_old=$LIBS - if test -n "$threadsafe_flag"; then - cflags_save=$CFLAGS - CFLAGS="$CFLAGS $threadsafe_flag" - LIBS="$LIBS $thread_lib" - AC_TRY_LINK(,[ ], - AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag", - AC_MSG_RESULT(no); LIBS=$libs_save_old - ) - CFLAGS=$cflags_save - else - AC_MSG_RESULT(no) - fi - - dnl check that compiling a simple program still works with the flags - dnl added for Python. - AC_MSG_CHECKING([if compile and link flags for Python 3 are sane]) - cflags_save=$CFLAGS - libs_save=$LIBS - CFLAGS="$CFLAGS $PYTHON3_CFLAGS" - LIBS="$LIBS $PYTHON3_LIBS" - AC_TRY_LINK(,[ ], - AC_MSG_RESULT(yes); python3_ok=yes, - AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no) - CFLAGS=$cflags_save - LIBS=$libs_save - if test "$python3_ok" = yes; then - AC_DEFINE(FEAT_PYTHON3) - else - LIBS=$libs_save_old - PYTHON3_SRC= - PYTHON3_OBJ= - PYTHON3_LIBS= - PYTHON3_CFLAGS= - fi + else + AC_MSG_RESULT(too old) fi fi fi @@ -2442,7 +2457,7 @@ if test -z "$SKIP_MOTIF"; then xmheader="Xm/Xm.h" else xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h - Xm/UnhighlightT.h Xm/Notebook.h" + Xm/UnhighlightT.h Xm/Notebook.h" fi AC_CHECK_HEADERS($xmheader) @@ -3356,7 +3371,7 @@ AC_TRY_COMPILE( [#include #include ], [ struct sysinfo sinfo; - sinfo.mem_unit = 1; + sinfo.mem_unit = 1; ], AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT), AC_MSG_RESULT(no)) diff --git a/src/version.c b/src/version.c index 037b0a4529..428843f13e 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1167, /**/ 1166, /**/ From b39ee674d40325c091e4df0d083e43d87a828798 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 19:53:45 +0200 Subject: [PATCH 22/24] Added tag v7-3-1167 for changeset 81dedcd64821 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 213f074379..1bb6ad6e8a 100644 --- a/.hgtags +++ b/.hgtags @@ -2503,3 +2503,4 @@ b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162 4db0bf9f1b44d1f0d42a1863732dfaef73c9971d v7-3-1164 05b8436873d48055cbd24f043548092755d77be7 v7-3-1165 d59ff2114733a526847ea38d093897f496f73ffc v7-3-1166 +81dedcd648216d6b3fc6b967368fef23d8ee1154 v7-3-1167 From 83b7c9573f301416e3307bda430b70f622b97114 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 20:53:28 +0200 Subject: [PATCH 23/24] updated for version 7.3.1168 Problem: Python "sane" configure checks give a warning message. Solution: Use single quotes intead of escaped double quotes. (Ben Fritz) --- src/auto/configure | 8 ++++---- src/configure.in | 8 ++++---- src/version.c | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/auto/configure b/src/auto/configure index d5819577f4..0d1c56304d 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -5410,9 +5410,9 @@ fi fi PYTHON_LIBS="${vi_cv_path_python_plibs}" if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'" else - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'" fi PYTHON_SRC="if_python.c" PYTHON_OBJ="objects/if_python.o" @@ -5729,9 +5729,9 @@ fi fi PYTHON3_LIBS="${vi_cv_path_python3_plibs}" if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'" else - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'" fi PYTHON3_SRC="if_python3.c" PYTHON3_OBJ="objects/if_python3.o" diff --git a/src/configure.in b/src/configure.in index 1eac2e821a..1418f56d2c 100644 --- a/src/configure.in +++ b/src/configure.in @@ -958,9 +958,9 @@ eof fi PYTHON_LIBS="${vi_cv_path_python_plibs}" if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'" else - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'" fi PYTHON_SRC="if_python.c" PYTHON_OBJ="objects/if_python.o" @@ -1161,9 +1161,9 @@ eof fi PYTHON3_LIBS="${vi_cv_path_python3_plibs}" if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'" else - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'" fi PYTHON3_SRC="if_python3.c" PYTHON3_OBJ="objects/if_python3.o" diff --git a/src/version.c b/src/version.c index 428843f13e..8c64fd7261 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1168, /**/ 1167, /**/ From a4341a311651ad6ded4c4ea0378b5b809ca774bb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 11 Jun 2013 20:53:28 +0200 Subject: [PATCH 24/24] Added tag v7-3-1168 for changeset ed47632fd149 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 1bb6ad6e8a..1a12a7530e 100644 --- a/.hgtags +++ b/.hgtags @@ -2504,3 +2504,4 @@ b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162 05b8436873d48055cbd24f043548092755d77be7 v7-3-1165 d59ff2114733a526847ea38d093897f496f73ffc v7-3-1166 81dedcd648216d6b3fc6b967368fef23d8ee1154 v7-3-1167 +ed47632fd1498d50e31ab5b30aac403de3db2496 v7-3-1168