unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: kzhr@d1.dion.ne.jp, michael.albinus@gmx.de, emacs-devel@gnu.org
Subject: Re: Multibyte and unibyte file names
Date: Sun, 27 Jan 2013 20:55:16 -0500	[thread overview]
Message-ID: <jwvip6ijd96.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <834ni3jefn.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 27 Jan 2013 09:03:08 +0200")

>> > OK, but as long as file-name primitives are required to support
>> > unibyte strings, you cannot be sure these situations won't pop up in
>> > the future.
>> I don't see a need to disallow unibyte strings, but I don't see the need
>> to be particularly careful about it either.  Basically Elisp code which
>> provides unibyte file names does it at its own risks.
> What about C code that calls these primitives?  Can we consider every
> such instance a bug in the caller?

Most likely, yes.

>> But that's exactly the behavior stipulated by POSIX (tho for '/' rather
>> than '\\').  I.e. if you use file names on a POSIX host with
>> a coding-system that occasionally uses '/' within its multibyte
>> sequences, you'll get those surprises regardless of Emacs.  And for that
>> reason, Emacs would be right to cut those file names in the middle of
>> a multibyte sequence.
> Then why did you regard this:
>  (let ((file-name-coding-system 'cp932))
>    (expand-file-name "表" "C:/"))
>   => "c:/\225/"
> as a bug?

Because expand-file-name works on Emacs strings, not on
file-system strings.

>> And since Emacs is largely based on "POSIX semantics for the generic
>> code, plus an emulation layer in w32.c", we have a problem of subtly
>> incompatible semantics.
> Maybe so, but it certainly isn't the only place in Emacs with subtly
> incompatible semantics.  And anyway, I don't see how this observation
> helps to decide what, if anything, to do to fix this.

It helps me understand the problem, at least.
Maybe it also points out that we might like to change the interface so
that generic code does not encode strings before passing them to the
OS-specific primitives.

>> Could you specify a bit more precisely which primitives you have
>> in mind?
> Those in fileio.c and in dired.c.  I could give an explicit list, if
> you want.

At least I disagree with your Ffile_name_directory suggestion: if the
file-name is already encoded and it results in bugs, the fix should be
in the caller.


        Stefan



  parent reply	other threads:[~2013-01-28  1:55 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23 17:45 Multibyte and unibyte file names Eli Zaretskii
2013-01-23 18:08 ` Paul Eggert
2013-01-23 19:04   ` Eli Zaretskii
2013-01-23 23:38     ` Paul Eggert
2013-01-23 19:42 ` Michael Albinus
2013-01-23 20:05   ` Eli Zaretskii
2013-01-23 20:58     ` Michael Albinus
2013-01-24 16:37       ` Eli Zaretskii
2013-01-23 21:09 ` Stefan Monnier
2013-01-24 17:02   ` Eli Zaretskii
2013-01-24 18:25     ` Stefan Monnier
2013-01-24 18:38       ` Eli Zaretskii
2013-01-25  0:06         ` Stefan Monnier
2013-01-25  7:37           ` Eli Zaretskii
2013-01-25 11:36             ` Stefan Monnier
2013-01-25 20:31               ` Eli Zaretskii
2013-01-25 22:28                 ` Stefan Monnier
2013-01-26 10:54                   ` Eli Zaretskii
2013-01-26 11:34                     ` Stefan Monnier
2013-01-26 13:16                       ` Eli Zaretskii
2013-01-26 22:11                         ` Stefan Monnier
2013-01-27  7:03                           ` Eli Zaretskii
2013-01-27  8:46                             ` Andreas Schwab
2013-01-27  9:40                               ` Eli Zaretskii
2013-01-28  1:55                             ` Stefan Monnier [this message]
2013-01-28 14:44                               ` Eli Zaretskii
2013-01-28 15:21                                 ` Stefan Monnier
2013-02-02 17:19                                   ` Eli Zaretskii
2013-01-26 13:20                       ` Stephen J. Turnbull
2013-01-26  3:04                 ` Stephen J. Turnbull
2013-01-26 11:27                   ` Eli Zaretskii
2013-01-26 13:03                     ` Stephen J. Turnbull
2013-01-26 13:36                       ` Eli Zaretskii
2013-01-26 16:26                         ` Paul Eggert
2013-01-26 18:30                           ` Stephen J. Turnbull
2013-01-26 17:10                         ` Stephen J. Turnbull
2013-01-26 17:33                           ` Eli Zaretskii
2013-01-26 18:06                             ` Paul Eggert
2013-01-26 18:20                               ` Eli Zaretskii
2013-01-26 18:56                             ` Stephen J. Turnbull
2013-01-26 21:40                               ` Stefan Monnier
2013-01-26 21:44                             ` Stefan Monnier
2013-01-27  6:14                               ` Eli Zaretskii
2013-01-26 16:05                   ` Richard Stallman
2013-01-26 17:57                     ` Stephen J. Turnbull
2013-01-26 22:16                     ` Stefan Monnier
2013-01-24 10:00 ` Michael Albinus
2013-01-24 16:40   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvip6ijd96.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=kzhr@d1.dion.ne.jp \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).