changeset 10:13f0cd4d1b23 r200808

*** empty log message ***
author axmo
date Fri, 29 Aug 2008 22:14:24 +0900
parents 6a13985590e6
children bb64d8561b7b
files src/Makefile src/auto/config.h src/auto/config.mk src/ex_docmd.c src/main.c src/memline.c src/misc1.c src/os_unix.c src/ui.c
diffstat 9 files changed, 1104 insertions(+), 141 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/Makefile	Fri Aug 29 22:14:24 2008 +0900
@@ -1244,6 +1244,11 @@
 ALL_GUI_SRC  = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_xmdlg.c gui_xmebw.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c
 ALL_GUI_PRO  = gui.pro gui_gtk.pro gui_motif.pro gui_xmdlg.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w16.pro gui_w32.pro gui_photon.pro
 
+# REMOTE EDITOR files
+REDITOR_SRC = reditor.c
+REDITOR_OBJ = objects/reditor.o
+
+
 # }}}
 
 ### Command to create dependencies based on #include "..."
@@ -1414,7 +1419,8 @@
 
 SRC =	$(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(MZSCHEME_SRC) \
 	$(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) $(RUBY_SRC) \
-	$(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC)
+	$(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC) \
+	$(REDITOR_SRC)
 
 TAGS_SRC = *.c *.cpp if_perl.xs
 
@@ -1490,7 +1496,9 @@
 	$(OS_EXTRA_OBJ) \
 	$(WORKSHOP_OBJ) \
 	$(NETBEANS_OBJ) \
-	$(WSDEBUG_OBJ)
+	$(WSDEBUG_OBJ) \
+	$(REDITOR_OBJ)
+
 
 PRO_AUTO = \
 	buffer.pro \
@@ -2558,6 +2566,10 @@
 objects/netbeans.o: netbeans.c
 	$(CCC) -o $@ netbeans.c
 
+objects/reditor.o: reditor.c
+	$(CCC) -o $@ reditor.c
+
+
 Makefile:
 	@echo The name of the makefile MUST be "Makefile" (with capital M)!!!!
 
@@ -2682,7 +2694,7 @@
 objects/ex_docmd.o: ex_docmd.c vim.h auto/config.h feature.h os_unix.h \
   auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
   regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+  globals.h farsi.h arabic.h reditor.h
 objects/ex_eval.o: ex_eval.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
@@ -2722,7 +2734,7 @@
 objects/main.o: main.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h farsi.c arabic.c
+  arabic.h farsi.c arabic.c reditor.h
 objects/mark.o: mark.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
@@ -2734,7 +2746,7 @@
 objects/memline.o: memline.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+  arabic.h reditor.h
 objects/menu.o: menu.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
@@ -2746,7 +2758,7 @@
 objects/misc1.o: misc1.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h version.h
+  arabic.h version.h reditor.h
 objects/misc2.o: misc2.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
@@ -2773,7 +2785,7 @@
 objects/os_unix.o: os_unix.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h os_unixx.h
+  arabic.h os_unixx.h reditor.h
 objects/pathdef.o: auto/pathdef.c ./vim.h ./auto/config.h ./feature.h ./os_unix.h \
   ./auto/osdef.h ./ascii.h ./keymap.h ./term.h ./macros.h ./option.h \
   ./structs.h ./regexp.h ./gui.h ./gui_beval.h proto/gui_beval.pro \
@@ -2815,7 +2827,7 @@
   arabic.h
 objects/ui.o: ui.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h \
   keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
-  proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
+  proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h reditor.h
 objects/undo.o: undo.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
--- a/src/auto/config.h	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/auto/config.h	Fri Aug 29 22:14:24 2008 +0900
@@ -0,0 +1,381 @@
+/* auto/config.h.  Generated from config.h.in by configure.  */
+/*
+ * config.h.in.  Generated automatically from configure.in by autoheader, and
+ * manually changed after that.
+ */
+
+/* Define if we have EBCDIC code */
+/* #undef EBCDIC */
+
+/* Define unless no X support found */
+/* #undef HAVE_X11 */
+
+/* Define when terminfo support found */
+#define TERMINFO 1
+
+/* Define when termcap.h contains ospeed */
+#define HAVE_OSPEED 1
+
+/* Define when ospeed can be extern */
+/* #undef OSPEED_EXTERN */
+
+/* Define when termcap.h contains UP, BC and PC */
+#define HAVE_UP_BC_PC 1
+
+/* Define when UP, BC and PC can be extern */
+/* #undef UP_BC_PC_EXTERN */
+
+/* Define when termcap.h defines outfuntype */
+/* #undef HAVE_OUTFUNTYPE */
+
+/* Define when __DATE__ " " __TIME__ can be used */
+#define HAVE_DATE_TIME 1
+
+/* defined always when using configure */
+#define UNIX 1
+
+/* Defined to the size of an int */
+#define SIZEOF_INT 4
+
+/*
+ * If we cannot trust one of the following from the libraries, we use our
+ * own safe but probably slower vim_memmove().
+ */
+/* #undef USEBCOPY */
+#define USEMEMMOVE 1
+/* #undef USEMEMCPY */
+
+/* Define when "man -s 2" is to be used */
+#define USEMAN_S 1
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef mode_t */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef off_t */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef pid_t */
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef size_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef uid_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef gid_t */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef ino_t */
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef dev_t */
+
+/* Define to `unsigned long' if <sys/types.h> doesn't define.  */
+/* #undef rlim_t */
+
+/* Define to `struct sigaltstack' if <signal.h> doesn't define.  */
+/* #undef stack_t */
+
+/* Define if stack_t has the ss_base field. */
+/* #undef HAVE_SS_BASE */
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define if you can safely include both <sys/time.h> and <sys/select.h>.  */
+#define SYS_SELECT_WITH_SYS_TIME 1
+
+/* Define if you have /dev/ptc */
+/* #undef HAVE_DEV_PTC */
+
+/* Define if you have Sys4 ptys */
+#define HAVE_SVR4_PTYS 1
+
+/* Define to range of pty names to try */
+#define PTYRANGE0 "pqrstuvw"
+#define PTYRANGE1 "0123456789abcdef"
+
+/* Define mode for pty */
+/* #undef PTYMODE */
+
+/* Define group for pty */
+/* #undef PTYGROUP */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* Define as the command at the end of signal handlers ("" or "return 0;").  */
+#define SIGRETURN return
+
+/* Define if struct sigcontext is present */
+#define HAVE_SIGCONTEXT 1
+
+/* Define if touuper/tolower only work on lower/upercase characters */
+/* #undef BROKEN_TOUPPER */
+
+/* Define if stat() ignores a trailing slash */
+/* #undef STAT_IGNORES_SLASH */
+
+/* Define if tgetstr() has a second argument that is (char *) */
+/* #undef TGETSTR_CHAR_P */
+
+/* Define if tgetent() returns zero for an error */
+/* #undef TGETENT_ZERO_ERR */
+
+/* Define if the getcwd() function should not be used.  */
+/* #undef BAD_GETCWD */
+
+/* Define if you the function: */
+#define HAVE_BCMP 1
+#define HAVE_FCHDIR 1
+#define HAVE_FCHOWN 1
+#define HAVE_FSEEKO 1
+#define HAVE_FSYNC 1
+#define HAVE_FTELLO 1
+#define HAVE_GETCWD 1
+/* #undef HAVE_GETPSEUDOTTY */
+#define HAVE_GETPWNAM 1
+#define HAVE_GETPWUID 1
+#define HAVE_GETRLIMIT 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETWD 1
+#define HAVE_ICONV 1
+#define HAVE_NL_LANGINFO_CODESET 1
+#define HAVE_LSTAT 1
+#define HAVE_MEMCMP 1
+#define HAVE_MEMSET 1
+#define HAVE_NANOSLEEP 1
+#define HAVE_OPENDIR 1
+#define HAVE_FLOAT_FUNCS 1
+#define HAVE_PUTENV 1
+#define HAVE_QSORT 1
+#define HAVE_READLINK 1
+#define HAVE_RENAME 1
+#define HAVE_SELECT 1
+/* #undef HAVE_SELINUX */
+#define HAVE_SETENV 1
+#define HAVE_SETPGID 1
+#define HAVE_SETSID 1
+#define HAVE_SIGACTION 1
+#define HAVE_SIGALTSTACK 1
+#define HAVE_SIGSET 1
+#define HAVE_SIGSETJMP 1
+/* #undef HAVE_SIGSTACK */
+#define HAVE_SIGVEC 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRFTIME 1
+/* #undef HAVE_STRICMP */
+#define HAVE_STRNCASECMP 1
+/* #undef HAVE_STRNICMP */
+#define HAVE_STRPBRK 1
+#define HAVE_STRTOL 1
+#define HAVE_ST_BLKSIZE 1
+/* #undef HAVE_SYSCONF */
+#define HAVE_SYSCTL 1
+/* #undef HAVE_SYSINFO */
+/* #undef HAVE_SYSINFO_MEM_UNIT */
+#define HAVE_TGETENT 1
+#define HAVE_TOWLOWER 1
+#define HAVE_TOWUPPER 1
+#define HAVE_ISWUPPER 1
+#define HAVE_USLEEP 1
+#define HAVE_UTIME 1
+/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */
+
+/* Define if you do not have utime(), but do have the utimes() function. */
+#define HAVE_UTIMES 1
+
+/* Define if you have the header file: */
+#define HAVE_DIRENT_H 1
+#define HAVE_ERRNO_H 1
+#define HAVE_FCNTL_H 1
+/* #undef HAVE_FRAME_H */
+#define HAVE_ICONV_H 1
+#define HAVE_LANGINFO_H 1
+#define HAVE_LIBC_H 1
+#define HAVE_LIBGEN_H 1
+/* #undef HAVE_LIBINTL_H */
+#define HAVE_LOCALE_H 1
+#define HAVE_MATH_H 1
+/* #undef HAVE_NDIR_H */
+#define HAVE_POLL_H 1
+/* #undef HAVE_PTHREAD_NP_H */
+#define HAVE_PWD_H 1
+#define HAVE_SETJMP_H 1
+#define HAVE_SGTTY_H 1
+#define HAVE_STRINGS_H 1
+/* #undef HAVE_STROPTS_H */
+/* #undef HAVE_SYS_ACCESS_H */
+#define HAVE_SYS_ACL_H 1
+/* #undef HAVE_SYS_DIR_H */
+#define HAVE_SYS_IOCTL_H 1
+/* #undef HAVE_SYS_NDIR_H */
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_POLL_H 1
+/* #undef HAVE_SYS_PTEM_H */
+#define HAVE_SYS_RESOURCE_H 1
+#define HAVE_SYS_SELECT_H 1
+/* #undef HAVE_SYS_STATFS_H */
+/* #undef HAVE_SYS_STREAM_H */
+#define HAVE_SYS_SYSCTL_H 1
+/* #undef HAVE_SYS_SYSINFO_H */
+/* #undef HAVE_SYS_SYSTEMINFO_H */
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_UTSNAME_H 1
+#define HAVE_WCHAR_H 1
+#define HAVE_WCTYPE_H 1
+#define HAVE_TERMCAP_H 1
+#define HAVE_TERMIOS_H 1
+/* #undef HAVE_TERMIO_H */
+#define HAVE_UNISTD_H 1
+/* #undef HAVE_UTIL_DEBUG_H */
+/* #undef HAVE_UTIL_MSGI18N_H */
+#define HAVE_UTIME_H 1
+/* #undef HAVE_X11_SUNKEYSYM_H */
+/* #undef HAVE_XM_XM_H */
+/* #undef HAVE_XM_XPMP_H */
+/* #undef HAVE_XM_TRAITP_H */
+/* #undef HAVE_XM_MANAGER_H */
+/* #undef HAVE_XM_UNHIGHLIGHTT_H */
+/* #undef HAVE_XM_JOINSIDET_H */
+/* #undef HAVE_XM_NOTEBOOK_H */
+/* #undef HAVE_X11_XPM_H */
+/* #undef HAVE_X11_XMU_EDITRES_H */
+#define HAVE_X11_SM_SMLIB_H 1
+
+/* Define to the type of the XpmAttributes type. */
+/* #undef XPMATTRIBUTES_TYPE */
+
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
+#define HAVE_SYS_WAIT_H 1
+
+/* Define if you have a <sys/wait.h> that is not POSIX.1 compatible. */
+/* #undef HAVE_UNION_WAIT */
+
+/* This is currently unused in vim: */
+/* Define if you have the ANSI C header files. */
+/* #undef STDC_HEADERS */
+
+/* instead, we check a few STDC things ourselves */
+#define HAVE_STDARG_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+
+/* Define if strings.h cannot be included when strings.h already is */
+#define NO_STRINGS_WITH_STRING_H 1
+
+/* Define if you want tiny features. */
+/* #undef FEAT_TINY */
+
+/* Define if you want small features. */
+/* #undef FEAT_SMALL */
+
+/* Define if you want normal features. */
+#define FEAT_NORMAL 1
+
+/* Define if you want big features. */
+/* #undef FEAT_BIG */
+
+/* Define if you want huge features. */
+/* #undef FEAT_HUGE */
+
+/* Define if you want to include the MzScheme interpreter. */
+/* #undef FEAT_MZSCHEME */
+
+/* Define if you want to include the Perl interpreter. */
+/* #undef FEAT_PERL */
+
+/* Define if you want to include the Python interpreter. */
+/* #undef FEAT_PYTHON */
+
+/* Define if you want to include the Ruby interpreter. */
+/* #undef FEAT_RUBY */
+
+/* Define if you want to include the Tcl interpreter. */
+/* #undef FEAT_TCL */
+
+/* Define if you want to include the Sniff interface. */
+/* #undef FEAT_SNIFF */
+
+/* Define if you want to add support for ACL */
+#define HAVE_POSIX_ACL 1
+/* #undef HAVE_SOLARIS_ACL */
+/* #undef HAVE_AIX_ACL */
+
+/* Define if you want to add support of GPM (Linux console mouse daemon) */
+/* #undef HAVE_GPM */
+
+/* Define if you want to add support of sysmouse (*BSD console mouse) */
+/* #undef HAVE_SYSMOUSE */
+
+/* Define if you want to include the Cscope interface. */
+/* #undef FEAT_CSCOPE */
+
+/* Define if you want to include multibyte support. */
+/* #undef FEAT_MBYTE */
+
+/* Define if you want to include fontset support. */
+/* #undef FEAT_XFONTSET */
+
+/* Define if you want to include XIM support. */
+/* #undef FEAT_XIM */
+
+/* Define if you want to include Hangul input support. */
+/* #undef FEAT_HANGULIN */
+
+/* Define if you use GTK and want GNOME support. */
+/* #undef FEAT_GUI_GNOME */
+
+/* Define if you use KDE and want KDE Toolbar support. */
+/* #undef FEAT_KDETOOLBAR */
+
+/* Define if GTK+ 2 is available. */
+/* #undef HAVE_GTK2 */
+
+/* Define if GTK+ multihead support is available (requires GTK+ >= 2.1.1). */
+/* #undef HAVE_GTK_MULTIHEAD */
+
+/* Define if your X has own locale library */
+/* #undef X_LOCALE */
+
+/* Define if we have dlfcn.h. */
+#define HAVE_DLFCN_H 1
+
+/* Define if there is a working gettext(). */
+/* #undef HAVE_GETTEXT */
+
+/* Define if _nl_msg_cat_cntr is present. */
+/* #undef HAVE_NL_MSG_CAT_CNTR */
+
+/* Define if we have dlopen() */
+#define HAVE_DLOPEN 1
+
+/* Define if we have dlsym() */
+#define HAVE_DLSYM 1
+
+/* Define if we have dl.h. */
+/* #undef HAVE_DL_H */
+
+/* Define if we have shl_load() */
+/* #undef HAVE_SHL_LOAD */
+
+/* Define if you want to include Sun Visual Workshop support. */
+/* #undef FEAT_SUN_WORKSHOP */
+
+/* Define if you want to include NetBeans integration. */
+#define FEAT_NETBEANS_INTG 1
+
+/* Define default global runtime path */
+/* #undef RUNTIME_GLOBAL */
+
+/* Define name of who modified a released Vim */
+/* #undef MODIFIED_BY */
+
+/* Define if you want XSMP interaction as well as vanilla swapfile safety */
+#define USE_XSMP_INTERACT 1
--- a/src/auto/config.mk	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/auto/config.mk	Fri Aug 29 22:14:24 2008 +0900
@@ -1,5 +1,151 @@
-the first targets to make vim are: scratch config myself
-srcdir = .
-VIMNAME = vim
-EXNAME = ex
-VIEWNAME = view
+#
+# config.mk.in -- autoconf template for Vim on Unix		vim:ts=8:sw=8:
+#
+# DO NOT EDIT config.mk!!  It will be overwritten by configure.
+# Edit Makefile and run "make" or run ./configure with other arguments.
+#
+# Configure does not edit the makefile directly. This method is not the
+# standard use of GNU autoconf, but it has two advantages:
+#   a) The user can override every choice made by configure.
+#   b) Modifications to the makefile are not lost when configure is run.
+#
+# I hope this is worth being nonstandard. jw.
+
+
+
+VIMNAME		= Vim
+EXNAME		= ex
+VIEWNAME	= view
+
+CC		= gcc
+DEFS		= -DHAVE_CONFIG_H
+CFLAGS		= -g -O
+CPPFLAGS	=  -DMACOS_X_UNIX -no-cpp-precomp -I/Developer/Headers/FlatCarbon
+srcdir		= .
+
+LDFLAGS		=  -L/usr/local/lib
+LIBS		= -lm -lncurses  -liconv
+TAGPRG		= ctags -t
+
+CPP		= gcc -E
+CPP_MM		= M
+DEPEND_CFLAGS_FILTER = | sed 's+-I */+-isystem /+g'
+X_CFLAGS	= 
+X_LIBS_DIR	= 
+X_PRE_LIBS	= 
+X_EXTRA_LIBS	= 
+X_LIBS		= 
+
+MZSCHEME_LIBS	= 
+MZSCHEME_SRC	= 
+MZSCHEME_OBJ	= 
+MZSCHEME_CFLAGS	= 
+MZSCHEME_PRO	= 
+
+PERL		= 
+PERLLIB		= 
+PERL_LIBS	= 
+SHRPENV		= 
+PERL_SRC	= 
+PERL_OBJ	= 
+PERL_PRO	= 
+PERL_CFLAGS	= 
+
+PYTHON_SRC	= 
+PYTHON_OBJ	= 
+PYTHON_CFLAGS	= 
+PYTHON_LIBS	= 
+PYTHON_CONFDIR	= 
+PYTHON_GETPATH_CFLAGS = 
+
+TCL		= 
+TCL_SRC		= 
+TCL_OBJ		= 
+TCL_PRO		= 
+TCL_CFLAGS	= 
+TCL_LIBS	= 
+
+HANGULIN_SRC	= 
+HANGULIN_OBJ	= 
+
+WORKSHOP_SRC	= 
+WORKSHOP_OBJ	= 
+
+NETBEANS_SRC	= netbeans.c
+NETBEANS_OBJ	= objects/netbeans.o
+
+RUBY		= 
+RUBY_SRC	= 
+RUBY_OBJ	= 
+RUBY_PRO	= 
+RUBY_CFLAGS	= 
+RUBY_LIBS	= 
+
+SNIFF_SRC	= 
+SNIFF_OBJ	= 
+
+AWK		= gawk
+
+STRIP		= strip
+
+EXEEXT		= 
+
+COMPILEDBY	= 
+
+INSTALLVIMDIFF	= installvimdiff
+INSTALLGVIMDIFF	= installgvimdiff
+INSTALL_LANGS	= install-languages
+INSTALL_TOOL_LANGS	= install-tool-languages
+
+### Line break character as octal number for "tr"
+NL		= "\\012"
+
+### Top directory for everything
+prefix		= /Applications
+
+### Top directory for the binary
+exec_prefix	= ${prefix}
+
+### Prefix for location of data files
+BINDIR		= ${exec_prefix}/bin
+
+### For autoconf 2.60 and later (avoid a warning)
+datarootdir	= ${prefix}/share
+
+### Prefix for location of data files
+DATADIR		= ${prefix}/Vim.app/Contents/Resources
+
+### Prefix for location of man pages
+MANDIR		= ${datarootdir}/man
+
+### Do we have a GUI
+GUI_INC_LOC	= 
+GUI_LIB_LOC	= 
+GUI_SRC		= $(CARBONGUI_SRC)
+GUI_OBJ		= $(CARBONGUI_OBJ)
+GUI_DEFS	= $(CARBONGUI_DEFS)
+GUI_IPATH	= $(CARBONGUI_IPATH)
+GUI_LIBS_DIR	= $(CARBONGUI_LIBS_DIR)
+GUI_LIBS1	= $(CARBONGUI_LIBS1)
+GUI_LIBS2	= $(CARBONGUI_LIBS2)
+GUI_INSTALL	= $(CARBONGUI_INSTALL)
+GUI_TARGETS	= $(CARBONGUI_TARGETS)
+GUI_MAN_TARGETS	= $(CARBONGUI_MAN_TARGETS)
+GUI_TESTTARGET	= $(CARBONGUI_TESTTARGET)
+GUI_TESTARG	= $(CARBONGUI_TESTARG)
+GUI_BUNDLE	= $(CARBONGUI_BUNDLE)
+NARROW_PROTO	= 
+GUI_X_LIBS	= 
+MOTIF_LIBNAME	= 
+GTK_LIBNAME	= 
+
+### Any OS dependent extra source and object file
+OS_EXTRA_SRC	= os_macosx.c os_mac_conv.c
+OS_EXTRA_OBJ	= objects/os_macosx.o objects/os_mac_conv.o
+
+### If the *.po files are to be translated to *.mo files.
+MAKEMO		= 
+
+# Make sure that "make first" will run "make all" once configure has done its
+# work.  This is needed when using the Makefile in the top directory.
+first: all
--- a/src/ex_docmd.c	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/ex_docmd.c	Fri Aug 29 22:14:24 2008 +0900
@@ -12,6 +12,7 @@
  */
 
 #include "vim.h"
+#include "reditor.h"
 
 static int	quitmore = 0;
 static int	ex_pressedreturn = FALSE;
@@ -459,6 +460,9 @@
 # define ex_profile		ex_ni
 #endif
 
+
+
+
 /*
  * Declare cmdnames[].
  */
@@ -11011,3 +11015,49 @@
     ml_clearmarked();	   /* clear rest of the marks */
 }
 #endif
