unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch for invalid chars in file names on Cygwin
@ 2005-08-10 23:18 ehud
  2005-08-11 12:03 ` Joe Buehler
  0 siblings, 1 reply; 3+ messages in thread
From: ehud @ 2005-08-10 23:18 UTC (permalink / raw)
  Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 9535 bytes --]

I discovered today that `convert-standard-filename' on Cygwin does 
nothing and as result `make-temp-file' fails for name like "*mail*".
The change in `make-auto-save-file-name' in 22.0.50 to call 
`make-temp-file' (it was `make-temp-name' before) made `compose-mail'
fails on Cygwin.

I created a new file `cygwin.el' to have Cygwin specific functions
(for now just one). Below is a patch that fix this problem.

Note. Joe, I don't have CVS write permission, so pleas check my patch
and if you find it appropriate, please install it.

Ehud.


2005-08-11  Ehud Karni  <ehud@unix.mvs.co.il>
           
	* files.el (convert-standard-filename): change documentation.
	(abbreviate-file-name): replace or by memq.
        (make-auto-save-file-name): call `convert-standard-filename'
        when OS is Cygwin too.

	* loadup.el load cygwin when OS is Cygwin. Dump on Cygwin
        with 2 names (as on UNIX).

	* cygwin.el - new file. (convert-standard-filename): new function
        to ensure valid file name on Cygwin.


diff -c lisp/files.el.\~1.781.\~ lisp/files-new.el
*** lisp/files.el.~1.781.~	Mon Aug  1 16:58:48 2005
--- lisp/files-new.el	Thu Aug 11 00:10:55 2005
***************
*** 517,526 ****
  This function's standard definition is trivial; it just returns
  the argument.  However, on Windows and DOS, replace invalid
  characters.  On DOS, make sure to obey the 8.3 limitations.  On
! Windows, turn Cygwin names into native names, and also turn
! slashes into backslashes if the shell requires it (see
  `w32-shell-dos-semantics').
  
  See Info node `(elisp)Standard File Names' for more details."
    filename)
  
--- 517,528 ----
  This function's standard definition is trivial; it just returns
  the argument.  However, on Windows and DOS, replace invalid
  characters.  On DOS, make sure to obey the 8.3 limitations.  On
! Windows (native), turn Cygwin names into native names, and also
! turn slashes into backslashes if the shell requires it (see
  `w32-shell-dos-semantics').
  
+ On Cygwin, replace invalid Windows characters.
+ 
  See Info node `(elisp)Standard File Names' for more details."
    filename)
  
***************
*** 1232,1240 ****
  		       (= (aref filename 0) ?/)))
  	     ;; MS-DOS root directories can come with a drive letter;
  	     ;; Novell Netware allows drive letters beyond `Z:'.
! 	     (not (and (or (eq system-type 'ms-dos)
! 			   (eq system-type 'cygwin)
! 			   (eq system-type 'windows-nt))
  		       (save-match-data
  			 (string-match "^[a-zA-`]:/$" filename)))))
  	(setq filename
--- 1234,1240 ----
  		       (= (aref filename 0) ?/)))
  	     ;; MS-DOS root directories can come with a drive letter;
  	     ;; Novell Netware allows drive letters beyond `Z:'.
! 	     (not (and (memq system-type '(ms-dos windows-nt cygwin))
  		       (save-match-data
  			 (string-match "^[a-zA-`]:/$" filename)))))
  	(setq filename
***************
*** 4099,4105 ****
  			"#")))
  	;; Make sure auto-save file names don't contain characters
  	;; invalid for the underlying filesystem.
! 	(if (and (memq system-type '(ms-dos windows-nt))
  		 ;; Don't modify remote (ange-ftp) filenames
  		 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result)))
  	    (convert-standard-filename result)
--- 4099,4105 ----
  			"#")))
  	;; Make sure auto-save file names don't contain characters
  	;; invalid for the underlying filesystem.
! 	(if (and (memq system-type '(ms-dos windows-nt cygwin)
  		 ;; Don't modify remote (ange-ftp) filenames
  		 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result)))
  	    (convert-standard-filename result)
