unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Removing (most of) directory-sep-char
@ 2010-06-03 20:06 Juanma Barranquero
  2010-06-04  3:00 ` Kevin Rodgers
  2010-06-04  8:38 ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Juanma Barranquero @ 2010-06-03 20:06 UTC (permalink / raw)
  To: Emacs developers

The following patch moves `directory-sep-char' from C to lisp, and
removes all references to it from C code, in effect turning the var
into a noop.

It's OK to commit it? Eli, could this cause any trouble with the MS-DOS port?

    Juanma


2010-06-03  Juanma Barranquero  <lekktu@gmail.com>

	* subr.el (directory-sep-char): Move from fileio.c.


2010-06-03  Juanma Barranquero  <lekktu@gmail.com>

	* lisp.h [WINDOWSNT] (Vdirectory_sep_char): Don't declare.
	(DIRECTORY_SEP): Define unconditionally.

	* s/ms-w32.h (DIRECTORY_SEP): Remove.

	* emacs.c (decode_env_path): Don't check DIRECTORY_SEP,
	call dostounix_filename directly.

	* fileio.c (CORRECT_DIR_SEPS): Remove.
	(Ffile_name_directory, directory_file_name, Fexpand_file_name)
	(Fsubstitute_in_file_name): Use dostounix_filename instead.
	(file_name_as_directory): Use dostounix_filename, DIRECTORY_SEP.
	(syms_of_fileio) <directory-sep-char>: Move to subr.el.

	* w32proc.c (CORRECT_DIR_SEPS): Remove.
	(Fw32_short_file_name, Fw32_long_file_name): Use dostounix_filename.