+
+/*
+ * Remote Editor's Ex commands.
+ */
+
+/* join and get session list */
+static void
+ex_repjoin(eap)
+    exarg_T *eap;
+{
+    char *smhost;
+    /*
+    if ((smhost = rep_input_param("Host and Port of Session Manager = ", "Do NOT connect."))
+        == NULL) {
+        rep_end();
+        return;
+    }
+    */
+    smhost = rep_input_param("Host and Port of Session Manager = ", NULL);
+    if (rep_join(smhost) == FALSE) {
+        rep_end();
+        return;
+    }
+
+    return ;
+}
+
+static void
+ex_repput(eap)
+    exarg_T *eap;
+{
+    char *sname;
+    sname = rep_input_param("Register Session Name = ", NULL);
+
+    if (rep_put(sname) == FALSE) {
+        vim_free(sname);
+        rep_end();
+        return;
+    }
+
+    if (sname) {
+        vim_free(sname);
+    }
+
+    return;
+}
--- a/src/main.c	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/main.c	Fri Aug 29 22:14:24 2008 +0900
@@ -7,7 +7,7 @@
  * See README.txt for an overview of the Vim source code.
  */
 
-#if defined(MSDOS) || defined(WIN32) || defined(_WIN64)
+#if defined(MSDOS) || defined(WIN16) || defined(WIN32) || defined(_WIN64)
 # include "vimio.h"		/* for close() and dup() */
 #endif
 
