mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Merge branch 'vim'
Conflicts: src/auto/configure src/if_python.c
This commit is contained in:
@@ -44,6 +44,7 @@ gvimext.lib
|
||||
*.mo
|
||||
*.swp
|
||||
*~
|
||||
*.pyc
|
||||
src/po/vim.pot
|
||||
|
||||
# Generated by "make test"
|
||||
|
||||
@@ -2493,3 +2493,15 @@ bc3f4804cf470cec5773d8842743efb760f69102 v7-3-1153
|
||||
6419ee8098c80f0418081c73b790b09c61f13c3a v7-3-1154
|
||||
bf1e6326df1104cabc04b8490f9456dbda901fd2 v7-3-1155
|
||||
8c4324e6f4779ee316361511ff783f6344750be9 v7-3-1156
|
||||
2f1ee97f5f23a5f9e1c572ed4afb50fb79ce7a35 v7-3-1157
|
||||
46077370bc605815f5e41cbfc925120a913acbaa v7-3-1158
|
||||
208a6c04e6b8221c1f5187391d86c5b57e61445b v7-3-1159
|
||||
60301d4d16827a961019d72a78e811f41326c680 v7-3-1160
|
||||
ff393592644960783e9a1c7c7959a8cbb0954673 v7-3-1161
|
||||
b8eabb6a96871321bec8526fa04ba1ff1a96780e v7-3-1162
|
||||
70b1178dec7919120632cdeee6056e38108356a7 v7-3-1163
|
||||
4db0bf9f1b44d1f0d42a1863732dfaef73c9971d v7-3-1164
|
||||
05b8436873d48055cbd24f043548092755d77be7 v7-3-1165
|
||||
d59ff2114733a526847ea38d093897f496f73ffc v7-3-1166
|
||||
81dedcd648216d6b3fc6b967368fef23d8ee1154 v7-3-1167
|
||||
ed47632fd1498d50e31ab5b30aac403de3db2496 v7-3-1168
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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*
|
||||
|
||||
|
||||
Vendored
+124
-107
@@ -5439,10 +5439,10 @@ fi
|
||||
{ echo "$as_me:$LINENO: result: $vi_cv_var_python_version" >&5
|
||||
echo "${ECHO_T}$vi_cv_var_python_version" >&6; }
|
||||
|
||||
{ echo "$as_me:$LINENO: checking Python is 2.2 or better" >&5
|
||||
echo $ECHO_N "checking Python is 2.2 or better... $ECHO_C" >&6; }
|
||||
{ echo "$as_me:$LINENO: checking Python is 2.3 or better" >&5
|
||||
echo $ECHO_N "checking Python is 2.3 or better... $ECHO_C" >&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
|
||||
{ echo "$as_me:$LINENO: result: yep" >&5
|
||||
echo "${ECHO_T}yep" >&6; }
|
||||
@@ -5560,9 +5560,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"
|
||||
@@ -5581,6 +5581,9 @@ echo $ECHO_N "checking if -pthread should be used... $ECHO_C" >&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
|
||||
@@ -5711,7 +5714,6 @@ _ACEOF
|
||||
PYTHON_LIBS=
|
||||
PYTHON_CFLAGS=
|
||||
fi
|
||||
|
||||
fi
|
||||
else
|
||||
{ echo "$as_me:$LINENO: result: too old" >&5
|
||||
@@ -5805,55 +5807,63 @@ fi
|
||||
{ echo "$as_me:$LINENO: result: $vi_cv_var_python3_version" >&5
|
||||
echo "${ECHO_T}$vi_cv_var_python3_version" >&6; }
|
||||
|
||||
{ echo "$as_me:$LINENO: checking Python's abiflags" >&5
|
||||
{ echo "$as_me:$LINENO: checking Python is 3.0 or better" >&5
|
||||
echo $ECHO_N "checking Python is 3.0 or better... $ECHO_C" >&6; }
|
||||
if ${vi_cv_path_python3} -c \
|
||||
"import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
|
||||
then
|
||||
{ echo "$as_me:$LINENO: result: yep" >&5
|
||||
echo "${ECHO_T}yep" >&6; }
|
||||
|
||||
{ echo "$as_me:$LINENO: checking Python's abiflags" >&5
|
||||
echo $ECHO_N "checking Python's abiflags... $ECHO_C" >&6; }
|
||||
if test "${vi_cv_var_python3_abiflags+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&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
|
||||
{ echo "$as_me:$LINENO: result: $vi_cv_var_python3_abiflags" >&5
|
||||
echo "${ECHO_T}$vi_cv_var_python3_abiflags" >&6; }
|
||||
|
||||
{ echo "$as_me:$LINENO: checking Python's install prefix" >&5
|
||||
{ echo "$as_me:$LINENO: checking Python's install prefix" >&5
|
||||
echo $ECHO_N "checking Python's install prefix... $ECHO_C" >&6; }
|
||||
if test "${vi_cv_path_python3_pfx+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&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
|
||||
{ echo "$as_me:$LINENO: result: $vi_cv_path_python3_pfx" >&5
|
||||
echo "${ECHO_T}$vi_cv_path_python3_pfx" >&6; }
|
||||
|
||||
{ echo "$as_me:$LINENO: checking Python's execution prefix" >&5
|
||||
{ echo "$as_me:$LINENO: checking Python's execution prefix" >&5
|
||||
echo $ECHO_N "checking Python's execution prefix... $ECHO_C" >&6; }
|
||||
if test "${vi_cv_path_python3_epfx+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&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
|
||||
{ echo "$as_me:$LINENO: result: $vi_cv_path_python3_epfx" >&5
|
||||
echo "${ECHO_T}$vi_cv_path_python3_epfx" >&6; }
|
||||
|
||||
|
||||
if test "${vi_cv_path_python3path+set}" = set; then
|
||||
if test "${vi_cv_path_python3path+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&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
|
||||
|
||||
|
||||
@@ -5865,49 +5875,49 @@ if test "${with_python3_config_dir+set}" = set; then
|
||||
fi
|
||||
|
||||
|
||||
{ echo "$as_me:$LINENO: checking Python's configuration directory" >&5
|
||||
{ echo "$as_me:$LINENO: checking Python's configuration directory" >&5
|
||||
echo $ECHO_N "checking Python's configuration directory... $ECHO_C" >&6; }
|
||||
if test "${vi_cv_path_python3_conf+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&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
|
||||
{ echo "$as_me:$LINENO: result: $vi_cv_path_python3_conf" >&5
|
||||
echo "${ECHO_T}$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
|
||||
{ echo "$as_me:$LINENO: result: can't find it!" >&5
|
||||
if test "X$PYTHON3_CONFDIR" = "X"; then
|
||||
{ echo "$as_me:$LINENO: result: can't find it!" >&5
|
||||
echo "${ECHO_T}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
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&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)'"
|
||||
@@ -5915,45 +5925,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"
|
||||
|
||||
{ echo "$as_me:$LINENO: checking if -pthread should be used" >&5
|
||||
echo $ECHO_N "checking if -pthread should be used... $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF
|
||||
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"
|
||||
|
||||
{ echo "$as_me:$LINENO: checking if -pthread should be used" >&5
|
||||
echo $ECHO_N "checking if -pthread should be used... $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
@@ -5999,19 +6012,19 @@ fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
CFLAGS=$cflags_save
|
||||
else
|
||||
{ echo "$as_me:$LINENO: result: no" >&5
|
||||
CFLAGS=$cflags_save
|
||||
else
|
||||
{ echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6; }
|
||||
fi
|
||||
fi
|
||||
|
||||
{ echo "$as_me:$LINENO: checking if compile and link flags for Python 3 are sane" >&5
|
||||
{ echo "$as_me:$LINENO: checking if compile and link flags for Python 3 are sane" >&5
|
||||
echo $ECHO_N "checking if compile and link flags for Python 3 are sane... $ECHO_C" >&6; }
|
||||
cflags_save=$CFLAGS
|
||||
libs_save=$LIBS
|
||||
CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
|
||||
LIBS="$LIBS $PYTHON3_LIBS"
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
cflags_save=$CFLAGS
|
||||
libs_save=$LIBS
|
||||
CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
|
||||
LIBS="$LIBS $PYTHON3_LIBS"
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
@@ -6056,20 +6069,24 @@ fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
CFLAGS=$cflags_save
|
||||
LIBS=$libs_save
|
||||
if test "$python3_ok" = yes; then
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
CFLAGS=$cflags_save
|
||||
LIBS=$libs_save
|
||||
if test "$python3_ok" = yes; then
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define FEAT_PYTHON3 1
|
||||
_ACEOF
|
||||
|
||||
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
|
||||
{ echo "$as_me:$LINENO: result: too old" >&5
|
||||
echo "${ECHO_T}too old" >&6; }
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -10535,7 +10552,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
|
||||
@@ -16319,7 +16336,7 @@ int
|
||||
main ()
|
||||
{
|
||||
struct sysinfo sinfo;
|
||||
sinfo.mem_unit = 1;
|
||||
sinfo.mem_unit = 1;
|
||||
|
||||
;
|
||||
return 0;
|
||||
|
||||
+166
-151
@@ -887,10 +887,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)
|
||||
|
||||
@@ -982,9 +982,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"
|
||||
@@ -1010,6 +1010,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
|
||||
@@ -1056,7 +1059,6 @@ eof
|
||||
PYTHON_LIBS=
|
||||
PYTHON_CFLAGS=
|
||||
fi
|
||||
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT(too old)
|
||||
@@ -1092,78 +1094,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)'"
|
||||
@@ -1171,81 +1180,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
|
||||
@@ -2502,7 +2517,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)
|
||||
|
||||
@@ -3416,7 +3431,7 @@ AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <sys/sysinfo.h>],
|
||||
[ 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))
|
||||
|
||||
+69
-2
@@ -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));
|
||||
@@ -8038,6 +8040,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},
|
||||
@@ -15802,6 +15806,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
|
||||
*/
|
||||
@@ -15814,13 +15829,65 @@ 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;
|
||||
}
|
||||
#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
|
||||
*
|
||||
|
||||
+14
-4
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -2810,6 +2810,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)
|
||||
@@ -2841,7 +2845,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\""),
|
||||
@@ -2855,7 +2859,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);
|
||||
@@ -2894,7 +2904,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);
|
||||
|
||||
+288
-38
@@ -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
|
||||
@@ -375,8 +379,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())
|
||||
{
|
||||
@@ -777,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 <Tab> 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 <Tab> 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}
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1319,12 +1474,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 +1958,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 +3309,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,
|
||||
@@ -5050,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)
|
||||
{
|
||||
@@ -5295,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;
|
||||
}
|
||||
|
||||
@@ -5346,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 *);
|
||||
@@ -5366,8 +5591,9 @@ 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;
|
||||
PyObject *attr;
|
||||
|
||||
for (i = 0; i < (int)(sizeof(numeric_constants)
|
||||
/ sizeof(struct numeric_constant));
|
||||
@@ -5395,28 +5621,52 @@ 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 (!(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(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 (!(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();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
+139
-20
@@ -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 */
|
||||
|
||||
@@ -53,12 +53,18 @@
|
||||
# undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */
|
||||
#endif
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
#ifdef FEAT_GUI_MACVIM
|
||||
# include <Python/Python.h>
|
||||
#else
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#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 <CodeFragments.h>
|
||||
@@ -66,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
|
||||
|
||||
#define PyBytes_FromString PyString_FromString
|
||||
#define PyBytes_Check PyString_Check
|
||||
|
||||
@@ -170,6 +172,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
|
||||
@@ -186,6 +189,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
|
||||
@@ -212,6 +216,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
|
||||
@@ -234,6 +239,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)
|
||||
@@ -306,6 +312,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);
|
||||
@@ -321,7 +328,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 *);
|
||||
@@ -346,6 +354,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 *);
|
||||
@@ -366,6 +375,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 +441,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 +450,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 +483,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 +500,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},
|
||||
@@ -511,6 +525,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},
|
||||
@@ -531,6 +546,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},
|
||||
@@ -705,6 +721,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);
|
||||
@@ -712,6 +729,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 */
|
||||
@@ -734,6 +752,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
|
||||
@@ -1358,21 +1380,112 @@ python_tabpage_free(tabpage_T *tab)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
add_object(PyObject *dict, const char *name, PyObject *object)
|
||||
static PyObject *
|
||||
LoaderLoadModule(PyObject *self, PyObject *args)
|
||||
{
|
||||
if (PyDict_SetItemString(dict, (char *) name, object))
|
||||
return -1;
|
||||
Py_DECREF(object);
|
||||
return 0;
|
||||
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;
|
||||
PyObject *dict;
|
||||
|
||||
/* The special value is removed from sys.path in Python_Init(). */
|
||||
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
|
||||
|
||||
@@ -1382,11 +1495,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);
|
||||
dict = PyModule_GetDict(mod);
|
||||
vim_module = Py_InitModule4("vim", VimMethods, (char *)NULL,
|
||||
(PyObject *)NULL, PYTHON_API_VERSION);
|
||||
|
||||
return populate_module(dict, add_object, PyDict_GetItemString);
|
||||
if (populate_module(vim_module, PyModule_AddObject,
|
||||
PyObject_GetAttrString))
|
||||
return -1;
|
||||
|
||||
if (init_sys_path())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
+90
-13
@@ -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 <Python.h>
|
||||
|
||||
#if defined(MACOS) && !defined(MACOS_X_UNIX)
|
||||
# include "macglue.h"
|
||||
# include <CodeFragments.h>
|
||||
@@ -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"
|
||||
@@ -135,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
|
||||
@@ -144,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
|
||||
@@ -178,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
|
||||
@@ -269,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 *);
|
||||
@@ -285,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 *);
|
||||
@@ -394,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
|
||||
@@ -402,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.
|
||||
@@ -429,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},
|
||||
@@ -442,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},
|
||||
@@ -665,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);
|
||||
@@ -672,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 */
|
||||
@@ -724,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
|
||||
|
||||
/*
|
||||
@@ -1585,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;
|
||||
@@ -1599,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;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
+4
-3
@@ -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));
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
/*
|
||||
|
||||
+43
-18
@@ -4587,6 +4587,7 @@ static long find_match_text __ARGS((colnr_T startcol, int regstart, char_u *matc
|
||||
|
||||
/*
|
||||
* Estimate the chance of a match with "state" failing.
|
||||
* empty match: 0
|
||||
* NFA_ANY: 1
|
||||
* specific character: 99
|
||||
*/
|
||||
@@ -4616,7 +4617,9 @@ failure_chance(state, depth)
|
||||
case NFA_ANY:
|
||||
/* matches anything, unlikely to fail */
|
||||
return 1;
|
||||
|
||||
case NFA_MATCH:
|
||||
case NFA_MCLOSE:
|
||||
/* empty match works always */
|
||||
return 0;
|
||||
|
||||
@@ -4664,7 +4667,6 @@ failure_chance(state, depth)
|
||||
case NFA_ZCLOSE9:
|
||||
#endif
|
||||
case NFA_NOPEN:
|
||||
case NFA_MCLOSE:
|
||||
case NFA_MCLOSE1:
|
||||
case NFA_MCLOSE2:
|
||||
case NFA_MCLOSE3:
|
||||
@@ -5095,23 +5097,46 @@ nfa_regmatch(prog, start, submatch, m)
|
||||
case NFA_START_INVISIBLE_BEFORE:
|
||||
case NFA_START_INVISIBLE_BEFORE_NEG:
|
||||
{
|
||||
int cout = t->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 \@<!, these are expensive.
|
||||
* Otherwise first do the one that has the highest chance
|
||||
* of failing. */
|
||||
if ((cout >= 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
|
||||
@@ -6366,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;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
dir = '2'
|
||||
@@ -0,0 +1 @@
|
||||
dir = '3'
|
||||
@@ -0,0 +1 @@
|
||||
dir = 'x'
|
||||
@@ -0,0 +1 @@
|
||||
ddir = 'xx'
|
||||
@@ -392,6 +392,7 @@ STARTTEST
|
||||
:call add(tl, [2, '\v\C%(<Last Changed:\s+)@<=.*$', '" Last Changed: 1970', '1970'])
|
||||
:call add(tl, [2, '\(foo\)\@<=\>', 'foobar'])
|
||||
:call add(tl, [2, '\(foo\)\@<=\>', 'barfoo', '', 'foo'])
|
||||
:call add(tl, [2, '\(foo\)\@<=.*', 'foobar', 'bar', 'foo'])
|
||||
:"
|
||||
:""""" \@>
|
||||
:call add(tl, [2, '\(a*\)\@>a', 'aaaa'])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1069,6 +1069,14 @@ ee('vim.current.tabpage = True')
|
||||
ee('vim.current.xxx = True')
|
||||
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)
|
||||
: execute a:e
|
||||
|
||||
@@ -1083,6 +1083,7 @@ vim.current.buffer = True:(<type 'exceptions.TypeError'>, TypeError('expected vi
|
||||
vim.current.window = True:(<type 'exceptions.TypeError'>, TypeError('expected vim.Window object',))
|
||||
vim.current.tabpage = True:(<type 'exceptions.TypeError'>, TypeError('expected vim.TabPage object',))
|
||||
vim.current.xxx = True:(<type 'exceptions.AttributeError'>, AttributeError('xxx',))
|
||||
2,xx
|
||||
vim.command("throw 'abc'"):(<class 'vim.error'>, error('abc',))
|
||||
Exe("throw 'def'"):(<class 'vim.error'>, error('def',))
|
||||
vim.eval("Exe('throw ''ghi''')"):(<class 'vim.error'>, error('ghi',))
|
||||
|
||||
@@ -1036,6 +1036,14 @@ ee('vim.current.tabpage = True')
|
||||
ee('vim.current.xxx = True')
|
||||
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)
|
||||
: execute a:e
|
||||
|
||||
@@ -1092,6 +1092,7 @@ vim.current.buffer = True:(<class 'TypeError'>, TypeError('expected vim.Buffer o
|
||||
vim.current.window = True:(<class 'TypeError'>, TypeError('expected vim.Window object',))
|
||||
vim.current.tabpage = True:(<class 'TypeError'>, TypeError('expected vim.TabPage object',))
|
||||
vim.current.xxx = True:(<class 'AttributeError'>, AttributeError('xxx',))
|
||||
3,xx
|
||||
vim.command("throw 'abc'"):(<class 'vim.error'>, error('abc',))
|
||||
Exe("throw 'def'"):(<class 'vim.error'>, error('def',))
|
||||
vim.eval("Exe('throw ''ghi''')"):(<class 'vim.error'>, error('ghi',))
|
||||
|
||||
+4
-2
@@ -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:
|
||||
|
||||
@@ -743,6 +743,30 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1168,
|
||||
/**/
|
||||
1167,
|
||||
/**/
|
||||
1166,
|
||||
/**/
|
||||
1165,
|
||||
/**/
|
||||
1164,
|
||||
/**/
|
||||
1163,
|
||||
/**/
|
||||
1162,
|
||||
/**/
|
||||
1161,
|
||||
/**/
|
||||
1160,
|
||||
/**/
|
||||
1159,
|
||||
/**/
|
||||
1158,
|
||||
/**/
|
||||
1157,
|
||||
/**/
|
||||
1156,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user