From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ehud@karni.org Newsgroups: gmane.emacs.devel Subject: Patch for invalid chars in file names on Cygwin Date: Thu, 11 Aug 2005 02:18:36 +0300 Organization: The Karni Family Message-ID: <84fyth2xf7.fsf@karni.org> Reply-To: kehud@karni.com NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1123716840 7870 80.91.229.2 (10 Aug 2005 23:34:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 10 Aug 2005 23:34:00 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 11 01:33:55 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E3046-0000wa-R7 for ged-emacs-devel@m.gmane.org; Thu, 11 Aug 2005 01:32:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E307E-0002w5-S9 for ged-emacs-devel@m.gmane.org; Wed, 10 Aug 2005 19:36:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E302Z-0001dk-1Z for emacs-devel@gnu.org; Wed, 10 Aug 2005 19:31:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E302W-0001c8-5e for emacs-devel@gnu.org; Wed, 10 Aug 2005 19:31:17 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E302U-0001QE-VX for emacs-devel@gnu.org; Wed, 10 Aug 2005 19:31:15 -0400 Original-Received: from [193.16.147.12] (helo=unix.mvs.co.il) by monty-python.gnu.org with esmtp (Exim 4.34) id 1E304X-0007jZ-Ik for emacs-devel@gnu.org; Wed, 10 Aug 2005 19:33:23 -0400 Original-Received: from p4-1700-xp (linux [10.253.0.6]) by unix.mvs.co.il (8.13.0/8.13.0) with ESMTP id j7ANIZVF018719 for ; Thu, 11 Aug 2005 02:18:35 +0300 Original-To: jbuehler@spirentcom.com Original-From: Ehud Karni X-Mailer: Emacs 22.0.50.8 (cygwin) rmail 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:41889 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41889 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 * 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 ;; 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 בשחמ תוכרעמב הכימת