@@ -18,17 +18,20 @@
 # include <spawno.h>		/* special MS-DOS swapping library */
 #endif
 
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
 #ifdef __CYGWIN__
 # ifndef WIN32
-#  include <sys/cygwin.h>	/* for cygwin_conv_to_posix_path() */
+#  include <cygwin/version.h>
+#  include <sys/cygwin.h>	/* for cygwin_conv_to_posix_path() and/or
+				 * cygwin_conv_path() */
 # endif
 # include <limits.h>
 #endif
 
+/*
+ * Remote Editor
+ */
+#include "reditor.h"
+
 /* Maximum number of commands from + or -c arguments. */
 #define MAX_ARG_CMDS 10
 
@@ -248,6 +251,9 @@
 	mch_exit(0);
     TIME_MSG("Allocated generic buffers");
 
+    /* Remote Editor */
+    rep_init();
+
 #ifdef NBDEBUG
     /* Wait a moment for debugging NetBeans.  Must be after allocating
      * NameBuff. */
@@ -1368,6 +1374,12 @@
 init_locale()
 {
     setlocale(LC_ALL, "");
+
+# if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
+    /* Make sure strtod() uses a decimal point, not a comma. */
+    setlocale(LC_NUMERIC, "C");
+# endif
+
 # ifdef WIN32
     /* Apparently MS-Windows printf() may cause a crash when we give it 8-bit
      * text while it's expecting text in the current locale.  This call avoids
@@ -1552,15 +1564,15 @@
 	else if (STRICMP(argv[i], "--socketid") == 0)
 #  endif
 	{
-	    unsigned int    id;
-	    int		    count;
+	    long_u	id;
+	    int		count;
 
 	    if (i == argc - 1)
 		mainerr_arg_missing((char_u *)argv[i]);
 	    if (STRNICMP(argv[i+1], "0x", 2) == 0)
-		count = sscanf(&(argv[i + 1][2]), "%x", &id);
+		count = sscanf(&(argv[i + 1][2]), SCANF_HEX_LONG_U, &id);
 	    else
-		count = sscanf(argv[i+1], "%u", &id);
+		count = sscanf(argv[i + 1], SCANF_DECIMAL_LONG_U, &id);
 	    if (count != 1)
 		mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
 	    else
@@ -1775,7 +1787,8 @@
 
 	    case 'F':		/* "-F" start in Farsi mode: rl + fkmap set */
 #ifdef FEAT_FKMAP
-		curwin->w_p_rl = p_fkmap = TRUE;
+		p_fkmap = TRUE;
+		set_option_value((char_u *)"rl", 1L, NULL, 0);
 #else
 		mch_errmsg(_(e_nofarsi));
 		mch_exit(2);
@@ -1792,7 +1805,8 @@
 
 	    case 'H':		/* "-H" start in Hebrew mode: rl + hkmap set */
 #ifdef FEAT_RIGHTLEFT
-		curwin->w_p_rl = p_hkmap = TRUE;
+		p_hkmap = TRUE;
+		set_option_value((char_u *)"rl", 1L, NULL, 0);
 #else
 		mch_errmsg(_(e_nohebrew));
 		mch_exit(2);
@@ -2209,7 +2223,11 @@
 	    {
 		char posix_path[PATH_MAX];
 
+# if CYGWIN_VERSION_DLL_MAJOR >= 1007
+		cygwin_conv_path(CCP_WIN_A_TO_POSIX, p, posix_path, PATH_MAX);
+# else
 		cygwin_conv_to_posix_path(p, posix_path);
+# endif
 		vim_free(p);
 		p = vim_strsave(posix_path);
 		if (p == NULL)
@@ -2235,7 +2253,12 @@
 		/* Remember this argument has been added to the argument list.
 		 * Needed when 'encoding' is changed. */
 		used_file_arg(argv[0], parmp->literal, parmp->full_path,
-							    parmp->diff_mode);
+# ifdef FEAT_DIFF
+							    parmp->diff_mode
+# else
+							    FALSE
+# endif
+							    );
 	    }
 #endif
 	}