=== modified file 'lisp/subr.el'
--- lisp/subr.el	2010-06-01 02:34:49 +0000
+++ lisp/subr.el	2010-06-03 19:06:39 +0000
@@ -1089,7 +1089,11 @@
 (make-obsolete 'process-filter-multibyte-p nil "23.1")
 (make-obsolete 'set-process-filter-multibyte nil "23.1")

-(make-obsolete-variable 'directory-sep-char "do not use it." "21.1")
+(defvar directory-sep-char ?/
+  "Directory separator character for built-in functions that return file names.
+The value is always ?/.")
+(make-obsolete-variable 'directory-sep-char "do not use it, just use
`/'." "21.1")
+
 (make-obsolete-variable
  'mode-line-inverse-video
  "use the appropriate faces instead."

=== modified file 'src/emacs.c'
--- src/emacs.c	2010-05-15 21:16:20 +0000
+++ src/emacs.c	2010-06-03 19:06:39 +0000
@@ -2384,10 +2384,7 @@
       strcpy (p, path);
       path = p;

-      if ('/' == DIRECTORY_SEP)
-	dostounix_filename (path);
-      else
-	unixtodos_filename (path);
+      dostounix_filename (path);
     }
 #endif
   lpath = Qnil;

=== modified file 'src/fileio.c'
--- src/fileio.c	2010-05-28 14:57:11 +0000
+++ src/fileio.c	2010-06-03 19:14:20 +0000
@@ -83,10 +83,6 @@
 #endif

 #ifdef DOS_NT
-#define CORRECT_DIR_SEPS(s) \
-  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
-       else unixtodos_filename (s); \
-  } while (0)
 /* On Windows, drive letters must be alphabetic - on DOS, the Netware
    redirector allows the six letters between 'Z' and 'a' as well. */
 #ifdef MSDOS
@@ -474,7 +470,7 @@
 	  p = beg + strlen (beg);
 	}
     }
-  CORRECT_DIR_SEPS (beg);
+  dostounix_filename (beg);
 #endif /* DOS_NT */

   return make_specified_string (beg, -1, p - beg, STRING_MULTIBYTE (filename));
@@ -561,12 +557,11 @@
   /* For Unix syntax, Append a slash if necessary */
   if (!IS_DIRECTORY_SEP (out[size]))
     {
-      /* Cannot use DIRECTORY_SEP, which could have any value */
-      out[size + 1] = '/';
+      out[size + 1] = DIRECTORY_SEP;
       out[size + 2] = '\0';
     }
 #ifdef DOS_NT
-  CORRECT_DIR_SEPS (out);
+  dostounix_filename (out);
 #endif
   return out;
 }
@@ -627,7 +622,7 @@
       )
     dst[slen - 1] = 0;
 #ifdef DOS_NT
-  CORRECT_DIR_SEPS (dst);
+  dostounix_filename (dst);
 #endif
   return 1;
 }
@@ -1032,10 +1027,9 @@
       if (!lose)
 	{
 #ifdef DOS_NT
-	  /* Make sure directories are all separated with / or \ as
-	     desired, but avoid allocation of a new string when not
-	     required. */
-	  CORRECT_DIR_SEPS (nm);
+	  /* Make sure directories are all separated with /, but
+	     avoid allocation of a new string when not required. */
+	  dostounix_filename (nm);
 #ifdef WINDOWSNT
 	  if (IS_DIRECTORY_SEP (nm[1]))
 	    {
@@ -1381,7 +1375,7 @@
 	target[0] = '/';
 	target[1] = ':';
       }
-    CORRECT_DIR_SEPS (target);
+    dostounix_filename (target);
 #endif /* DOS_NT */

     result = make_specified_string (target, -1, o - target, multibyte);
@@ -1659,7 +1653,7 @@
   bcopy (SDATA (filename), nm, SBYTES (filename) + 1);

 #ifdef DOS_NT
-  CORRECT_DIR_SEPS (nm);
+  dostounix_filename (nm);
   substituted = (strcmp (nm, SDATA (filename)) != 0);
 #endif
   endp = nm + SBYTES (filename);
@@ -5787,11 +5781,6 @@
   Fput (Qfile_date_error, Qerror_message,
 	make_pure_c_string ("Cannot set file date"));

-  DEFVAR_LISP ("directory-sep-char", &Vdirectory_sep_char,
-	       doc: /* Directory separator character for built-in functions
that return file names.
-The value is always ?/.  Don't use this variable, just use `/'.  */);
-  XSETFASTINT (Vdirectory_sep_char, '/');
-
   DEFVAR_LISP ("file-name-handler-alist", &Vfile_name_handler_alist,
 	       doc: /* *Alist of elements (REGEXP . HANDLER) for file names
handled specially.
 If a file name matches REGEXP, then all I/O on that file is done by calling

=== modified file 'src/lisp.h'
--- src/lisp.h	2010-05-27 23:30:11 +0000
+++ src/lisp.h	2010-06-03 19:19:30 +0000
@@ -3509,16 +3509,10 @@
 extern void init_system_name P_ ((void));

 /* Some systems (e.g., NT) use a different path separator than Unix,
-   in addition to a device separator.  Default the path separator
+   in addition to a device separator.  Set the path separator
    to '/', and don't test for a device separator in IS_ANY_SEP.  */

-#ifdef WINDOWSNT
-extern Lisp_Object Vdirectory_sep_char;
-#endif
-
-#ifndef DIRECTORY_SEP
 #define DIRECTORY_SEP '/'
-#endif
 #ifndef IS_DIRECTORY_SEP
 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
 #endif

=== modified file 'src/s/ms-w32.h'
--- src/s/ms-w32.h	2010-05-12 06:53:03 +0000
+++ src/s/ms-w32.h	2010-06-03 19:06:39 +0000
@@ -95,9 +95,6 @@
    your system and must be used only through an encapsulation (which
    you should place, by convention, in sysdep.c).  */

-/* Define this to be the separator between path elements.  */
-#define DIRECTORY_SEP XINT (Vdirectory_sep_char)
-
 /* Define this to be the separator between devices and paths.  */
 #define DEVICE_SEP ':'


=== modified file 'src/w32proc.c'
--- src/w32proc.c	2010-01-13 08:35:10 +0000
+++ src/w32proc.c	2010-06-03 19:06:39 +0000
@@ -1762,12 +1762,6 @@
 /* Some miscellaneous functions that are Windows specific, but not GUI
    specific (ie. are applicable in terminal or batch mode as well).  */

-/* lifted from fileio.c  */
-#define CORRECT_DIR_SEPS(s) \
-  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
-       else unixtodos_filename (s); \
-  } while (0)
-
 DEFUN ("w32-short-file-name", Fw32_short_file_name,
Sw32_short_file_name, 1, 1, 0,
        doc: /* Return the short file name version (8.3) of the full
path of FILENAME.
 If FILENAME does not exist, return nil.
@@ -1786,7 +1780,7 @@
   if (GetShortPathName (SDATA (ENCODE_FILE (filename)), shortname,
MAX_PATH) == 0)
     return Qnil;

-  CORRECT_DIR_SEPS (shortname);
+  dostounix_filename (shortname);

   return build_string (shortname);
 }
@@ -1815,7 +1809,7 @@
   if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)),
longname, MAX_PATH))
     return Qnil;

-  CORRECT_DIR_SEPS (longname);
+  dostounix_filename (longname);

   /* If we were passed only a drive, make sure that a slash is not appended
      for consistency with directories.  Allow for drive mapping via SUBST



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Removing (most of) directory-sep-char
  2010-06-03 20:06 Removing (most of) directory-sep-char Juanma Barranquero
@ 2010-06-04  3:00 ` Kevin Rodgers
  2010-06-04  8:40   ` Eli Zaretskii
  2010-06-04 10:20   ` Juanma Barranquero
  2010-06-04  8:38 ` Eli Zaretskii
  1 sibling, 2 replies; 8+ messages in thread
From: Kevin Rodgers @ 2010-06-04  3:00 UTC (permalink / raw)
  To: emacs-devel

Juanma Barranquero wrote:
> The following patch moves `directory-sep-char' from C to lisp, and
> removes all references to it from C code, in effect turning the var
> into a noop.

Does Emacs still support files with backslash in their name on non-DOS/
Windows platforms with your patch?

(By support, I mean visit files via find-file and dired.)

Thanks,

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Removing (most of) directory-sep-char
  2010-06-03 20:06 Removing (most of) directory-sep-char Juanma Barranquero
  2010-06-04  3:00 ` Kevin Rodgers
@ 2010-06-04  8:38 ` Eli Zaretskii
  2010-06-04 10:22   ` Juanma Barranquero
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2010-06-04  8:38 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Thu, 3 Jun 2010 22:06:15 +0200
> 
> The following patch moves `directory-sep-char' from C to lisp, and
> removes all references to it from C code, in effect turning the var
> into a noop.
> 
> It's OK to commit it? 

It's fine with me, thanks.

> Eli, could this cause any trouble with the MS-DOS port?

No.  The MS-DOS port never really supported backslashes except as an
accident.  It is much more radical than the Windows port in using
forward slashes (and all the other Posix features).  It even converts
all file names in PATH to use forward slashes, and passes that to
subprocesses.  See msdos.c.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Removing (most of) directory-sep-char
  2010-06-04  3:00 ` Kevin Rodgers
@ 2010-06-04  8:40   ` Eli Zaretskii
  2010-06-04 10:20   ` Juanma Barranquero
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2010-06-04  8:40 UTC (permalink / raw)
  To: Kevin Rodgers; +Cc: emacs-devel

> From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
> Date: Thu, 03 Jun 2010 21:00:38 -0600
> 
> Juanma Barranquero wrote:
> > The following patch moves `directory-sep-char' from C to lisp, and
> > removes all references to it from C code, in effect turning the var
> > into a noop.
> 
> Does Emacs still support files with backslash in their name on non-DOS/
> Windows platforms with your patch?

I don't see how any of Juanma's changes could affect Posix platforms,
since all the changes are in portions of code conditioned by #ifdef DOS_NT.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Removing (most of) directory-sep-char
  2010-06-04  3:00 ` Kevin Rodgers
  2010-06-04  8:40   ` Eli Zaretskii
@ 2010-06-04 10:20   ` Juanma Barranquero
  1 sibling, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2010-06-04 10:20 UTC (permalink / raw)
  To: Kevin Rodgers; +Cc: emacs-devel

On Fri, Jun 4, 2010 at 05:00, Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote:

> Does Emacs still support files with backslash in their name on non-DOS/
> Windows platforms with your patch?
>
> (By support, I mean visit files via find-file and dired.)

I don't expect my patch to affect non-DOS_NT platforms, but if it
does, then that'd be bugs (on non-DOS_NT code) that would have to be
addressed when found.

    Juanma



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Removing (most of) directory-sep-char
  2010-06-04  8:38 ` Eli Zaretskii
@ 2010-06-04 10:22   ` Juanma Barranquero
  2010-06-04 13:25     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Juanma Barranquero @ 2010-06-04 10:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Fri, Jun 4, 2010 at 10:38, Eli Zaretskii <eliz@gnu.org> wrote:

> It's fine with me, thanks.

Cool.

Stefan, Chong?

> No.  The MS-DOS port never really supported backslashes except as an
> accident.  It is much more radical than the Windows port in using
> forward slashes (and all the other Posix features).

I supposed as much, but better ask than break. Thanks.

    Juanma



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Removing (most of) directory-sep-char
  2010-06-04 10:22   ` Juanma Barranquero
@ 2010-06-04 13:25     ` Stefan Monnier
  2010-06-04 14:25       ` Juanma Barranquero
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2010-06-04 13:25 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Eli Zaretskii, emacs-devel

>> It's fine with me, thanks.
> Cool.
> Stefan, Chong?

Fine with me, except it should be a defconst, not a defvar.


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Removing (most of) directory-sep-char
  2010-06-04 13:25     ` Stefan Monnier
@ 2010-06-04 14:25       ` Juanma Barranquero
  0 siblings, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2010-06-04 14:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel

> Fine with me, except it should be a defconst, not a defvar.

Done, and installed.

Thanks.

    Juanma



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-06-04 14:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-03 20:06 Removing (most of) directory-sep-char Juanma Barranquero
2010-06-04  3:00 ` Kevin Rodgers
2010-06-04  8:40   ` Eli Zaretskii
2010-06-04 10:20   ` Juanma Barranquero
2010-06-04  8:38 ` Eli Zaretskii
2010-06-04 10:22   ` Juanma Barranquero
2010-06-04 13:25     ` Stefan Monnier
2010-06-04 14:25       ` Juanma Barranquero

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).