OSDN Git Service

* fhandler.cc (fhandler_base::open): Don't set binmode if already set. Don't
authorcgf <cgf>
Tue, 4 Jun 2002 01:40:53 +0000 (01:40 +0000)
committercgf <cgf>
Tue, 4 Jun 2002 01:40:53 +0000 (01:40 +0000)
check for file.  Files should already be set.  Report on binary mode for
debugging.
(fhandler_base::fhandler_base): Don't set default binmode here.  That's for
later.
* fhandler_console.cc (fhandler_console::output_tcsetattr): Don't set binmode,
ever, for console.
* fhandler_disk_file.cc (fhandler_disk_file::open): Always set the binary mode
to the value derived from mount table.
* path.cc (mount_info::conv_to_win32_path): Default to binmode if path does not
translate into anything in the mount table.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_disk_file.cc
winsup/cygwin/path.cc

index 54113f9..cd012c6 100644 (file)
@@ -1,3 +1,17 @@
+2002-06-03  Christopher Faylor  <cgf@redhat.com>
+
+       * fhandler.cc (fhandler_base::open): Don't set binmode if already set.
+       Don't check for file.  Files should already be set.  Report on binary
+       mode for debugging.
+       (fhandler_base::fhandler_base): Don't set default binmode here.  That's
+       for later.
+       * fhandler_console.cc (fhandler_console::output_tcsetattr): Don't set
+       binmode, ever, for console.
+       * fhandler_disk_file.cc (fhandler_disk_file::open): Always set the
+       binary mode to the value derived from mount table.
+       * path.cc (mount_info::conv_to_win32_path): Default to binmode if path
+       does not translate into anything in the mount table.
+
 2002-06-03  Corinna Vinschen  <corinna@vinschen.de>
 
        * external.cc (cygwin_internal): Add CW_EXTRACT_DOMAIN_AND_USER
index 71860d2..820096b 100644 (file)
@@ -424,27 +424,30 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
     set_file_attribute (has_acls (), get_win32_name (), mode);
 
   set_io_handle (x);
-  int bin;
-  int fmode;
-  if ((bin = flags & (O_BINARY | O_TEXT)))
-    /* nothing to do */;
-  else if ((fmode = get_default_fmode (flags)) & O_BINARY)
-    bin = O_BINARY;
-  else if (fmode & O_TEXT)
-    bin = O_TEXT;
-  else if (get_device () == FH_DISK)
-    bin = get_w_binary () || get_r_binary () || 1;
+  if (get_w_binset () && get_r_binset ())
+    syscall_printf ("filemode already set to %d/%d", get_r_binary (), get_w_binary ());
   else
-    bin = get_w_binary () || get_r_binary () || (binmode != O_TEXT);
+    {
+      int bin;
+      int fmode;
+      if ((bin = flags & (O_BINARY | O_TEXT)))
+       /* nothing to do */;
+      else if ((fmode = get_default_fmode (flags)) & O_BINARY)
+       bin = O_BINARY;
+      else if (fmode & O_TEXT)
+       bin = O_TEXT;
+      else
+       bin = get_w_binary () || get_r_binary () || (binmode != O_TEXT);
 
-  if (bin & O_TEXT)
-    bin = 0;
+      if (bin & O_TEXT)
+       bin = 0;
 
-  set_flags (flags | (bin ? O_BINARY : O_TEXT));
+      set_flags (flags | (bin ? O_BINARY : O_TEXT));
 
-  set_r_binary (bin);
-  set_w_binary (bin);
-  syscall_printf ("filemode set to %s", bin ? "binary" : "text");
+      set_r_binary (bin);
+      set_w_binary (bin);
+      syscall_printf ("filemode set to %s", bin ? "binary" : "text");
+    }
 
   res = 1;
   set_open_status ();
@@ -859,7 +862,7 @@ fhandler_base::init (HANDLE f, DWORD a, mode_t bin)
     oflags = O_RDWR;
   set_flags (oflags | (bin ? O_BINARY : O_TEXT));
   set_open_status ();
-  debug_printf ("created new fhandler_base for handle %p", f);
+  debug_printf ("created new fhandler_base for handle %p, bin %d", f, get_r_binary ());
 }
 
 void
@@ -1019,6 +1022,7 @@ fhandler_base::fhandler_base (DWORD devtype, int unit):
   win32_path_name (NULL),
   open_status (0)
 {
+#if 0
   int bin = __fmode & O_TEXT ? 0 : 1;
   if (status != FH_DISK && status != FH_CONSOLE)
     {
@@ -1027,6 +1031,7 @@ fhandler_base::fhandler_base (DWORD devtype, int unit):
       if (!get_w_binset ())
        set_w_binary (bin);
     }
+#endif
 }
 
 /* Normal I/O destructor */
index ac4f9ba..64959e9 100644 (file)
@@ -719,8 +719,10 @@ fhandler_console::output_tcsetattr (int, struct termios const *t)
   /* Ignore the optional_actions stuff, since all output is emitted
      instantly */
 
+#if 0
   /* Enable/disable LF -> CRLF conversions */
   set_w_binary ((t->c_oflag & ONLCR) ? 0 : 1);
+#endif
 
   /* All the output bits we can ignore */
 
index c7c78ab..167edf4 100644 (file)
@@ -339,11 +339,8 @@ fhandler_disk_file::open (path_conv *real_path, int flags, mode_t mode)
       return 0;
     }
 
-  if (real_path->isbinary ())
-    {
-      set_r_binary (1);
-      set_w_binary (1);
-    }
+  set_r_binary (real_path->isbinary ());
+  set_w_binary (real_path->isbinary ());
 
   set_has_acls (real_path->has_acls ());
   set_isremote (real_path->isremote ());
index 3b8a2d8..e6a9483 100644 (file)
@@ -1508,7 +1508,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
   if (i >= nmounts)
     {
       backslashify (pathbuf, dst, 0);  /* just convert */
-      *flags = 0;
+      *flags = PATH_BINARY;            /* Default to binmode */
     }
   else
     {