@@ -2514,7 +2537,6 @@
     int		arg_idx;		/* index in argument list */
     int		i;
     int		advance = TRUE;
-    buf_T	*old_curbuf;
 
 # ifdef FEAT_AUTOCMD
     /*
@@ -2567,21 +2589,26 @@
 	    curwin->w_arg_idx = arg_idx;
 	    /* Edit file from arg list, if there is one.  When "Quit" selected
 	     * at the ATTENTION prompt close the window. */
-	    old_curbuf = curbuf;
+# ifdef HAS_SWAP_EXISTS_ACTION
+	    swap_exists_did_quit = FALSE;
+# endif
 	    (void)do_ecmd(0, arg_idx < GARGCOUNT
 			  ? alist_name(&GARGLIST[arg_idx]) : NULL,
 			  NULL, NULL, ECMD_LASTL, ECMD_HIDE);
-	    if (curbuf == old_curbuf)
+# ifdef HAS_SWAP_EXISTS_ACTION
+	    if (swap_exists_did_quit)
 	    {
+		/* abort or quit selected */
 		if (got_int || only_one_window())
 		{
-		    /* abort selected or quit and only one window */
+		    /* abort selected and only one window */
 		    did_emsg = FALSE;   /* avoid hit-enter prompt */
 		    getout(1);
 		}
 		win_close(curwin, TRUE);
 		advance = FALSE;
 	    }
+# endif
 	    if (arg_idx == GARGCOUNT - 1)
 		arg_had_last = TRUE;
 	    ++arg_idx;
@@ -3081,7 +3108,7 @@
     main_msg(_("--remote-wait <files>  As --remote but wait for files to have been edited"));
     main_msg(_("--remote-wait-silent <files>  Same, don't complain if there is no server"));
 # ifdef FEAT_WINDOWS
-    main_msg(_("--remote-tab <files>  As --remote but open tab page for each file"));
+    main_msg(_("--remote-tab[-wait][-silent] <files>  As --remote but use tab page per file"));
 # endif
     main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit"));
     main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result"));
--- a/src/memline.c	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/memline.c	Fri Aug 29 22:14:24 2008 +0900
@@ -42,15 +42,12 @@
  *  mf_get().
  */
 
-#if defined(MSDOS) || defined(WIN32) || defined(_WIN64)
-# include "vimio.h"
+#if defined(MSDOS) || defined(WIN16) || defined(WIN32) || defined(_WIN64)
+# include "vimio.h"	/* for mch_open(), must be before vim.h */
 #endif
 
 #include "vim.h"
 
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
 #ifndef UNIX		/* it's in os_unix.h for Unix */
 # include <time.h>
 #endif
@@ -2197,6 +2194,14 @@
 
     if (buf->b_ml.ml_line_lnum != 0)
 	ml_flush_line(buf);
+
+    /*
+     * Remote Editor
+     */
+    if (rep_permit()) {
+        rep_prevline_flush();
+    }
+
     return ml_append_int(buf, lnum, line, len, newfile, FALSE);
 }
 #endif
@@ -2757,6 +2762,14 @@
     int		message;
 {
     ml_flush_line(curbuf);
+
+    /*
+     * Remote Editor
+     */
+    if (rep_permit()) {
+        rep_prevline_flush();
+    }
+
     return ml_delete_int(curbuf, lnum, message);
 }
 
@@ -3435,7 +3448,8 @@
 					(buf->b_ml.ml_stack_size + STACK_INCR));
 	if (newstack == NULL)
 	    return -1;
-	mch_memmove(newstack, buf->b_ml.ml_stack, (size_t)top * sizeof(infoptr_T));
+	mch_memmove(newstack, buf->b_ml.ml_stack,
+					     (size_t)top * sizeof(infoptr_T));
 	vim_free(buf->b_ml.ml_stack);
 	buf->b_ml.ml_stack = newstack;
 	buf->b_ml.ml_stack_size += STACK_INCR;
--- a/src/misc1.c	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/misc1.c	Fri Aug 29 22:14:24 2008 +0900
@@ -13,10 +13,7 @@
 
 #include "vim.h"
 #include "version.h"
-
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>		/* for chdir() */
-#endif
+#include "reditor.h"
 
 static char_u *vim_version_dir __ARGS((char_u *vimdir));
 static char_u *remove_tail __ARGS((char_u *p, char_u *pend, char_u *name));
@@ -222,10 +219,11 @@
 	    *s++ = *p++;
 	    orig_char_len--;
 	}
+
 	/* Skip over any additional white space (useful when newindent is less
 	 * than old) */
 	while (vim_iswhite(*p))
-	    (void)*p++;
+	    ++p;
 
     }
     else
@@ -436,7 +434,8 @@
     {
 	regmatch.rmm_ic = FALSE;
 	regmatch.rmm_maxcol = 0;
-	if (vim_regexec_multi(&regmatch, curwin, curbuf, lnum, (colnr_T)0))
+	if (vim_regexec_multi(&regmatch, curwin, curbuf, lnum,
+							    (colnr_T)0, NULL))
 	{
 	    pos.lnum = regmatch.endpos[0].lnum + lnum;
 	    pos.col = regmatch.endpos[0].col;
@@ -591,7 +590,14 @@
 	replace_push(NUL);
 	p = saved_line + curwin->w_cursor.col;
 	while (*p != NUL)
-	    replace_push(*p++);
+	{
+#ifdef FEAT_MBYTE
+	    if (has_mbyte)
+		p += replace_push_mb(p);
+	    else
+#endif
+		replace_push(*p++);
+	}
 	saved_line[curwin->w_cursor.col] = NUL;
     }
 #endif
@@ -1871,15 +1877,20 @@
 # ifdef FEAT_MBYTE
     int		n;
 
-    for (i = 0; i < len; i += n)
-    {
-	n = (*mb_ptr2len)(p + i);
-	ins_char_bytes(p + i, n);
-    }
-# else
-    for (i = 0; i < len; ++i)
-	ins_char(p[i]);
+    if (has_mbyte)
+	for (i = 0; i < len; i += n)
+	{
+	    if (enc_utf8)
+		/* avoid reading past p[len] */
+		n = utfc_ptr2len_len(p + i, len - i);
+	    else
+		n = (*mb_ptr2len)(p + i);
+	    ins_char_bytes(p + i, n);
+	}
+    else
 # endif
+	for (i = 0; i < len; ++i)
+	    ins_char(p[i]);
 }
 #endif
 
@@ -1914,7 +1925,6 @@
     int		charlen;
 {
     int		c = buf[0];
-    int		l, j;
 #endif
     int		newlen;		/* nr of bytes inserted */
     int		oldlen;		/* nr of bytes deleted (0 when not replacing) */
@@ -2016,13 +2026,11 @@
 	for (i = 0; i < oldlen; ++i)
 	{
 #ifdef FEAT_MBYTE
-	    l = (*mb_ptr2len)(oldp + col + i) - 1;
-	    for (j = l; j >= 0; --j)
-		replace_push(oldp[col + i + j]);
-	    i += l;
-#else
-	    replace_push(oldp[col + i]);
-#endif
+	    if (has_mbyte)
+		i += replace_push_mb(oldp + col + i) - 1;
+	    else
+#endif
+		replace_push(oldp[col + i]);
 	}
     }
 
@@ -2264,13 +2272,16 @@
     /*
      * If the old line has been allocated the deletion can be done in the
      * existing line. Otherwise a new line has to be allocated
+     * Can't do this when using Netbeans, because we would need to invoke
+     * netbeans_removed(), which deallocates the line.  Let ml_replace() take
+     * care of notifiying Netbeans.
      */
-    was_alloced = ml_line_alloced();	    /* check if oldp was allocated */
 #ifdef FEAT_NETBEANS_INTG
-    if (was_alloced && usingNetbeans)
-	netbeans_removed(curbuf, lnum, col, count);
-    /* else is handled by ml_replace() */
-#endif
+    if (usingNetbeans)
+	was_alloced = FALSE;
+    else
+#endif
+	was_alloced = ml_line_alloced();    /* check if oldp was allocated */
     if (was_alloced)
 	newp = oldp;			    /* use same allocated memory */
     else
@@ -2714,6 +2725,13 @@
     int		add;
 #endif
 
