From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Ehud Karni" Newsgroups: gmane.emacs.devel Subject: Patch for invalid chars in file names on Cygwin Date: Sat, 20 Aug 2005 18:54:07 +0300 Organization: Mivtach-Simon Insurance agencies Message-ID: <200508201554.j7KFs7B3011682@beta.mvs.co.il> Reply-To: ehud@unix.mvs.co.il NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-8-i Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1124554126 30228 80.91.229.2 (20 Aug 2005 16:08:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 20 Aug 2005 16:08:46 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 20 18:08:40 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E6Vry-0003mB-3V for ged-emacs-devel@m.gmane.org; Sat, 20 Aug 2005 18:06:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E6Vvb-0007Cs-5l for ged-emacs-devel@m.gmane.org; Sat, 20 Aug 2005 12:10:39 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E6Vqv-00051A-GD for emacs-devel@gnu.org; Sat, 20 Aug 2005 12:05:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E6Vqk-0004tW-Gy for emacs-devel@gnu.org; Sat, 20 Aug 2005 12:05:41 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E6Vqi-0004eY-VU for emacs-devel@gnu.org; Sat, 20 Aug 2005 12:05:37 -0400 Original-Received: from [193.16.147.12] (helo=unix.mvs.co.il) by monty-python.gnu.org with esmtp (Exim 4.34) id 1E6Vfv-0007WZ-Jt for emacs-devel@gnu.org; Sat, 20 Aug 2005 11:54:28 -0400 Original-Received: from beta.mvs.co.il (beta [10.253.0.3]) by unix.mvs.co.il (8.13.0/8.13.0) with ESMTP id j7KFs8Qj014673 for ; Sat, 20 Aug 2005 18:54:08 +0300 Original-Received: from beta.mvs.co.il (localhost [127.0.0.1]) by beta.mvs.co.il (8.13.4/8.13.4) with ESMTP id j7KFs7wN011685 for ; Sat, 20 Aug 2005 18:54:07 +0300 Original-Received: (from root@localhost) by beta.mvs.co.il (8.13.4/8.13.4/Submit) id j7KFs7B3011682; Sat, 20 Aug 2005 18:54:07 +0300 Original-To: emacs-devel@gnu.org X-Mailer: Emacs 21.3.1 rmail (send-msg 1.108) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:42275 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:42275 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 * 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 ;; 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 Better Safe Than Sorry