unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [gmane.emacs.xemacs.beta] [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")
@ 2006-11-01 15:16 David Kastrup
  2006-11-01 15:31 ` Lennart Borgman
  0 siblings, 1 reply; 5+ messages in thread
From: David Kastrup @ 2006-11-01 15:16 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 347 bytes --]


Saw the following bug report on the XEmacs developer list.  The code
in fileio.c in Emacs is very much identical, lines 446 and 472 would
seem to be relevant to the problem.

I don't have a Windows Emacs available, so I can't vouch for this
actually crashing Emacs too, but I consider it quite likely.

Somebody using Windows better check this.


[-- Attachment #2: Type: message/rfc822, Size: 2513 bytes --]

From: stephen@xemacs.org
Cc: XEmacs Beta <xemacs-beta@xemacs.org>
Subject: [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")
Date: Wed, 01 Nov 2006 23:41:46 +0900
Message-ID: <87lkmv5ivp.fsf@uwakimon.sk.tsukuba.ac.jp>

Adrian Aichner writes:

 > Just evaluate
 > (file-name-directory "1:")
 > in the *scratch* buffer (without any unsaved autobiographies or other
 > work close to your heart).

This is only a problem on Windows.  Here's the problem, I think, in
fileio.c:find_end_of_directory_component:

------------------------------------------------------------------------
  while (p != path && !IS_DIRECTORY_SEP (p[-1])
#ifdef WIN32_FILENAMES
	 /* only recognise drive specifier at the beginning */
	 && !(p[-1] == ':'
	      /* handle the "/:d:foo" and "/:foo" cases correctly  */
	      && ((p == path + 2 && !IS_DIRECTORY_SEP (*path))
		  || (p == path + 4 && IS_DIRECTORY_SEP (*path))))
#endif
	 ) p--;
------------------------------------------------------------------------

This code doesn't check whether the X in "X:" is a valid drive letter
or not!  My guess would be that if X is a valid drive letter, you
won't have a problem.  Could you try `(file-name-directory "X:")' for
X = "C" and X = "S" (or some other letter that definitely isn't mapped
to a drive on your system)?  I'll bet that it crashes for X = ".", or
anything else that isn't a valid drive letter, too.

Even if it doesn't fix the crash, if the IS_VALID_DRIVE_LETTER macro
exists, then it seems to me the above fragment should be

------------------------------------------------------------------------
  while (p != path && !IS_DIRECTORY_SEP (p[-1])
#ifdef WIN32_FILENAMES
	 /* only recognise drive specifier at the beginning */
	 && !(p == path + 2 && path[1] == ':' && IS_VALID_DRIVE_LETTER (*path))
#endif
	 ) p--;
------------------------------------------------------------------------

It might be even more sane (not to mention faster) to

------------------------------------------------------------------------
#ifdef WIN32_FILENAMES
  const Ibyte *beg = (path[0] && path[1] && path[1] == ':'
                      && IS_VALID_DRIVE_LETTER (path[0])) ? path + 2 : path;
#else
  const Ibyte *beg = path;
#endif

  while (p != beg && !IS_DIRECTORY_SEP (p[-1])) p--;
------------------------------------------------------------------------

don't you think?

[-- Attachment #3: Type: text/plain, Size: 52 bytes --]



-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: [gmane.emacs.xemacs.beta] [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")
  2006-11-01 15:16 [gmane.emacs.xemacs.beta] [Bug: 21.5-b27] [CRASH] (file-name-directory "1:") David Kastrup
@ 2006-11-01 15:31 ` Lennart Borgman
  2006-11-01 15:33   ` Lennart Borgman
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2006-11-01 15:31 UTC (permalink / raw)
  Cc: emacs-devel

David Kastrup wrote:
> Saw the following bug report on the XEmacs developer list.  The code
> in fileio.c in Emacs is very much identical, lines 446 and 472 would
> seem to be relevant to the problem.
>
> I don't have a Windows Emacs available, so I can't vouch for this
> actually crashing Emacs too, but I consider it quite likely.
>
> Somebody using Windows better check this.
>
>   
>
> ------------------------------------------------------------------------
>
> Subject:
> [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")
> From:
> stephen@xemacs.org
> Date:
> Wed, 01 Nov 2006 23:41:46 +0900
>
> CC:
> XEmacs Beta <xemacs-beta@xemacs.org>
> Newsgroups:
> gmane.emacs.xemacs.beta
>
>
> Adrian Aichner writes:
>
>  > Just evaluate
>  > (file-name-directory "1:")
>  > in the *scratch* buffer (without any unsaved autobiographies or other
>  > work close to your heart).
>
> This is only a problem on Windows.  Here's the problem, I think, in
> fileio.c:find_end_of_directory_component:
>
> ------------------------------------------------------------------------
>   while (p != path && !IS_DIRECTORY_SEP (p[-1])
> #ifdef WIN32_FILENAMES
> 	 /* only recognise drive specifier at the beginning */
> 	 && !(p[-1] == ':'
> 	      /* handle the "/:d:foo" and "/:foo" cases correctly  */
> 	      && ((p == path + 2 && !IS_DIRECTORY_SEP (*path))
> 		  || (p == path + 4 && IS_DIRECTORY_SEP (*path))))
> #endif
> 	 ) p--;
> ------------------------------------------------------------------------
>
> This code doesn't check whether the X in "X:" is a valid drive letter
> or not!  My guess would be that if X is a valid drive letter, you
> won't have a problem.  Could you try `(file-name-directory "X:")' for
> X = "C" and X = "S" (or some other letter that definitely isn't mapped
> to a drive on your system)?  I'll bet that it crashes for X = ".", or
> anything else that isn't a valid drive letter, too.
>
> Even if it doesn't fix the crash, if the IS_VALID_DRIVE_LETTER macro
> exists, then it seems to me the above fragment should be
>
> ------------------------------------------------------------------------
>   while (p != path && !IS_DIRECTORY_SEP (p[-1])
> #ifdef WIN32_FILENAMES
> 	 /* only recognise drive specifier at the beginning */
> 	 && !(p == path + 2 && path[1] == ':' && IS_VALID_DRIVE_LETTER (*path))
> #endif
> 	 ) p--;
> ------------------------------------------------------------------------
>
> It might be even more sane (not to mention faster) to
>
> ------------------------------------------------------------------------
> #ifdef WIN32_FILENAMES
>   const Ibyte *beg = (path[0] && path[1] && path[1] == ':'
>                       && IS_VALID_DRIVE_LETTER (path[0])) ? path + 2 : path;
> #else
>   const Ibyte *beg = path;
> #endif
>
>   while (p != beg && !IS_DIRECTORY_SEP (p[-1])) p--;
> ------------------------------------------------------------------------
>
> don't you think?
>   

With CVS Emacs from 2006-10-27 this gives just "1:/" for me.

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

* Re: [gmane.emacs.xemacs.beta] [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")
  2006-11-01 15:31 ` Lennart Borgman
@ 2006-11-01 15:33   ` Lennart Borgman
  2006-11-01 15:46     ` Juanma Barranquero
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2006-11-01 15:33 UTC (permalink / raw)


Lennart Borgman wrote:
>
> With CVS Emacs from 2006-10-27 this gives just "1:/" for me.
>

But on the other hand (file-name-directory "é:") gives nil.

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

* Re: [gmane.emacs.xemacs.beta] [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")
  2006-11-01 15:33   ` Lennart Borgman
@ 2006-11-01 15:46     ` Juanma Barranquero
  2006-11-05 13:09       ` Adrian Aichner
  0 siblings, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2006-11-01 15:46 UTC (permalink / raw)
  Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On 11/1/06, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:

> But on the other hand (file-name-directory "é:") gives nil.

 (file-name-directory (string (multibyte-char-as-unibyte ?é) ?:))

  => "\311:/"

I guess `file-name-directory' is treating "é:" as unibyte, so its
second char is not `:', so it's not a drive:path.

All in all, perhaps `file-name-directory' should check that the X in
X: is in the 'A'..'Z' range.

-- 
                    /L/e/k/t/u

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: [gmane.emacs.xemacs.beta] [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")
  2006-11-01 15:46     ` Juanma Barranquero
@ 2006-11-05 13:09       ` Adrian Aichner
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Aichner @ 2006-11-05 13:09 UTC (permalink / raw)


"Juanma Barranquero" <lekktu@gmail.com> writes:

> On 11/1/06, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:
>
>> But on the other hand (file-name-directory "é:") gives nil.
>
> (file-name-directory (string (multibyte-char-as-unibyte ?é) ?:))
>
>  => "\311:/"
>
> I guess `file-name-directory' is treating "é:" as unibyte, so its
> second char is not `:', so it's not a drive:path.
>
> All in all, perhaps `file-name-directory' should check that the X in
> X: is in the 'A'..'Z' range.

Hi!

CVS XEmacs now returns nil for invalid or unavailable drives.

See
http://calypso.tux.org/pipermail/xemacs-patches/2006-November/000036.html

Adrian

-- 
Adrian Aichner
 mailto:adrian@xemacs.org
 http://www.xemacs.org/

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

end of thread, other threads:[~2006-11-05 13:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-01 15:16 [gmane.emacs.xemacs.beta] [Bug: 21.5-b27] [CRASH] (file-name-directory "1:") David Kastrup
2006-11-01 15:31 ` Lennart Borgman
2006-11-01 15:33   ` Lennart Borgman
2006-11-01 15:46     ` Juanma Barranquero
2006-11-05 13:09       ` Adrian Aichner

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