+        /*
+         * Remote Editor
+         */
+        if(rep_session_permit()){
+            rep_register(lnum,lnume,xtra);
+        }
+
     /* mark the buffer as modified */
     changed();
 
@@ -3020,7 +3038,7 @@
 	if (direct)
 	    r = get_keystroke();
 	else
-	    r = safe_vgetc();
+	    r = plain_vgetc();
 	if (r == Ctrl_C || r == ESC)
 	    r = 'n';
 	msg_putchar(r);	    /* show what you typed */
@@ -3972,7 +3990,7 @@
 	    /* remove trailing path separator */
 #ifndef MACOS_CLASSIC
 	    /* With MacOS path (with  colons) the final colon is required */
-	    /* to avoid confusion between absoulute and relative path */
+	    /* to avoid confusion between absolute and relative path */
 	    if (pend > p && after_pathsep(p, pend))
 		--pend;
 #endif
@@ -5683,7 +5701,7 @@
 	    else if (lookfor_ctor_init || class_or_struct)
 	    {
 		/* we have something found, that looks like the start of
-		 * cpp-base-class-declaration or contructor-initialization */
+		 * cpp-base-class-declaration or constructor-initialization */
 		cpp_base_class = TRUE;
 		lookfor_ctor_init = class_or_struct = FALSE;
 		*col = 0;
@@ -6140,7 +6158,7 @@
     pos_T	our_paren_pos;
     char_u	*start;
     int		start_brace;
-#define BRACE_IN_COL0		1	    /* '{' is in comumn 0 */
+#define BRACE_IN_COL0		1	    /* '{' is in column 0 */
 #define BRACE_AT_START		2	    /* '{' is at start of line */
 #define BRACE_AT_END		3	    /* '{' is at end of line */
     linenr_T	ourscope;
@@ -6363,7 +6381,7 @@
 		    if (curwin->w_cursor.lnum > 1)
 		    {
 			/* If the start comment string matches in the previous
-			 * line, use the indent of that line pluss offset.  If
+			 * line, use the indent of that line plus offset.  If
 			 * the middle comment string matches in the previous
 			 * line, use the indent of that line.  XXX */
 			look = skipwhite(ml_get(curwin->w_cursor.lnum - 1));
@@ -6885,6 +6903,7 @@
 			if (trypos != NULL)
 			{
 			    curwin->w_cursor.lnum = trypos->lnum + 1;
+			    curwin->w_cursor.col = 0;
 			    continue;
 			}
 
@@ -6945,6 +6964,7 @@
 			    if (trypos != NULL)
 			    {
 				curwin->w_cursor.lnum = trypos->lnum + 1;
+				curwin->w_cursor.col = 0;
 				continue;
 			    }
 			}
@@ -6982,6 +7002,7 @@
 		if ((trypos = find_start_comment(ind_maxcomment)) != NULL)
 		{
 		    curwin->w_cursor.lnum = trypos->lnum + 1;
+		    curwin->w_cursor.col = 0;
 		    continue;
 		}
 
@@ -7105,7 +7126,10 @@
 		{
 		    if (find_last_paren(l, '{', '}') && (trypos =
 				    find_start_brace(ind_maxcomment)) != NULL)
+		    {
 			curwin->w_cursor.lnum = trypos->lnum + 1;
+			curwin->w_cursor.col = 0;
+		    }
 		    continue;
 		}
 
@@ -7221,11 +7245,12 @@
 			 *     case xx:  if ( asdf &&
 			 *			asdf)
 			 */
-			curwin->w_cursor.lnum = trypos->lnum;
+			curwin->w_cursor = *trypos;
 			l = ml_get_curline();
 			if (cin_iscase(l) || cin_isscopedecl(l))
 			{
 			    ++curwin->w_cursor.lnum;
+			    curwin->w_cursor.col = 0;
 			    continue;
 			}
 		    }
@@ -7245,6 +7270,7 @@
 			    if (*l == NUL || l[STRLEN(l) - 1] != '\\')
 				break;
 			    --curwin->w_cursor.lnum;
+			    curwin->w_cursor.col = 0;
 			}
 		    }
 
@@ -7578,11 +7604,12 @@
 			     *	   case xx:  if ( asdf &&
 			     *			    asdf)
 			     */
-			    curwin->w_cursor.lnum = trypos->lnum;
+			    curwin->w_cursor = *trypos;
 			    l = ml_get_curline();
 			    if (cin_iscase(l) || cin_isscopedecl(l))
 			    {
 				++curwin->w_cursor.lnum;
+				curwin->w_cursor.col = 0;
 				continue;
 			    }
 			}
@@ -7643,13 +7670,14 @@
 				&& (trypos = find_start_brace(ind_maxcomment))
 							    != NULL) /* XXX */
 			{
-			    curwin->w_cursor.lnum = trypos->lnum;
+			    curwin->w_cursor = *trypos;
 			    /* if not "else {" check for terminated again */
 			    /* but skip block for "} else {" */
 			    l = cin_skipcomment(ml_get_curline());
 			    if (*l == '}' || !cin_iselse(l))
 				goto term_again;
 			    ++curwin->w_cursor.lnum;
+			    curwin->w_cursor.col = 0;
 			}
 		    }
 		}
@@ -7718,6 +7746,7 @@
 		if ((trypos = find_start_comment(ind_maxcomment)) != NULL)
 		{
 		    curwin->w_cursor.lnum = trypos->lnum + 1;
+		    curwin->w_cursor.col = 0;
 		    continue;
 		}
 
@@ -7768,7 +7797,7 @@
 		    if (find_last_paren(l, '(', ')')
 			    && (trypos = find_match_paren(ind_maxparen,
 						     ind_maxcomment)) != NULL)
-			curwin->w_cursor.lnum = trypos->lnum;
+			curwin->w_cursor = *trypos;
 
 		    /* For a line ending in ',' that is a continuation line go
 		     * back to the first line with a backslash:
@@ -7782,6 +7811,7 @@
 			if (*l == NUL || l[STRLEN(l) - 1] != '\\')
 			    break;
 			--curwin->w_cursor.lnum;
+			curwin->w_cursor.col = 0;
 		    }
 
 		    amount = get_indent();	    /* XXX */
@@ -7855,7 +7885,7 @@
 
 		if ((trypos = find_match_paren(ind_maxparen,
 						     ind_maxcomment)) != NULL)
-		    curwin->w_cursor.lnum = trypos->lnum;
+		    curwin->w_cursor = *trypos;
 		amount = get_indent();	    /* XXX */
 		break;
 	    }
@@ -8216,7 +8246,7 @@
 
 		    if (*that && *that != ';') /* not a comment line */
 		    {
-			/* test *that != '(' to accomodate first let/do
+			/* test *that != '(' to accommodate first let/do
 			 * argument if it is more than one line */
 			if (!vi_lisp && *that != '(' && *that != '[')
 			    firsttry++;
@@ -8654,7 +8684,7 @@
     for (p = buf + wildoff; p < s; ++p)
 	if (rem_backslash(p))
 	{
-	    mch_memmove(p, p + 1, STRLEN(p));
+	    STRMOVE(p, p + 1);
 	    --e;
 	    --s;
 	}
@@ -8955,7 +8985,7 @@
     for (p = buf + wildoff; p < s; ++p)
 	if (rem_backslash(p))
 	{
-	    mch_memmove(p, p + 1, STRLEN(p));
+	    STRMOVE(p, p + 1);
 	    --e;
 	    --s;
 	}
--- a/src/os_unix.c	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/os_unix.c	Fri Aug 29 22:14:24 2008 +0900
@@ -30,21 +30,23 @@
 #endif
 
 #include "vim.h"
+#include "reditor.h"
 
 #ifdef FEAT_MZSCHEME
 # include "if_mzsch.h"
 #endif
 
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
 #include "os_unixx.h"	    /* unix includes for os_unix.c only */
 
 #ifdef USE_XSMP
 # include <X11/SM/SMlib.h>
 #endif
 
+#ifdef HAVE_SELINUX
+# include <selinux/selinux.h>
+static int selinux_enabled = -1;
+#endif
+
 /*
  * Use this prototype for select, some include files have a wrong prototype
  */
@@ -57,7 +59,9 @@
 
 #ifdef __CYGWIN__
 # ifndef WIN32
-#  include <sys/cygwin.h>	/* for cygwin_conv_to_posix_path() */
+#  include <cygwin/version.h>
+#  include <sys/cygwin.h>	/* for cygwin_conv_to_posix_path() and/or
+				 * for cygwin_conv_path() */
 # endif
 #endif
 
@@ -87,6 +91,15 @@
 static int mch_gpm_process __ARGS((void));
 #endif
 
+#ifdef FEAT_SYSMOUSE
+# include <sys/consio.h>
+# include <sys/fbio.h>
+
+static int sysmouse_open __ARGS((void));
+static void sysmouse_close __ARGS((void));
+static RETSIGTYPE sig_sysmouse __ARGS(SIGPROTOARG);
+#endif
+
 /*
  * end of autoconf section. To be extended...
  */
@@ -195,6 +208,7 @@
 static int	show_shell_mess = TRUE;
 #endif
 static int	deadly_signal = 0;	    /* The signal we caught */
+static int	in_mch_delay = FALSE;	    /* sleeping in mch_delay() */
 
 static int curr_tmode = TMODE_COOK;	/* contains current terminal mode */
 
@@ -203,6 +217,7 @@
 {
     SmcConn smcconn;	    /* The SM connection ID */
     IceConn iceconn;	    /* The ICE connection ID */
+    char *clientid;         /* The client ID for the current smc session */
     Bool save_yourself;     /* If we're in the middle of a save_yourself */
     Bool shutdown;	    /* If we're in shutdown mode */
 } xsmp_config_T;
@@ -268,8 +283,9 @@
 #ifdef SIGVTALRM
     {SIGVTALRM,	    "VTALRM",	TRUE},
 #endif
-#if defined(SIGPROF) && !defined(FEAT_MZSCHEME)
-    /* MzScheme uses SIGPROF for its own needs */
+#if defined(SIGPROF) && !defined(FEAT_MZSCHEME) && !defined(WE_ARE_PROFILING)
+    /* MzScheme uses SIGPROF for its own needs; On Linux with profiling
+     * this makes Vim exit.  WE_ARE_PROFILING is defined in Makefile.  */
     {SIGPROF,	    "PROF",	TRUE},
 #endif
 #ifdef SIGXCPU
@@ -281,7 +297,8 @@
 #ifdef SIGUSR1
     {SIGUSR1,	    "USR1",	TRUE},
 #endif
-#ifdef SIGUSR2
+#if defined(SIGUSR2) && !defined(FEAT_SYSMOUSE)
+    /* Used for sysmouse handling */
     {SIGUSR2,	    "USR2",	TRUE},
 #endif
 #ifdef SIGINT
@@ -310,7 +327,7 @@
 }
 
 /*
- * mch_inchar(): low level input funcion.
+ * mch_inchar(): low level input function.
  * Get a characters from the keyboard.
  * Return the number of characters that are available.
  * If wtime == 0 do not wait for characters.
@@ -538,7 +555,9 @@
     if (ignoreinput)
     {
 	/* Go to cooked mode without echo, to allow SIGINT interrupting us
-	 * here */
+	 * here.  But we don't want QUIT to kill us (CTRL-\ used in a
+	 * shell may produce SIGQUIT). */
+	in_mch_delay = TRUE;
 	old_tmode = curr_tmode;
 	if (curr_tmode == TMODE_RAW)
 	    settmode(TMODE_SLEEP);