***************
*** 4134,4140 ****
  		      ((file-writable-p default-directory) default-directory)
  		      ((file-writable-p "/var/tmp/") "/var/tmp/")
  		      ("~/")))))
! 	       (if (and (memq system-type '(ms-dos windows-nt))
  			;; Don't modify remote (ange-ftp) filenames
  			(not (string-match "^/\\w+@[-A-Za-z0-9._]+:" fname)))
  		   ;; The call to convert-standard-filename is in case
--- 4134,4140 ----
  		      ((file-writable-p default-directory) default-directory)
  		      ((file-writable-p "/var/tmp/") "/var/tmp/")
  		      ("~/")))))
! 	       (if (and (memq system-type '(ms-dos windows-nt cygwin))
  			;; Don't modify remote (ange-ftp) filenames
  			(not (string-match "^/\\w+@[-A-Za-z0-9._]+:" fname)))
  		   ;; The call to convert-standard-filename is in case

Diff finished.  Thu Aug 11 00:12:50 2005


diff -c lisp/loadup.el.\~1.140.\~ lisp/loadup-new.el
*** lisp/loadup.el.~1.140.~	Mon Jul 11 19:32:54 2005
--- lisp/loadup-new.el	Wed Aug 10 23:30:55 2005
***************
*** 166,171 ****
--- 166,174 ----
  (if (eq system-type 'vax-vms)
      (progn
        (load "vms-patch")))
+ (if (eq system-type 'cygwin)
+     (progn
+       (load "cygwin")))
  (if (eq system-type 'windows-nt)
      (progn
        (load "ls-lisp")
***************
*** 320,346 ****
  	  (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  			     "-"
  			     (substring name (match-end 0)))))
! 	(if (memq system-type '(ms-dos windows-nt cygwin))
  	    (message "Dumping under the name emacs")
! 	  (message "Dumping under names emacs and %s" name)))
!       (condition-case ()
! 	  (delete-file "emacs")
! 	(file-error nil))
!       ;; We used to dump under the name xemacs, but that occasionally
!       ;; confused people installing Emacs (they'd install the file
!       ;; under the name `xemacs'), and it's inconsistent with every
!       ;; other GNU program's build process.
!       (dump-emacs "emacs" "temacs")
!       (message "%d pure bytes used" pure-bytes-used)
!       ;; Recompute NAME now, so that it isn't set when we dump.
!       (if (not (memq system-type '(ms-dos windows-nt cygwin)))
! 	  (let ((name (concat "emacs-" emacs-version)))
! 	    (while (string-match "[^-+_.a-zA-Z0-9]+" name)
! 	      (setq name (concat (downcase (substring name 0 (match-beginning 0)))
! 				 "-"
! 				 (substring name (match-end 0)))))
! 	    (add-name-to-file "emacs" name t)))
!       (kill-emacs)))
  
  ;; Avoid error if user loads some more libraries now.
  (setq purify-flag nil)
--- 323,346 ----
  	  (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  			     "-"
  			     (substring name (match-end 0)))))
! 	(if (memq system-type '(ms-dos windows-nt))
  	    (message "Dumping under the name emacs")
! 	  (message "Dumping under names emacs and %s" name))
! 	(condition-case ()
! 	    (delete-file "emacs")
! 	  (file-error nil))
! 	;; We used to dump under the name xemacs, but that occasionally
! 	;; confused people installing Emacs (they'd install the file
! 	;; under the name `xemacs'), and it's inconsistent with every
! 	;; other GNU program's build process.
! 	(dump-emacs "emacs" "temacs")
! 	(message "%d pure bytes used" pure-bytes-used)
! 	;; Recompute NAME now, so that it isn't set when we dump.
! 	(if (not (memq system-type '(ms-dos windows-nt)))
! 	    (if (eq system-type 'cygwin)
! 		(add-name-to-file "emacs.exe" (concat name ".exe") t))
! 	      (add-name-to-file "emacs" name t)))
! 	(kill-emacs)))
  
  ;; Avoid error if user loads some more libraries now.
  (setq purify-flag nil)

Diff finished.  Wed Aug 10 23:49:31 2005

New file  lisp/cygwin.el	Wed Aug 10 23:43:28 2005
********************************************************

;;; cygwin.el --- Lisp routines for Cygwin emulation layer

;; Copyright (C) 2005 Free Software Foundation, Inc.

;; Author: Ehud Karni <ehud@unix.mvs.co.il>
;; Keywords: internal

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; (August 10, 2005)
;; Created.


(defun convert-standard-filename (filename)
  "Convert a standard file's name to something suitable for the OS.
This means to guarantee valid names and perhaps to canonicalize
certain patterns.

FILENAME should be an absolute file name since the conversion rules
sometimes vary depending on the position in the file name.  E.g. c:/foo
is a valid DOS file name, but c:/bar/c:/foo is not.

This function's standard definition is trivial; it just returns
the argument.  However, on Windows and DOS, replace invalid
characters.  On DOS, make sure to obey the 8.3 limitations.  On
Windows (native), turn Cygwin names into native names, and also
turn slashes into backslashes if the shell requires it (see
`w32-shell-dos-semantics').

On Cygwin, replace invalid Windows characters.

See Info node `(elisp)Standard File Names' for more details."
  (let ((name filename)
	(start 0))
    ;; destructively replace invalid filename characters with %
    (while (string-match "[?*:<>|\"\000-\037]" name start)
      (aset name (match-beginning 0) ?%)
      (setq start (match-end 0)))
    name))


;;; arch-tag:
;;; cygwin.el ends here



-- 
Ehud Karni    Better Safe Than Sorry    éðø÷ ãåäà
Senior System Support          áùçî úåëøòîá äëéîú

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

* Re: Patch for invalid chars in file names on Cygwin
  2005-08-10 23:18 ehud
@ 2005-08-11 12:03 ` Joe Buehler
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Buehler @ 2005-08-11 12:03 UTC (permalink / raw)
  Cc: emacs-devel

Ehud Karni wrote:

> I discovered today that `convert-standard-filename' on Cygwin does 
> nothing and as result `make-temp-file' fails for name like "*mail*".
> The change in `make-auto-save-file-name' in 22.0.50 to call 
> `make-temp-file' (it was `make-temp-name' before) made `compose-mail'
> fails on Cygwin.
> 
> I created a new file `cygwin.el' to have Cygwin specific functions
> (for now just one). Below is a patch that fix this problem.
> 
> Note. Joe, I don't have CVS write permission, so pleas check my patch
> and if you find it appropriate, please install it.

I don't have write permission either.  Run the patch by the FSF
developers who do (which I guess you sort of did since you copied
emacs-devel).
-- 
Joe Buehler

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

* Patch for invalid chars in file names on Cygwin
@ 2005-08-20 15:54 Ehud Karni
  0 siblings, 0 replies; 3+ messages in thread
From: Ehud Karni @ 2005-08-20 15:54 UTC (permalink / raw)


On 2005-08-11 I sent the following patch for Cygwin handling of file
names. I did not get any response. Please check this and comment.

[Repeat of that email, with new diffs against the newer versions]

I discovered today that `convert-standard-filename' on Cygwin does
nothing and as result `make-temp-file' fails for name like "*mail*".
The change in `make-auto-save-file-name' in 22.0.50 to call
`make-temp-file' (it was `make-temp-name' before) made `compose-mail'
fails on Cygwin.

I created a new file `cygwin.el' to have Cygwin specific functions
(for now just one). Below is a patch that fix this problem.

Note. I don't have CVS write permission, so pleas check my patch
and if you find it appropriate, please install it.

Ehud.



2005-08-11  Ehud Karni  <ehud@unix.mvs.co.il>

	* files.el (convert-standard-filename): change documentation.
	(abbreviate-file-name): replace or by memq.
        (make-auto-save-file-name): call `convert-standard-filename'
        when OS is Cygwin too.

	* loadup.el load cygwin when OS is Cygwin. Dump on Cygwin
        with 2 names (as on UNIX).

	* cygwin.el - new file. (convert-standard-filename): new function
        to ensure valid file name on Cygwin.


diff -c lisp/files.el.\~1.784.\~ lisp/files.el
*** lisp/files.el.~1.784.~	Mon Aug 15 05:05:01 2005
--- lisp/files.el		Mon Aug 15 23:35:10 2005
***************
*** 517,526 ****
  This function's standard definition is trivial; it just returns
  the argument.  However, on Windows and DOS, replace invalid
  characters.  On DOS, make sure to obey the 8.3 limitations.  On
! Windows, turn Cygwin names into native names, and also turn
! slashes into backslashes if the shell requires it (see
  `w32-shell-dos-semantics').

  See Info node `(elisp)Standard File Names' for more details."
    filename)

--- 517,528 ----
  This function's standard definition is trivial; it just returns
  the argument.  However, on Windows and DOS, replace invalid
  characters.  On DOS, make sure to obey the 8.3 limitations.  On
! Windows (native), turn Cygwin names into native names, and also
! turn slashes into backslashes if the shell requires it (see
  `w32-shell-dos-semantics').

+ On Cygwin, replace invalid Windows characters.
+
  See Info node `(elisp)Standard File Names' for more details."
    filename)

***************
*** 1232,1240 ****
  		       (= (aref filename 0) ?/)))
  	     ;; MS-DOS root directories can come with a drive letter;
  	     ;; Novell Netware allows drive letters beyond `Z:'.
! 	     (not (and (or (eq system-type 'ms-dos)
! 			   (eq system-type 'cygwin)
! 			   (eq system-type 'windows-nt))
  		       (save-match-data
  			 (string-match "^[a-zA-`]:/$" filename)))))
  	(setq filename
--- 1234,1240 ----
  		       (= (aref filename 0) ?/)))
  	     ;; MS-DOS root directories can come with a drive letter;
  	     ;; Novell Netware allows drive letters beyond `Z:'.
! 	     (not (and (memq system-type '(ms-dos windows-nt cygwin))
  		       (save-match-data
  			 (string-match "^[a-zA-`]:/$" filename)))))
  	(setq filename
***************
*** 4098,4104 ****
  			"#")))
  	;; Make sure auto-save file names don't contain characters
  	;; invalid for the underlying filesystem.
