+2016-09-17 Eli Zaretskii <eliz@gnu.org>
+
+ * util.c: Include rlshell.h.
+ (_rl_tropen) [_WIN32 && !__CYGWIN__]: Open the trace file in the
+ user's temporary directory.
+
+ * tcap.h [HAVE_NCURSES_TERMCAP_H]: Include ncurses/termcap.h.
+
+ * input.c (w32_isatty) [_WIN32 && !__CYGWIN__]: New function, to
+ replace isatty that is not reliable enough on MS-Windows.
+ (isatty) [_WIN32 && !__CYGWIN__]: Redirect to w32_isatty.
+ (rl_getc): Call _getch, not getch, which could be an ncurses
+ function when linked with ncurses, in which case getch will return
+ EOF for any keystroke, because there's no curses window.
+
+ * tilde.c (tilde_expand_word) [_WIN32]:
+ * histfile.c (history_filename) [_WIN32]: Windows-specific
+ environment variable to replace HOME if that is undefined.
+
+ * funmap.c (default_funmap): Compile rl_paste_from_clipboard on
+ all Windows platforms, not just Cygwin.
+
+ * readline.h (rl_paste_from_clipboard): Include declaration for
+ all Windows platforms.
+
+ * display.c (insert_some_chars, delete_chars): Don't use the
+ MinGW-specific code if linked with ncurses.
+
+ * configure.in:
+ * config.h.in: Support ncurses/termcap.h. The configure script
+ was updated accordingly.
+
+ * complete.c [_WIN32 && !__CYGWIN__]: Initialize
+ _rl_completion_case_fold to 1.
+ (printable_part, rl_filename_completion_function)
+ [_WIN32 && !__CYGWIN__]: Handle the drive letter.
+
2014-12-30 Eli Zaretskii <eliz@gnu.org>
* complete.c (stat_char) [_WIN32]: Don't use 'access' and X_OK on
int _rl_print_completions_horizontally;
/* Non-zero means that case is not significant in filename completion. */
-#if defined (__MSDOS__) && !defined (__DJGPP__)
+#if defined (__MSDOS__) && !defined (__DJGPP__) \
+ || (defined (_WIN32) && !defined (__CYGWIN__))
int _rl_completion_case_fold = 1;
#else
int _rl_completion_case_fold = 0;
return (pathname);
temp = strrchr (pathname, '/');
-#if defined (__MSDOS__)
+#if defined (__MSDOS__) || defined (_WIN32)
if (temp == 0 && ISALPHA ((unsigned char)pathname[0]) && pathname[1] == ':')
temp = pathname + 1;
#endif
temp = strrchr (dirname, '/');
-#if defined (__MSDOS__)
+#if defined (__MSDOS__) || defined (_WIN32)
/* special hack for //X/... */
if (dirname[0] == '/' && dirname[1] == '/' && ISALPHA ((unsigned char)dirname[2]) && dirname[3] == '/')
temp = strrchr (dirname + 3, '/');
strcpy (filename, ++temp);
*temp = '\0';
}
-#if defined (__MSDOS__)
+#if defined (__MSDOS__) || (defined (_WIN32) && !defined (__CYGWIN__))
/* searches from current directory on the drive */
else if (ISALPHA ((unsigned char)dirname[0]) && dirname[1] == ':')
{
/* Define if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
+/* Define if you have the <ncurses/termcap.h> header file. */
+#undef HAVE_NCURSES_TERMCAP_H
+
/* Define if you have the <termio.h> header file. */
#undef HAVE_TERMIO_H
fi
fi
+if test "$TERMCAP_LIB" = "-lncurses"; then
+
+for ac_header in ncurses/termcap.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+ if test "x$as_val" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+fi
for ac_header in wctype.h
do :
TERMCAP_LIB=-ltermcap #default
fi
fi
+if test "$TERMCAP_LIB" = "-lncurses"; then
+ AC_CHECK_HEADERS(ncurses/termcap.h)
+fi
BASH_CHECK_MULTIBYTE
char *string;
int count, col;
{
-#if defined (__MSDOS__) || defined (__MINGW32__)
+#if defined (__MSDOS__) || (defined (__MINGW32__) && !defined (NCURSES_VERSION))
_rl_output_some_chars (string, count);
#else
/* DEBUGGING */
if (count > _rl_screenwidth) /* XXX */
return;
-#if !defined (__MSDOS__) && !defined (__MINGW32__)
+#if !defined (__MSDOS__) && !(defined (__MINGW32__) && !defined (NCURSES_VERSION))
if (_rl_term_DC && *_rl_term_DC)
{
char *buffer;
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
{ "old-menu-complete", rl_old_menu_complete },
{ "overwrite-mode", rl_overwrite_mode },
-#ifdef __CYGWIN__
+#ifdef _WIN32
{ "paste-from-clipboard", rl_paste_from_clipboard },
#endif
{ "possible-completions", rl_possible_completions },
return (return_val);
home = sh_get_env_value ("HOME");
+#ifdef _WIN32
+ if (!home)
+ home = sh_get_env_value ("APPDATA");
+#endif
if (home == 0)
{
static int rl_get_char PARAMS((int *));
static int rl_gather_tyi PARAMS((void));
+#if defined (_WIN32) && !defined (__CYGWIN__)
+
+/* 'isatty' in the Windows runtime returns non-zero for every
+ character device, including the null device. Repair that. */
+#include <io.h>
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+
+int w32_isatty (int fd)
+{
+ if (_isatty(fd))
+ {
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ DWORD ignored;
+
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return 0;
+ }
+ if (GetConsoleMode (h, &ignored) != 0)
+ return 1;
+ }
+ errno = ENOTTY;
+ return 0;
+}
+
+#define isatty(x) w32_isatty(x)
+#endif
+
/* **************************************************************** */
/* */
/* Character Input Buffering */
RL_CHECK_SIGNALS ();
#if defined (__MINGW32__)
+ /* Use _getch to make sure we call the function from MS runtime,
+ even if some curses library is linked in. */
if (isatty (fileno (stream)))
- return (getch ());
+ return (_getch ());
#endif
result = read (fileno (stream), &c, sizeof (unsigned char));
}
/* A special paste command for users of Cygnus's cygwin32. */
-#if defined (__CYGWIN__)
+#if defined (_WIN32)
#include <windows.h>
int
extern int rl_yank_pop PARAMS((int, int));
extern int rl_yank_nth_arg PARAMS((int, int));
extern int rl_yank_last_arg PARAMS((int, int));
-/* Not available unless __CYGWIN__ is defined. */
-#ifdef __CYGWIN__
+/* Not available unless _WIN32 is defined. */
+#ifdef _WIN32
extern int rl_paste_from_clipboard PARAMS((int, int));
#endif
# include "rltty.h"
# endif
# include <termcap.h>
+#elif defined (HAVE_NCURSES_TERMCAP_H)
+# include <ncurses/termcap.h>
#else
/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC.
{
/* Prefix $HOME to the rest of the string. */
expansion = sh_get_env_value ("HOME");
+#ifdef _WIN32
+ if (!expansion)
+ expansion = sh_get_env_value ("APPDATA");
+#endif
/* If there is no HOME variable, look up the directory in
the password database. */
#include "rlprivate.h"
#include "xmalloc.h"
+#include "rlshell.h"
/* **************************************************************** */
/* */
if (_rl_tracefp)
fclose (_rl_tracefp);
+#if defined (_WIN32) && !defined (__CYGWIN__)
+ /* Windows doesn't have /var/tmp, so open the trace file in the
+ user's temporary directory instead. */
+ sprintf (fnbuf, "%s/rltrace.%ld",
+ (sh_get_env_value ("TEMP")
+ ? sh_get_env_value ("TEMP")
+ : "."),
+ getpid());
+#else
sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid());
+#endif
unlink(fnbuf);
_rl_tracefp = fopen (fnbuf, "w+");
return _rl_tracefp != 0;