@@ -602,6 +621,7 @@
 #endif
 
 	settmode(old_tmode);
+	in_mch_delay = FALSE;
     }
     else
 	WaitForChar(msec);
@@ -922,6 +942,14 @@
 #endif
 
 #ifdef SIGHASARG
+# ifdef SIGQUIT
+    /* While in mch_delay() we go to cooked mode to allow a CTRL-C to
+     * interrupt us.  But in cooked mode we may also get SIGQUIT, e.g., when
+     * pressing CTRL-\, but we don't want Vim to exit then. */
+    if (in_mch_delay && sigarg == SIGQUIT)
+	SIGRETURN;
+# endif
+
     /* When SIGHUP, SIGQUIT, etc. are blocked: postpone the effect and return
      * here.  This avoids that a non-reentrant function is interrupted, e.g.,
      * free().  Calling free() again may then cause a crash. */
@@ -1567,18 +1595,19 @@
 #ifdef FEAT_XCLIPBOARD
     if (xterm_dpy != NULL && x11_window != 0)
     {
-	/* Checked it already. */
-	if (x11_display_from == XD_XTERM)
-	    return OK;
-
-	/*
-	 * If the X11 display was opened here before, for the window where Vim
-	 * was started, close that one now to avoid a memory leak.
-	 */
-	if (x11_display_from == XD_HERE && x11_display != NULL)
-	    XCloseDisplay(x11_display);
-	x11_display = xterm_dpy;
-	x11_display_from = XD_XTERM;
+	/* We may have checked it already, but Gnome terminal can move us to
+	 * another window, so we need to check every time. */
+	if (x11_display_from != XD_XTERM)
+	{
+	    /*
+	     * If the X11 display was opened here before, for the window where
+	     * Vim was started, close that one now to avoid a memory leak.
+	     */
+	    if (x11_display_from == XD_HERE && x11_display != NULL)
+		XCloseDisplay(x11_display);
+	    x11_display = xterm_dpy;
+	    x11_display_from = XD_XTERM;
+	}
 	if (test_x11_window(x11_display) == FAIL)
 	{
 	    /* probably bad $WINDOWID */
@@ -2035,6 +2064,21 @@
 		|| STRCMP(name, "builtin_xterm") == 0);
 }
 
+#if defined(FEAT_MOUSE_XTERM) || defined(PROTO)
+/*
+ * Return TRUE if "name" appears to be that of a terminal
+ * known to support the xterm-style mouse protocol.
+ * Relies on term_is_xterm having been set to its correct value.
+ */
+    int
+use_xterm_like_mouse(name)
+    char_u *name;
+{
+    return (name != NULL
+	    && (term_is_xterm || STRNICMP(name, "screen", 6) == 0));
+}
+#endif
+
 #if defined(FEAT_MOUSE_TTY) || defined(PROTO)
 /*
  * Return non-zero when using an xterm mouse, according to 'ttymouse'.
@@ -2258,6 +2302,10 @@
     char_u	olddir[MAXPATHL];
     char_u	*p;
     int		retval = OK;
+#ifdef __CYGWIN__
+    char_u	posix_fname[MAXPATHL];	/* Cygwin docs mention MAX_PATH, but
+					   it's not always defined */
+#endif
 
 #ifdef VMS
     fname = vms_fixfilename(fname);
@@ -2267,7 +2315,12 @@
     /*
      * This helps for when "/etc/hosts" is a symlink to "c:/something/hosts".
      */
-    cygwin_conv_to_posix_path(fname, fname);
+# if CYGWIN_VERSION_DLL_MAJOR >= 1007
+    cygwin_conv_path(CCP_WIN_A_TO_POSIX, fname, posix_fname, MAXPATHL);
+# else
+    cygwin_conv_to_posix_path(fname, posix_fname);
+# endif
+    fname = posix_fname;
 #endif
 
     /* expand it if forced or not an absolute path */
@@ -2421,7 +2474,7 @@
 /*
  * Set the case of the file name, if it already exists.  This will cause the
  * file name to remain exactly the same.
- * Only required for file systems where case is ingored and preserved.
+ * Only required for file systems where case is ignored and preserved.
  */
 /*ARGSUSED*/
     void
@@ -2543,6 +2596,62 @@
 } vim_acl_solaris_T;
 # endif
 
+#if defined(HAVE_SELINUX) || defined(PROTO)
+/*
+ * Copy security info from "from_file" to "to_file".
+ */
+    void
+mch_copy_sec(from_file, to_file)
+    char_u	*from_file;
+    char_u	*to_file;
+{
+    if (from_file == NULL)
+	return;
+
+    if (selinux_enabled == -1)
+	selinux_enabled = is_selinux_enabled();
+
+    if (selinux_enabled > 0)
+    {
+	security_context_t from_context = NULL;
+	security_context_t to_context = NULL;
+
+	if (getfilecon((char *)from_file, &from_context) < 0)
+	{
+	    /* If the filesystem doesn't support extended attributes,
+	       the original had no special security context and the
+	       target cannot have one either.  */
+	    if (errno == EOPNOTSUPP)
+		return;
+
+	    MSG_PUTS(_("\nCould not get security context for "));
+	    msg_outtrans(from_file);
+	    msg_putchar('\n');
+	    return;
+	}
+	if (getfilecon((char *)to_file, &to_context) < 0)
+	{
+	    MSG_PUTS(_("\nCould not get security context for "));
+	    msg_outtrans(to_file);
+	    msg_putchar('\n');
+	    freecon (from_context);
+	    return ;
+	}
+	if (strcmp(from_context, to_context) != 0)
+	{
+	    if (setfilecon((char *)to_file, from_context) < 0)
+	    {
+		MSG_PUTS(_("\nCould not set security context for "));
+		msg_outtrans(to_file);
+		msg_putchar('\n');
+	    }
+	}
+	freecon(to_context);
+	freecon(from_context);
+    }
+}
+#endif /* HAVE_SELINUX */
+
 /*
  * Return a pointer to the ACL of file "fname" in allocated memory.
  * Return NULL if the ACL is not available for whatever reason.
@@ -2812,16 +2921,28 @@
     if (clip_plus.owned)
 	clip_lose_selection(&clip_plus);
 # endif
-# if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO)
+# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
     if (xterm_Shell != (Widget)0)
 	XtDestroyWidget(xterm_Shell);
+#  ifndef LESSTIF_VERSION
+    /* Lesstif crashes here, lose some memory */
     if (xterm_dpy != NULL)
 	XtCloseDisplay(xterm_dpy);
     if (app_context != (XtAppContext)NULL)
+    {
 	XtDestroyApplicationContext(app_context);
+#   ifdef FEAT_X11
+	x11_display = NULL; /* freed by XtDestroyApplicationContext() */
+#   endif
+    }
+#  endif
 # endif
 # ifdef FEAT_X11