! 	(if (and (memq system-type '(ms-dos windows-nt))
  		 ;; Don't modify remote (ange-ftp) filenames
  		 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result)))
  	    (convert-standard-filename result)
--- 4098,4104 ----
  			"#")))
  	;; Make sure auto-save file names don't contain characters
  	;; invalid for the underlying filesystem.
! 	(if (and (memq system-type '(ms-dos windows-nt cygwin))
  		 ;; Don't modify remote (ange-ftp) filenames
  		 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result)))
  	    (convert-standard-filename result)
***************
*** 4133,4139 ****
  		      ((file-writable-p default-directory) default-directory)
  		      ((file-writable-p "/var/tmp/") "/var/tmp/")
  		      ("~/")))))
! 	       (if (and (memq system-type '(ms-dos windows-nt))
  			;; Don't modify remote (ange-ftp) filenames
  			(not (string-match "^/\\w+@[-A-Za-z0-9._]+:" fname)))
  		   ;; The call to convert-standard-filename is in case
--- 4133,4139 ----
  		      ((file-writable-p default-directory) default-directory)
  		      ((file-writable-p "/var/tmp/") "/var/tmp/")
  		      ("~/")))))
! 	       (if (and (memq system-type '(ms-dos windows-nt cygwin))
  			;; Don't modify remote (ange-ftp) filenames
  			(not (string-match "^/\\w+@[-A-Za-z0-9._]+:" fname)))
  		   ;; The call to convert-standard-filename is in case



diff -c lisp/loadup.el.\~1.141.\~ lisp/loadup.el
*** lisp/loadup.el.~1.141.~	Sun Aug  7 01:13:43 2005
--- lisp/loadup.el		Wed Aug 10 23:30:55 2005
***************
*** 167,172 ****
--- 167,175 ----
  (if (eq system-type 'vax-vms)
      (progn
        (load "vms-patch")))
+ (if (eq system-type 'cygwin)
+     (progn
+       (load "cygwin")))
  (if (eq system-type 'windows-nt)
      (progn
        (load "ls-lisp")
***************
*** 321,347 ****
  	  (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  			     "-"
  			     (substring name (match-end 0)))))
! 	(if (memq system-type '(ms-dos windows-nt cygwin))
  	    (message "Dumping under the name emacs")
! 	  (message "Dumping under names emacs and %s" name)))
!       (condition-case ()
! 	  (delete-file "emacs")
! 	(file-error nil))
!       ;; We used to dump under the name xemacs, but that occasionally
!       ;; confused people installing Emacs (they'd install the file
!       ;; under the name `xemacs'), and it's inconsistent with every
!       ;; other GNU program's build process.
!       (dump-emacs "emacs" "temacs")
!       (message "%d pure bytes used" pure-bytes-used)
!       ;; Recompute NAME now, so that it isn't set when we dump.
!       (if (not (memq system-type '(ms-dos windows-nt cygwin)))
! 	  (let ((name (concat "emacs-" emacs-version)))
! 	    (while (string-match "[^-+_.a-zA-Z0-9]+" name)
! 	      (setq name (concat (downcase (substring name 0 (match-beginning 0)))
! 				 "-"
! 				 (substring name (match-end 0)))))
! 	    (add-name-to-file "emacs" name t)))
!       (kill-emacs)))

  ;; Avoid error if user loads some more libraries now.
  (setq purify-flag nil)
--- 324,347 ----
  	  (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  			     "-"
  			     (substring name (match-end 0)))))
! 	(if (memq system-type '(ms-dos windows-nt))
  	    (message "Dumping under the name emacs")
! 	  (message "Dumping under names emacs and %s" name))
! 	(condition-case ()
! 	    (delete-file "emacs")
! 	  (file-error nil))
! 	;; We used to dump under the name xemacs, but that occasionally
! 	;; confused people installing Emacs (they'd install the file
! 	;; under the name `xemacs'), and it's inconsistent with every
! 	;; other GNU program's build process.
! 	(dump-emacs "emacs" "temacs")
! 	(message "%d pure bytes used" pure-bytes-used)
! 	;; Recompute NAME now, so that it isn't set when we dump.
! 	(if (not (memq system-type '(ms-dos windows-nt)))
! 	    (if (eq system-type 'cygwin)
! 		(add-name-to-file "emacs.exe" (concat name ".exe") t))
! 	      (add-name-to-file "emacs" name t)))
! 	(kill-emacs)))

  ;; Avoid error if user loads some more libraries now.
  (setq purify-flag nil)


New file  lisp/cygwin.el	Wed Aug 10 23:43:28 2005
********************************************************

;;; cygwin.el --- Lisp routines for Cygwin emulation layer

;; Copyright (C) 2005 Free Software Foundation, Inc.

;; Author: Ehud Karni <ehud@unix.mvs.co.il>
;; Keywords: internal

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; (August 10, 2005)
;; Created.


(defun convert-standard-filename (filename)
  "Convert a standard file's name to something suitable for the OS.
This means to guarantee valid names and perhaps to canonicalize
certain patterns.

FILENAME should be an absolute file name since the conversion rules
sometimes vary depending on the position in the file name.  E.g. c:/foo
is a valid DOS file name, but c:/bar/c:/foo is not.

This function's standard definition is trivial; it just returns
the argument.  However, on Windows and DOS, replace invalid
characters.  On DOS, make sure to obey the 8.3 limitations.  On
Windows (native), turn Cygwin names into native names, and also
turn slashes into backslashes if the shell requires it (see
`w32-shell-dos-semantics').

On Cygwin, replace invalid Windows characters.

See Info node `(elisp)Standard File Names' for more details."
  (let ((name filename)
	(start 0))
    ;; destructively replace invalid filename characters with %
    (while (string-match "[?*:<>|\"\000-\037]" name start)
      (aset name (match-beginning 0) ?%)
      (setq start (match-end 0)))
    name))


;;; arch-tag:
;;; cygwin.el ends here



--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry

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

end of thread, other threads:[~2005-08-20 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-20 15:54 Patch for invalid chars in file names on Cygwin Ehud Karni
  -- strict thread matches above, loose matches on Subject: below --
2005-08-10 23:18 ehud
2005-08-11 12:03 ` Joe Buehler

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).