bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-readline] Various file- and environment-related issues in Readline


From: Eli Zaretskii
Subject: [Bug-readline] Various file- and environment-related issues in Readline on MS-Windows
Date: Fri, 02 Jan 2015 12:39:52 +0200

[Please CC me on any replies, as I'm not subscribed to this list.]

Hi,

The following patches take care of a few issues with file names and
the run-time environment on MS-Windows.  TIA.

Windows filesystems behave similarly to MS-DOS:

--- complete.c~0        2014-06-11 18:34:41 +0300
+++ complete.c  2014-12-30 07:30:22 +0200
@@ -156,7 +156,8 @@
 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;
@@ -623,7 +637,7 @@
     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
@@ -2173,7 +2187,7 @@
 
       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, '/');
@@ -2184,7 +2198,7 @@
          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] == ':')
         {


Windows can paste to the console, like Cygwin:

--- funmap.c~0  2014-06-11 18:34:41 +0300
+++ funmap.c    2014-12-30 12:14:59 +0200
@@ -113,7 +113,7 @@
   { "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__
+#if defined (_WIN32)
   { "paste-from-clipboard", rl_paste_from_clipboard },
 #endif
   { "possible-completions", rl_possible_completions },


--- kill.c~0    2014-06-11 18:34:41 +0300
+++ kill.c      2014-12-30 12:15:38 +0200
@@ -656,8 +656,8 @@
   return retval;
 }
 
-/* A special paste command for users of Cygnus's cygwin32. */
-#if defined (__CYGWIN__)
+/* A special paste command for users of MS-Windows. */
+#if defined (_WIN32)
 #include <windows.h>
 
 int
@@ -691,4 +691,4 @@
     }
   return (0);
 }
-#endif /* __CYGWIN__ */
+#endif /* _WIN32 */

--- readline.h~0        2014-06-11 18:34:41 +0300
+++ readline.h  2014-12-30 12:35:12 +0200
@@ -172,8 +172,8 @@
 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
 

A few issues with home and temporary directories on MS-Windows:

--- histfile.c~0        2014-06-11 18:34:41 +0300
+++ histfile.c  2014-12-30 12:17:52 +0200
@@ -123,6 +123,10 @@
     return (return_val);
   
   home = sh_get_env_value ("HOME");
+#ifdef _WIN32
+  if (!home)
+    home = sh_get_env_value ("APPDATA");
+#endif
 
   if (home == 0)
     {


--- tilde.c~0   2014-06-11 18:34:41 +0300
+++ tilde.c     2014-12-30 12:30:08 +0200
@@ -360,6 +360,10 @@
     {
       /* 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. */


--- util.c~0    2014-06-11 18:34:41 +0300
+++ util.c      2014-12-30 12:36:27 +0200
@@ -56,6 +56,8 @@
 #include "rlprivate.h"
 #include "xmalloc.h"
 
+#include "rlshell.h"
+
 /* **************************************************************** */
 /*                                                                 */
 /*                     Utility Functions                           */
@@ -507,7 +509,17 @@
 
   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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]