-    if (x11_display != NULL && x11_display != xterm_dpy)
+    if (x11_display != NULL
+#  ifdef FEAT_XCLIPBOARD
+	    && x11_display != xterm_dpy
+#  endif
+	    )
 	XCloseDisplay(x11_display);
 # endif
 # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
@@ -3162,6 +3283,22 @@
     }
 # endif
 
+# ifdef FEAT_SYSMOUSE
+    else
+    {
+	if (on)
+	{
+	    if (sysmouse_open() == OK)
+		ison = TRUE;
+	}
+	else
+	{
+	    sysmouse_close();
+	    ison = FALSE;
+	}
+    }
+# endif
+
 # ifdef FEAT_MOUSE_JSB
     else
     {
@@ -3249,6 +3386,15 @@
 	set_mouse_termcode(KS_MOUSE, (char_u *)IF_EB("\033MG", ESC_STR "MG"));
 # endif
 
+# ifdef FEAT_SYSMOUSE
+    if (!use_xterm_mouse()
+#  ifdef FEAT_GUI
+	    && !gui.in_use
+#  endif
+	    )
+	set_mouse_termcode(KS_MOUSE, (char_u *)IF_EB("\033MS", ESC_STR "MS"));
+# endif
+
 # ifdef FEAT_MOUSE_JSB
     /* conflicts with xterm mouse: "\033[" and "\033[M" ??? */
     if (!use_xterm_mouse()
@@ -3799,7 +3945,7 @@
 # ifdef HAVE_SETSID
 		/* Create our own process group, so that the child and all its
 		 * children can be kill()ed.  Don't do this when using pipes,
-		 * because stdin is not a tty, we would loose /dev/tty. */
+		 * because stdin is not a tty, we would lose /dev/tty. */
 		if (p_stmp)
 		    (void)setsid();
 # endif
@@ -3828,7 +3974,7 @@
 # else
 		/*
 		 * Putenv does not copy the string, it has to remain valid.
-		 * Use a static array to avoid loosing allocated memory.
+		 * Use a static array to avoid losing allocated memory.
 		 */
 		putenv("TERM=dumb");
 		sprintf(envbuf_Rows, "ROWS=%ld", Rows);
@@ -4161,7 +4307,7 @@
 			/*
 			 * Write the characters to the child, unless EOF has
 			 * been typed for pipes.  Write one character at a
-			 * time, to avoid loosing too much typeahead.
+			 * time, to avoid losing too much typeahead.
 			 * When writing buffer lines, drop the typed
 			 * characters (only check for CTRL-C).
 			 */
@@ -4293,7 +4439,7 @@
 
 		    /*
 		     * Check if the child still exists, before checking for
-		     * typed characters (otherwise we would loose typeahead).
+		     * typed characters (otherwise we would lose typeahead).
 		     */
 # ifdef __NeXT__
 		    wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *) 0);
@@ -4653,7 +4799,7 @@
 	ret = poll(fds, nfd, towait);
 # ifdef FEAT_MZSCHEME
 	if (ret == 0 && mzquantum_used)
-	    /* MzThreads scheduling is required and timeout occured */
+	    /* MzThreads scheduling is required and timeout occurred */
 	    finished = FALSE;
 # endif
 
@@ -4784,6 +4930,11 @@
 	}
 # endif
 
+	   /* Remote Editor */
+	    if (rep_permit()) {
+	        maxfd = rep_fd_set(&rfds, &efds, maxfd);
+	    }
+
 # ifdef OLD_VMS
 	/* Old VMS as v6.2 and older have broken select(). It waits more than
 	 * required. Should not be used */
@@ -4801,10 +4952,16 @@
 #endif
 # ifdef FEAT_MZSCHEME
 	if (ret == 0 && mzquantum_used)
-	    /* loop if MzThreads must be scheduled and timeout occured */
+	    /* loop if MzThreads must be scheduled and timeout occurred */
 	    finished = FALSE;
 # endif
 
+    /* Remote Editor */
+    if ((ret > 0 ) && (rep_permit())) {
+        rep_fd_check(fd, &rfds, &efds);
+    }
+
+
 # ifdef FEAT_SNIFF
 	if (ret < 0 )
 	    sniff_disconnect(1);
@@ -4945,6 +5102,9 @@
     char_u	*p;
     int		dir;
 #ifdef __EMX__
+    /*
+     * This is the OS/2 implementation.
+     */
 # define EXPL_ALLOC_INC	16
     char_u	**expl_files;
     size_t	files_alloced, files_free;
@@ -5055,20 +5215,26 @@
     return OK;
 
 #else /* __EMX__ */
-
+    /*
+     * This is the non-OS/2 implementation (really Unix).
+     */
     int		j;
     char_u	*tempname;
     char_u	*command;
     FILE	*fd;
     char_u	*buffer;
-#define STYLE_ECHO  0	    /* use "echo" to expand */
-#define STYLE_GLOB  1	    /* use "glob" to expand, for csh */
-#define STYLE_PRINT 2	    /* use "print -N" to expand, for zsh */
-#define STYLE_BT    3	    /* `cmd` expansion, execute the pattern directly */
+#define STYLE_ECHO	0	/* use "echo", the default */
+#define STYLE_GLOB	1	/* use "glob", for csh */
+#define STYLE_VIMGLOB	2	/* use "vimglob", for Posix sh */
+#define STYLE_PRINT	3	/* use "print -N", for zsh */
+#define STYLE_BT	4	/* `cmd` expansion, execute the pattern
+				 * directly */
     int		shell_style = STYLE_ECHO;
     int		check_spaces;
     static int	did_find_nul = FALSE;
     int		ampersent = FALSE;
+		/* vimglob() function to define for Posix shell */
+    static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
 
     *num_file = 0;	/* default: no files found */
     *file = NULL;
@@ -5106,9 +5272,17 @@
 
     /*
      * Let the shell expand the patterns and write the result into the temp
-     * file.  if expanding `cmd` execute it directly.
-     * If we use csh, glob will work better than echo.
-     * If we use zsh, print -N will work better than glob.
+     * file.
+     * STYLE_BT:	NL separated
+     *	    If expanding `cmd` execute it directly.
+     * STYLE_GLOB:	NUL separated
+     *	    If we use *csh, "glob" will work better than "echo".
+     * STYLE_PRINT:	NL or NUL separated
+     *	    If we use *zsh, "print -N" will work better than "glob".
+     * STYLE_VIMGLOB:	NL separated
+     *	    If we use *sh*, we define "vimglob()".
+     * STYLE_ECHO:	space separated.
+     *	    A shell we don't know, stay safe and use "echo".
      */
     if (num_pat == 1 && *pat[0] == '`'
 	    && (len = STRLEN(pat[0])) > 2
@@ -5121,9 +5295,17 @@
 	else if (STRCMP(p_sh + len - 3, "zsh") == 0)
 	    shell_style = STYLE_PRINT;
     }
-
-    /* "unset nonomatch; print -N >" plus two is 29 */
+    if (shell_style == STYLE_ECHO && strstr((char *)gettail(p_sh),
+								"sh") != NULL)
+	shell_style = STYLE_VIMGLOB;
+
+    /* Compute the length of the command.  We need 2 extra bytes: for the
+     * optional '&' and for the NUL.
+     * Worst case: "unset nonomatch; print -N >" plus two is 29 */
     len = STRLEN(tempname) + 29;
+    if (shell_style == STYLE_VIMGLOB)
+	len += STRLEN(sh_vimglob_func);
+
     for (i = 0; i < num_pat; ++i)
     {
 	/* Count the length of the patterns in the same way as they are put in
@@ -5182,16 +5364,20 @@
 	    STRCAT(command, "glob >");
 	else if (shell_style == STYLE_PRINT)
 	    STRCAT(command, "print -N >");
+	else if (shell_style == STYLE_VIMGLOB)
+	    STRCAT(command, sh_vimglob_func);
 	else
 	    STRCAT(command, "echo >");
     }
+
     STRCAT(command, tempname);
+
     if (shell_style != STYLE_BT)
 	for (i = 0; i < num_pat; ++i)
 	{
 	    /* When using system() always add extra quotes, because the shell
 	     * is started twice.  Otherwise put a backslash before special
-	     * characters, except insice ``. */
+	     * characters, except inside ``. */
 #ifdef USE_SYSTEM
 	    STRCAT(command, " \"");
 	    STRCAT(command, pat[i]);
@@ -5231,8 +5417,7 @@
     if (flags & EW_SILENT)
 	show_shell_mess = FALSE;
     if (ampersent)
-	STRCAT(command, "&");		/* put the '&' back after the
-					   redirection */
+	STRCAT(command, "&");		/* put the '&' after the redirection */
 
     /*
      * Using zsh -G: If a pattern has no matches, it is just deleted from
@@ -5264,7 +5449,7 @@
     show_shell_mess = TRUE;
     vim_free(command);
 
-    if (i)				/* mch_call_shell() failed */
+    if (i != 0)				/* mch_call_shell() failed */
     {
 	mch_remove(tempname);
 	vim_free(tempname);
@@ -5335,7 +5520,7 @@
     }
     vim_free(tempname);
 
-#if defined(__CYGWIN__) || defined(__CYGWIN32__)
+# if defined(__CYGWIN__) || defined(__CYGWIN32__)
     /* Translate <CR><NL> into <NL>.  Caution, buffer may contain NUL. */
     p = buffer;
     for (i = 0; i < len; ++i)
@@ -5358,7 +5543,7 @@
 	}
     }
     /* file names are separated with NL */
