Subject: bug#55386: 29.0.50; check-declare-directory doesn't work on Windows

From: Yasuhiro Kimura <[email-masked]>
Date: Fri, 13 May 2022 00:22:44 +0900 (JST)

[How to reproduce the problem]

1. cd C:/Users/yasu/Temp
2. git clone https://git.savannah.gnu.org/git/emacs.git
3. Start Emacs with 'emacs -Q'
4. Type '(check-declare-directory "C:/Users/yasu/Temp/emacs/lisp")'
   and C-j.

[Expected result]

Retern value is inserted to *scratch* buffer.

[What really happens]

*Backtrace* buffer is displayed with following backtrace information.

----------------------------------------------------------------------
Debugger entered--Lisp error: (file-error "Opening input file" "Invalid argument" "c:/Users/yasu/ファイルが見つかりません - \"^[ \11]*(declare-funct...")
  insert-file-contents("ファイルが見つかりません - \"^[ \11]*(declare-function\"")
  check-declare-scan("ファイルが見つかりません - \"^[ \11]*(declare-function\"")
  check-declare-files("ファイルが見つかりません - \"^[ \11]*(declare-function\"")
  apply(check-declare-files "ファイルが見つかりません - \"^[ \11]*(declare-function\"")
  check-declare-directory("C:/Users/yasu/Temp/emacs/lisp")
  (progn (check-declare-directory "C:/Users/yasu/Temp/emacs/lisp"))
  eval((progn (check-declare-directory "C:/Users/yasu/Temp/emacs/lisp")) t)
  elisp--eval-last-sexp(t)
  eval-last-sexp(t)
  eval-print-last-sexp(nil)
  funcall-interactively(eval-print-last-sexp nil)
  call-interactively(eval-print-last-sexp nil nil)
  command-execute(eval-print-last-sexp)
----------------------------------------------------------------------

I guess check-declare-directory don't handle drive letter of Windows
properly.

In GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32)
 of 2022-05-12 built on HALF
Repository revision: c8d7a27438b294e20ca0f8f6f1dd74d4a273dc96
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.22000
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.22000.675)

Configured using:
 'configure --prefix=/c/Emacs --without-dbus'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG LIBXML2 MODULES NOTIFY W32NOTIFY
PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP
XPM ZLIB

Important settings:
  value of $LANG: JPN
  locale-coding-system: cp932

Major mode: Fundamental

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
c:/Emacs/share/emacs/site-lisp/transient hides c:/Emacs/share/emacs/29.0.50/lisp/transient
c:/Emacs/share/emacs/site-lisp/flim/sasl hides c:/Emacs/share/emacs/29.0.50/lisp/net/sasl

Features:
(shadow pp mew-varsx mew-win32 mew-w3m w3m doc-view jka-compr
image-mode exif timezone w3m-hist w3m-fb bookmark-w3m w3m-ems wid-edit
w3m-favicon w3m-image tab-line w3m-proc w3m-util mew-auth mew-config
mew-imap2 mew-imap mew-nntp2 mew-nntp mew-pop mew-smtp mew-ssl mew-ssh
mew-net mew-highlight mew-sort mew-fib mew-ext mew-refile mew-demo
mew-attach mew-draft mew-message mew-thread mew-virtual mew-summary4
mew-summary3 mew-summary2 mew-summary mew-search mew-pick mew-passwd
mew-scan mew-syntax mew-bq mew-smime mew-pgp mew-header mew-exec
mew-mark mew-mime mew-edit mew-decode mew-encode mew-cache mew-minibuf
mew-complete mew-addrbook mew-local mew-vars3 mew-vars2 mew-vars
mew-env mew-lang-jp mew-mule3 mew-mule mew-gemacs mew-key mew-func
mew-blvs mew-const mew emacsbug magit-version yaml-mode mime-setup
mail-mime-setup semi-setup semi-def alist path-util apel-ver product
rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match
rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap
sgml-mode facemenu dom nxml-util nxml-enc xmltok forge-list
forge-commands forge-semi forge-bitbucket buck forge-gogs gogs
forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy
gsexp ghub let-alist gnutls forge-notify forge-revnote forge-pullreq
forge-issue forge-topic yaml pcase parse-time iso8601 bug-reference
forge-post markdown-mode color noutline outline forge-repo forge
forge-core forge-db closql emacsql-sqlite advice emacsql
emacsql-compiler url-http url-auth url-gw nsm magit-submodule
magit-obsolete magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
url-handlers url-parse auth-source url-vars magit-repos magit-apply
magit-wip magit-log which-func imenu magit-diff smerge-mode diff
diff-mode easy-mmode git-commit log-edit message sendmail mailcap
yank-media rmc puny dired dired-loaddefs rfc822 mml mml-sec
password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log
magit-core magit-autorevert autorevert filenotify magit-margin
magit-transient magit-process with-editor shell pcomplete comint ring
server ansi-color magit-mode transient cl-extra edmacro kmacro
help-mode magit-git magit-base magit-section cl-seq format-spec crm
eieio eieio-core cl-macs eieio-loaddefs dash compat-27 compat-26
compat json map seq gv subr-x byte-opt bytecomp byte-compile cconv
gitignore-mode gitconfig-mode conf-mode rx gitattributes-mode
thingatpt cl-loaddefs cl-lib cp5022x japan-util iso-transl tooltip
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win
w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer
select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice simple cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj
charscript charprop case-table epa-hook jka-cmpr-hook help abbrev
obarray oclosure cl-preloaded button loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable
backquote threads w32notify w32 multi-tty make-network-process emacs)

Memory information:
((conses 16 262013 11023)
 (symbols 48 26306 16)
 (strings 32 81908 2908)
 (string-bytes 1 2429996)
 (vectors 16 50644)
 (vector-slots 8 737227 23350)
 (floats 8 254 159)
 (intervals 56 758 228)
 (buffers 992 13))