-    else if (shell_style == STYLE_BT)
+    else if (shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB)
     {
 	buffer[len] = NUL;		/* make sure the buffer ends in NUL */
 	p = buffer;
@@ -5437,7 +5622,8 @@
     {
 	(*file)[i] = p;
 	/* Space or NL separates */
-	if (shell_style == STYLE_ECHO || shell_style == STYLE_BT)
+	if (shell_style == STYLE_ECHO || shell_style == STYLE_BT
+					      || shell_style == STYLE_VIMGLOB)
 	{
 	    while (!(shell_style == STYLE_ECHO && *p == ' ')
 						   && *p != '\n' && *p != NUL)
@@ -5481,7 +5667,7 @@
 	{
 	    STRCPY(p, (*file)[i]);
 	    if (dir)
-		STRCAT(p, "/");	    /* add '/' to a directory name */
+		add_pathsep(p);	    /* add '/' to a directory name */
 	    (*file)[j++] = p;
 	}
     }
@@ -5675,7 +5861,7 @@
 	    /* gpm library tries to handling TSTP causes
 	     * problems. Anyways, we close connection to Gpm whenever
 	     * we are going to suspend or starting an external process
-	     * so we should'nt  have problem with this
+	     * so we shouldn't  have problem with this
 	     */
 	    signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
 	    return 1; /* succeed */
@@ -5689,7 +5875,6 @@
 
 /*
  * Closes connection to gpm
- * returns non-zero if connection successfully closed
  */
     static void
 gpm_close()
@@ -5784,6 +5969,114 @@
 }
 #endif /* FEAT_MOUSE_GPM */
 
+#ifdef FEAT_SYSMOUSE
+/*
+ * Initialize connection with sysmouse.
+ * Let virtual console inform us with SIGUSR2 for pending sysmouse
+ * output, any sysmouse output than will be processed via sig_sysmouse().
+ * Return OK if succeeded, FAIL if failed.
+ */
+    static int
+sysmouse_open()
+{
+    struct mouse_info   mouse;
+
+    mouse.operation = MOUSE_MODE;
+    mouse.u.mode.mode = 0;
+    mouse.u.mode.signal = SIGUSR2;
+    if (ioctl(1, CONS_MOUSECTL, &mouse) != -1)
+    {
+	signal(SIGUSR2, (RETSIGTYPE (*)())sig_sysmouse);
+	mouse.operation = MOUSE_SHOW;
+	ioctl(1, CONS_MOUSECTL, &mouse);
+	return OK;
+    }
+    return FAIL;
+}
+
+/*
+ * Stop processing SIGUSR2 signals, and also make sure that
+ * virtual console do not send us any sysmouse related signal.
+ */
+    static void
+sysmouse_close()
+{
+    struct mouse_info	mouse;
+
+    signal(SIGUSR2, restricted ? SIG_IGN : SIG_DFL);
+    mouse.operation = MOUSE_MODE;
+    mouse.u.mode.mode = 0;
+    mouse.u.mode.signal = 0;
+    ioctl(1, CONS_MOUSECTL, &mouse);
+}
+
+/*
+ * Gets info from sysmouse and adds special keys to input buf.
+ */
+/* ARGSUSED */
+    static RETSIGTYPE
+sig_sysmouse SIGDEFARG(sigarg)
+{
+    struct mouse_info	mouse;
+    struct video_info	video;
+    char_u		string[6];
+    int			row, col;
+    int			button;
+    int			buttons;
+    static int		oldbuttons = 0;
+
+#ifdef FEAT_GUI
+    /* Don't put events in the input queue now. */
+    if (hold_gui_events)
+	return;
+#endif
+
+    mouse.operation = MOUSE_GETINFO;
+    if (ioctl(1, FBIO_GETMODE, &video.vi_mode) != -1
+	    && ioctl(1, FBIO_MODEINFO, &video) != -1
+	    && ioctl(1, CONS_MOUSECTL, &mouse) != -1
+	    && video.vi_cheight > 0 && video.vi_cwidth > 0)
+    {
+	row = mouse.u.data.y / video.vi_cheight;
+	col = mouse.u.data.x / video.vi_cwidth;
+	buttons = mouse.u.data.buttons;
+	string[0] = ESC; /* Our termcode */
+	string[1] = 'M';
+	string[2] = 'S';
+	if (oldbuttons == buttons && buttons != 0)
+	{
+	    button = MOUSE_DRAG;
+	}
+	else
+	{
+	    switch (buttons)
+	    {
+		case 0:
+		    button = MOUSE_RELEASE;
+		    break;
+		case 1:
+		    button = MOUSE_LEFT;
+		    break;
+		case 2:
+		    button = MOUSE_MIDDLE;
+		    break;
+		case 4:
+		    button = MOUSE_RIGHT;
+		    break;
+		default:
+		    return;
+	    }
+	    oldbuttons = buttons;
+	}
+	string[3] = (char_u)(button);
+	string[4] = (char_u)(col + ' ' + 1);
+	string[5] = (char_u)(row + ' ' + 1);
+	add_to_input_buf(string, 6);
+    }
+    return;
+}
+#endif /* FEAT_SYSMOUSE */
+
 #if defined(FEAT_LIBCALL) || defined(PROTO)
 typedef char_u * (*STRPROCSTR)__ARGS((char_u *));
 typedef char_u * (*INTPROCSTR)__ARGS((int));
@@ -6115,9 +6408,9 @@
     if (xterm_trace == 1)
     {
 	/* Get the hints just before tracking starts.  The font size might
-	 * have changed recently */
-	XGetWMNormalHints(xterm_dpy, x11_window, &xterm_hints, &got_hints);
-	if (!(got_hints & PResizeInc)
+	 * have changed recently. */
+	if (!XGetWMNormalHints(xterm_dpy, x11_window, &xterm_hints, &got_hints)
+		|| !(got_hints & PResizeInc)
 		|| xterm_hints.width_inc <= 1
 		|| xterm_hints.height_inc <= 1)
 	{
@@ -6186,22 +6479,22 @@
     }
     if (xterm_dpy != NULL)
     {
-#if 0
+#  if 0
 	/* Lesstif and Solaris crash here, lose some memory */
 	XtCloseDisplay(xterm_dpy);
-#endif
+#  endif
 	if (x11_display == xterm_dpy)
 	    x11_display = NULL;
 	xterm_dpy = NULL;
     }
-#if 0
+#  if 0
     if (app_context != (XtAppContext)NULL)
     {
 	/* Lesstif and Solaris crash here, lose some memory */
 	XtDestroyApplicationContext(app_context);
 	app_context = (XtAppContext)NULL;
     }
-#endif
+#  endif
 }
 # endif
 
@@ -6453,7 +6746,6 @@
 xsmp_init(void)
 {
     char		errorstring[80];
-    char		*clientid;
     SmcCallbacks	smcallbacks;
 #if 0
     SmPropValue		smname;
@@ -6495,7 +6787,7 @@
 		     | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask,
 	    &smcallbacks,
 	    NULL,
-	    &clientid,
+	    &xsmp.clientid,
 	    sizeof(errorstring),
 	    errorstring);
     if (xsmp.smcconn == NULL)
@@ -6534,6 +6826,8 @@
     if (xsmp_icefd != -1)
     {
 	SmcCloseConnection(xsmp.smcconn, 0, NULL);
+	vim_free(xsmp.clientid);
+	xsmp.clientid = NULL;
 	xsmp_icefd = -1;
     }
 }
--- a/src/ui.c	Fri Aug 29 15:41:29 2008 +0900
+++ b/src/ui.c	Fri Aug 29 22:14:24 2008 +0900
@@ -17,6 +17,7 @@
  */
 
 #include "vim.h"
+#include "reditor.h"
 
     void
 ui_write(s, len)
@@ -1600,7 +1601,8 @@
 }
 #endif
 
-#if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) \
+#if defined(FEAT_GUI) \
+	|| defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) \
 	|| defined(FEAT_XCLIPBOARD) || defined(VMS) \
 	|| defined(FEAT_SNIFF) || defined(FEAT_CLIENTSERVER) \
 	|| defined(PROTO)
@@ -1788,6 +1790,13 @@
     len = 0;	/* to avoid gcc warning */
     for (try = 0; try < 100; ++try)
     {
+    	/*
+    	         * Remote Editor
+    	         */
+    	        if (rep_permit()) {
+    	            rep_select(read_cmd_fd);
+    	        }
+
 #  ifdef VMS
 	len = vms_read(
 #  else
@@ -1910,7 +1919,7 @@
 #endif
 
 #if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
-	|| defined(PROTO)
+	|| defined(FEAT_MBYTE) || defined(PROTO)
 /*
  * Check bounds for column number
  */