changeset 107108:5fe8d912ca9e

from trunk
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Feb 2010 14:51:15 +0900
parents a10fe49a1405 (current diff) 906017fe8f4b (diff)
children 79ae69c59078
files
diffstat 21 files changed, 199 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/ChangeLog	Fri Feb 05 16:14:26 2010 +0900
+++ b/doc/misc/ChangeLog	Mon Feb 08 14:51:15 2010 +0900
@@ -1,3 +1,7 @@
+2010-02-05  Mark A. Hershberger  <mah@everybody.org>
+
+	* ede.texi, eieio.texi, semantic.texi: Use standard direntry format.
+
 2010-01-21  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus.texi (Score File Format): Fix typo.
--- a/doc/misc/ede.texi	Fri Feb 05 16:14:26 2010 +0900
+++ b/doc/misc/ede.texi	Mon Feb 08 14:51:15 2010 +0900
@@ -22,13 +22,10 @@
 @end quotation
 @end copying
 
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
+@dircategory Emacs
+@direntry
 * ede: (ede).       Project management for Emacs
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
+@end direntry
 
 @titlepage
 @center @titlefont{EDE (The Emacs Development Environment)}
--- a/doc/misc/eieio.texi	Fri Feb 05 16:14:26 2010 +0900
+++ b/doc/misc/eieio.texi	Mon Feb 08 14:51:15 2010 +0900
@@ -27,13 +27,10 @@
 @end quotation
 @end copying
 
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
+@dircategory Emacs
+@direntry
 * eieio: (eieio).       Objects for Emacs
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
+@end direntry
 
 @titlepage
 @center @titlefont{@value{TITLE}}
--- a/doc/misc/semantic.texi	Fri Feb 05 16:14:26 2010 +0900
+++ b/doc/misc/semantic.texi	Mon Feb 08 14:51:15 2010 +0900
@@ -41,13 +41,10 @@
 @end quotation
 @end copying
 
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
+@dircategory Emacs
+@direntry
 * Semantic: (semantic).      Source code parser library and utilities.
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
+@end direntry
 
 @titlepage
 @center @titlefont{Semantic}
--- a/lisp/ChangeLog	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/ChangeLog	Mon Feb 08 14:51:15 2010 +0900
@@ -1,3 +1,59 @@
+2010-02-07  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/f90.el (f90-font-lock-keywords-1, f90-font-lock-keywords-2):
+	Move F2003 named interfaces from keywords-2 to keywords-1, and
+	use function-name-face rather than constant-face.
+	Simplify "abstract interface" regexp.
+
+2010-02-07  Chong Yidong  <cyd@stupidchicken.com>
+
+	* eshell/esh-util.el (eshell-file-attributes): New optional arg
+	ID-FORMAT.  Pass it to `file-attributes'.
+
+	* eshell/em-ls.el (eshell-do-ls): Use it (Bug#5528).
+
+2010-02-07  sj  <prime.wizard+emacs@gmail.com>  (tiny change)
+
+	* faces.el (set-face-attribute): Allow calling
+	internal-set-lisp-face-attribute with 'unspecified family and
+	foundry argument (Bug#5536).
+
+2010-02-07  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/f90.el (f90-font-lock-keywords-2)
+	(f90-looking-at-type-like, f90-looking-at-program-block-end):
+	Handle F2003 named interfaces.
+
+2010-02-06  Chong Yidong  <cyd@stupidchicken.com>
+
+	* progmodes/cc-mode.el (c-common-init): Bind temporary variables
+	beg and end before calling c-get-state-before-change-functions.
+
+2010-02-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-bzr.el (vc-bzr-dir-extra-headers): Disable the pending merges header.
+
+2010-02-05  Juri Linkov  <juri@jurta.org>
+
+	* doc-view.el (doc-view-mode):
+	* image-mode.el (image-mode): Put property mode-class=special.
+	(Bug#4896)
+
+2010-02-05  Mark A. Hershberger  <mah@everybody.org>
+
+	* vc-svn.el (vc-svn-revision-table): New function.
+
+2010-02-05  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/ange-ftp.el (ange-ftp-insert-directory):
+	* net/tramp-imap.el (tramp-imap-handle-insert-directory):
+	* net/tramp-smb.el (tramp-smb-handle-insert-directory):
+	Handle also directories.  (Bug#5478)
+
+2010-02-05  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/f90.el (f90-font-lock-keywords-2): Fix `enum'.
+
 2010-02-05  Chong Yidong  <cyd@stupidchicken.com>
 
 	* startup.el (command-line-1): Convert options beginning with a
--- a/lisp/doc-view.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/doc-view.el	Mon Feb 08 14:51:15 2010 +0900
@@ -1134,7 +1134,7 @@
 
 ;;;; User interface commands and the mode
 
-;; (put 'doc-view-mode 'mode-class 'special)
+(put 'doc-view-mode 'mode-class 'special)
 
 (defun doc-view-already-converted-p ()
   "Return non-nil if the current doc was already converted."
--- a/lisp/erc/ChangeLog	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/erc/ChangeLog	Mon Feb 08 14:51:15 2010 +0900
@@ -1,3 +1,7 @@
+2010-02-07  Vivek Dasmohapatra  <vivek@etla.org>
+
+	* erc-services.el (erc-nickserv-alist): Fix defcustom type (Bug#5520).
+
 2010-01-25  Vivek Dasmohapatra  <vivek@etla.org>
 
 	* erc-backend.el (erc-session-connector): New var.
--- a/lisp/erc/erc-services.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/erc/erc-services.el	Mon Feb 08 14:51:15 2010 +0900
@@ -303,7 +303,11 @@
 		 (boolean :tag "Use current nick in identify message?")
 		 (choice :tag "Command to use (optional)"
 		  (string :tag "Command")
-		  (const :tag "No special command necessary" nil)))))
+		  (const :tag "No special command necessary" nil))
+		 (choice :tag "Detect Success"
+			 (regexp :tag "Pattern to match")
+			 (const :tag "Do not try to detect success" nil)))))
+
 
 (defsubst erc-nickserv-alist-sender (network &optional entry)
   (nth 1 (or entry (assoc network erc-nickserv-alist))))
--- a/lisp/eshell/em-ls.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/eshell/em-ls.el	Mon Feb 08 14:51:15 2010 +0900
@@ -393,13 +393,13 @@
 	       (eshell-glob-regexp ignore-pattern))))
      ;; list the files!
      (eshell-ls-entries
-      (mapcar (function
-	       (lambda (arg)
-		 (cons (if (and (eshell-under-windows-p)
-				(file-name-absolute-p arg))
-			   (expand-file-name arg)
-			 arg)
-		       (eshell-file-attributes arg))))
+      (mapcar (lambda (arg)
+		(cons (if (and (eshell-under-windows-p)
+			       (file-name-absolute-p arg))
+			  (expand-file-name arg)
+			arg)
+		      (eshell-file-attributes
+		       arg (if numeric-uid-gid 'integer 'string))))
 	      args)
       t (expand-file-name default-directory)))
    (funcall flush-func)))
@@ -710,7 +710,7 @@
 	    (funcall insert-func need-return "\n"))))))
 
 (defun eshell-ls-entries (entries &optional separate root-dir)
-  "Output PATH's directory ENTRIES, formatted according to OPTIONS.
+  "Output PATH's directory ENTRIES.
 Each member of ENTRIES may either be a string or a cons cell, the car
 of which is the file name, and the cdr of which is the list of
 attributes.
--- a/lisp/eshell/esh-util.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/eshell/esh-util.el	Mon Feb 08 14:51:15 2010 +0900
@@ -701,8 +701,11 @@
 	(forward-line)))
     entry))
 
-(defun eshell-file-attributes (file)
-  "Return the attributes of FILE, playing tricks if it's over ange-ftp."
+(defun eshell-file-attributes (file &optional id-format)
+  "Return the attributes of FILE, playing tricks if it's over ange-ftp.
+The optional argument ID-FORMAT specifies the preferred uid and
+gid format.  Valid values are 'string and 'integer, defaulting to
+'integer.  See `file-attributes'."
   (let* ((file (expand-file-name file))
 	 entry)
     (if (string-equal (file-remote-p file 'method) "ftp")
@@ -723,7 +726,7 @@
 		      (setq entry (cdr fentry))
 		    (setq entry nil)))))
 	  entry)
-      (file-attributes file))))
+      (file-attributes file id-format))))
 
 (defalias 'eshell-copy-tree 'copy-tree)
 
--- a/lisp/faces.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/faces.el	Mon Feb 08 14:51:15 2010 +0900
@@ -735,10 +735,10 @@
 	(unless foundry
 	  (setq foundry (match-string 1 family)))
 	(setq family (match-string 2 family)))
-      (when (stringp family)
+      (when (or (stringp family) (eq family 'unspecified))
 	(internal-set-lisp-face-attribute face :family (purecopy family)
 					  where))
-      (when (stringp foundry)
+      (when (or (stringp foundry) (eq foundry 'unspecified))
 	(internal-set-lisp-face-attribute face :foundry (purecopy foundry)
 					  where)))
     (while args
--- a/lisp/image-mode.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/image-mode.el	Mon Feb 08 14:51:15 2010 +0900
@@ -317,6 +317,8 @@
 
 (defvar bookmark-make-record-function)
 
+(put 'image-mode 'mode-class 'special)
+
 ;;;###autoload
 (defun image-mode ()
   "Major mode for image files.
--- a/lisp/net/ange-ftp.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/net/ange-ftp.el	Mon Feb 08 14:51:15 2010 +0900
@@ -4533,9 +4533,10 @@
        (when (string-match "-?d\\'" switches)
          ;; Remove "d" which dired added to `switches'.
          (setq switches (substring switches 0 (match-beginning 0))))
+       (setq file (directory-file-name file))
        (let* ((dirlist (ange-ftp-ls (or (file-name-directory file) ".")
                                     switches 'parse))
-              (filename (file-name-nondirectory (directory-file-name file)))
+              (filename (file-name-nondirectory file))
               (case-fold-search nil))
          ;; FIXME: This presumes a particular output format, which is
          ;; basically Unix.
--- a/lisp/net/tramp-imap.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/net/tramp-imap.el	Mon Feb 08 14:51:15 2010 +0900
@@ -395,9 +395,10 @@
   (filename switches &optional wildcard full-directory-p)
   "Like `insert-directory' for Tramp files."
   (setq filename (expand-file-name filename))
-  (when full-directory-p
-    ;; Called from `dired-add-entry'.
-    (setq filename (file-name-as-directory filename)))
+  (if full-directory-p
+      ;; Called from `dired-add-entry'.
+      (setq filename (file-name-as-directory filename))
+    (setq filename (directory-file-name filename)))
   (with-parsed-tramp-file-name filename nil
     (save-match-data
       (let ((base (file-name-nondirectory localname))
@@ -479,7 +480,8 @@
 	       (insert
 		(format
 		 "%s\n"
-		 (file-relative-name (expand-file-name (nth 0 x) filename))))
+		 (file-relative-name
+		  (expand-file-name (nth 0 x) (file-name-directory filename)))))
 	       (put-text-property pos (1- (point)) 'dired-filename t))
 	     (forward-line)
 	     (beginning-of-line)))
--- a/lisp/net/tramp-smb.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/net/tramp-smb.el	Mon Feb 08 14:51:15 2010 +0900
@@ -651,9 +651,10 @@
   (filename switches &optional wildcard full-directory-p)
   "Like `insert-directory' for Tramp files."
   (setq filename (expand-file-name filename))
-  (when full-directory-p
-    ;; Called from `dired-add-entry'.
-    (setq filename (file-name-as-directory filename)))
+  (if full-directory-p
+      ;; Called from `dired-add-entry'.
+      (setq filename (file-name-as-directory filename))
+    (setq filename (directory-file-name filename)))
   (with-parsed-tramp-file-name filename nil
     (save-match-data
       (let ((base (file-name-nondirectory filename))
@@ -715,8 +716,7 @@
 	     (let ((attr
 		    (when (tramp-smb-get-stat-capability v)
 		      (ignore-errors
-			(file-attributes
-			 (expand-file-name (nth 0 x) filename) 'string)))))
+			(file-attributes filename 'string)))))
 	       (insert
 		(format
 		 "%10s %3d %-8s %-8s %8s %s "
@@ -739,7 +739,9 @@
 		 (insert
 		  (format
 		   "%s\n"
-		   (file-relative-name (expand-file-name (nth 0 x) filename))))
+		   (file-relative-name
+		    (expand-file-name
+		     (nth 0 x) (file-name-directory filename)))))
 		 (put-text-property start (1- (point)) 'dired-filename t))
 	       (forward-line)
 	       (beginning-of-line))))
--- a/lisp/progmodes/cc-mode.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/progmodes/cc-mode.el	Mon Feb 08 14:51:15 2010 +0900
@@ -642,9 +642,11 @@
     (widen)
     (save-excursion
       (if c-get-state-before-change-functions
-	  (mapc (lambda (fn)
-		  (funcall fn beg end))
-		c-get-state-before-change-functions))
+	  (let ((beg (point-min))
+		(end (point-max)))
+	    (mapc (lambda (fn)
+		    (funcall fn beg end))
+		  c-get-state-before-change-functions)))
       (if c-before-font-lock-function
 	  (funcall c-before-font-lock-function (point-min) (point-max)
 		   (- (point-max) (point-min))))))
--- a/lisp/progmodes/f90.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/progmodes/f90.el	Mon Feb 08 14:51:15 2010 +0900
@@ -158,10 +158,8 @@
 ;; 3. Support for align.
 ;; Font-locking:
 ;; 1. OpenMP, OpenMPI?, preprocessor highlighting.
-;; 2. interface blah - Highlight "blah" in function-name face?
-;; Need to avoid "interface operator (+)" etc.
-;; 3. integer_name = 1
-;; 4. Labels for "else" statements (F2003)?
+;; 2. integer_name = 1
+;; 3. Labels for "else" statements (F2003)?
 
 (defvar comment-auto-fill-only-comments)
 (defvar font-lock-keywords)
@@ -467,22 +465,21 @@
 ;;;      (1 font-lock-keyword-face) (3 font-lock-function-name-face))
    '(f90-typedef-matcher
      (1 font-lock-keyword-face) (2 font-lock-function-name-face))
-   ;; Other functions and declarations.
+    ;; F2003.  Prevent operators being highlighted as functions.
+    '("\\<\\(\\(?:end[ \t]*\\)?interface[ \t]*\\(?:assignment\\|operator\\|\
+read\\|write\\)\\)[ \t]*(" (1 font-lock-keyword-face t))
+   ;; Other functions and declarations.  Named interfaces = F2003.
    '("\\<\\(\\(?:end[ \t]*\\)?\\(program\\|module\\|function\\|associate\\|\
-subroutine\\)\\|use\\|call\\)\\>[ \t]*\\(\\sw+\\)?"
+subroutine\\|interface\\)\\|use\\|call\\)\\>[ \t]*\\(\\sw+\\)?"
      (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
    ;; F2003.
    '("\\<\\(use\\)[ \t]*,[ \t]*\\(\\(?:non_\\)?intrinsic\\)[ \t]*::[ \t]*\
 \\(\\sw+\\)"
      (1 font-lock-keyword-face) (2 font-lock-keyword-face)
      (3 font-lock-function-name-face))
-   "\\<\\(\\(end[ \t]*\\)?block[ \t]*data\\|contains\\|\
-end[ \t]*interface\\)\\>"
-   ;; "abstract interface" is F2003. Must come after previous entry.
-   '("\\<\\(\\(?:abstract[ \t]*\\)?interface\\)\\>"
-     ;; [ \t]*\\(\\(\\sw+\\)[ \t]*[^(]\\)?"
-     ;; (2) messes up "interface operator ()", etc.
-     (1 font-lock-keyword-face))) ;(2 font-lock-function-name-face nil t)))
+   "\\<\\(\\(end[ \t]*\\)?block[ \t]*data\\|contains\\)\\>"
+   ;; "abstract interface" is F2003.
+   '("\\<abstract[ \t]*interface\\>" (0 font-lock-keyword-face t)))
   "This does fairly subdued highlighting of comments and function calls.")
 
 ;; NB not explicitly handling this, yet it seems to work.
@@ -558,9 +555,8 @@
 \\(function\\)\\>[ \t]*\\(\\sw+\\)[ \t]*\\(([^&!\n]*)\\)"
       (1 font-lock-type-face t) (4 font-lock-keyword-face t)
       (5 font-lock-function-name-face t) (6 'default t))
-    ;; enum (F2003; cf type in -1).
-    '("\\<\\(enum\\)\\>\\([^()\n]*::\\)?[ \t]*\\(\\sw+\\)"
-      (1 font-lock-keyword-face) (3 font-lock-function-name-face))
+    ;; enum (F2003; must be followed by ", bind(C)").
+    '("\\<\\(enum\\)[ \t]*," (1 font-lock-keyword-face))
     ;; end do, enum (F2003), if, select, where, and forall constructs.
     '("\\<\\(end[ \t]*\\(do\\|if\\|enum\\|select\\|forall\\|where\\)\\)\\>\
 \\([ \t]+\\(\\sw+\\)\\)?"
@@ -1230,7 +1226,7 @@
 
 (defsubst f90-looking-at-type-like ()
   "Return (KIND NAME) if a type/enum/interface/block-data starts after point.
-NAME is non-nil only for type."
+NAME is non-nil only for type and certain interfaces."
   (cond
    ((save-excursion
       (and (looking-at "\\<type\\>[ \t]*")
@@ -1243,7 +1239,15 @@
 ;;;    ((and (not (looking-at f90-typeis-re))
 ;;;          (looking-at f90-type-def-re))
 ;;;     (list (match-string 1) (match-string 2)))
-   ((looking-at "\\(enum\\|interface\\|block[ \t]*data\\)\\>")
+   ((looking-at "\\<\\(interface\\)\\>[ \t]*")
+    (list (match-string 1)
+          (save-excursion
+            (goto-char (match-end 0))
+            (if (or (looking-at "\\(operator\\|assignment\\|read\\|\
+write\\)[ \t]*([^)\n]*)")
+                    (looking-at "\\sw+"))
+                (match-string 0)))))
+   ((looking-at "\\(enum\\|block[ \t]*data\\)\\>")
     (list (match-string 1) nil))
    ((looking-at "abstract[ \t]*\\(interface\\)\\>")
     (list (match-string 1) nil))))
@@ -1271,9 +1275,12 @@
 
 (defsubst f90-looking-at-program-block-end ()
   "Return (KIND NAME) if a block with name NAME ends after point."
-  (if (looking-at (concat "end[ \t]*" f90-blocks-re
-                          "?\\([ \t]+\\(\\sw+\\)\\)?\\>"))
-      (list (match-string 1) (match-string 3))))
+  (cond ((looking-at "end[ \t]*\\(interface\\)[ \t]*\\(\
+\\(?:assignment\\|operator\\|read\\|write\\)[ \t]*([^)\n]*)\\)")
+         (list (match-string 1) (match-string 2)))
+        ((looking-at (concat "end[ \t]*" f90-blocks-re
+                             "?\\([ \t]+\\(\\sw+\\)\\)?\\>"))
+        (list (match-string 1) (match-string 3)))))
 
 (defsubst f90-comment-indent ()
   "Return the indentation to be used for a comment starting at point.
--- a/lisp/vc-bzr.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/vc-bzr.el	Mon Feb 08 14:51:15 2010 +0900
@@ -796,8 +796,12 @@
        (shelve-help-echo "Use M-x vc-bzr-shelve to create shelves")
        (root-dir (vc-bzr-root dir))
        (pending-merge
-	(file-exists-p
-	 (expand-file-name ".bzr/checkout/merge-hashes" root-dir)))
+	;; FIXME: looking for .bzr/checkout/merge-hashes is not a
+	;; reliable method to detect pending merges, disable this
+	;; until a proper solution is implemented.
+	(and nil
+	 (file-exists-p
+	 (expand-file-name ".bzr/checkout/merge-hashes" root-dir))))
        (pending-merge-help-echo
 	(format "A merge has been performed.\nA commit from the top-level directory (%s)\nis required before being able to check in anything else" root-dir))
        (light-checkout
--- a/lisp/vc-svn.el	Fri Feb 05 16:14:26 2010 +0900
+++ b/lisp/vc-svn.el	Mon Feb 08 14:51:15 2010 +0900
@@ -31,6 +31,10 @@
 (eval-when-compile
   (require 'vc))
 
+;; Clear up the cache to force vc-call to check again and discover
+;; new functions when we reload this file.
+(put 'SVN 'vc-functions nil)
+
 ;;;
 ;;; Customization options
 ;;;
@@ -722,6 +726,21 @@
     (beginning-of-line)
     (if (looking-at vc-svn-annotate-re) (match-string 1))))
 
+(defun vc-svn-revision-table (files)
+  (let ((vc-svn-revisions '()))
+    (with-current-buffer "*vc*"
+      (vc-svn-command nil 0 files "log" "-q")
+      (goto-char (point-min))
+      (forward-line)
+      (let ((start (point-min))
+            (loglines (buffer-substring-no-properties (point-min)
+                                                      (point-max))))
+        (while (string-match "^r\\([0-9]+\\) " loglines)
+          (push (match-string 1 loglines) vc-svn-revisions)
+          (setq start (+ start (match-end 0)))
+          (setq loglines (buffer-substring-no-properties start (point-max)))))
+    vc-svn-revisions)))
+
 (provide 'vc-svn)
 
 ;; arch-tag: 02f10c68-2b4d-453a-90fc-1eee6cfb268d
--- a/src/ChangeLog	Fri Feb 05 16:14:26 2010 +0900
+++ b/src/ChangeLog	Mon Feb 08 14:51:15 2010 +0900
@@ -1,3 +1,9 @@
+2010-02-06  Chong Yidong  <cyd@stupidchicken.com>
+
+	* charset.c (load_charset_map_from_file)
+	(load_charset_map_from_vector): Fix last change to use SAFE_ALLOCA
+	instead of xmalloc (Bug#5526).  Suggested by Vivek Dasmohapatra.
+
 2010-02-05  Chong Yidong  <cyd@stupidchicken.com>
 
 	* charset.c (load_charset_map_from_file): Allocate large
--- a/src/charset.c	Fri Feb 05 16:14:26 2010 +0900
+++ b/src/charset.c	Mon Feb 08 14:51:15 2010 +0900
@@ -512,12 +512,13 @@
   int eof;
   Lisp_Object suffixes;
   struct charset_map_entries *head, *entries;
-  int n_entries;
-  int count = SPECPDL_INDEX ();
+  int n_entries, count;
+  USE_SAFE_ALLOCA;
 
   suffixes = Fcons (build_string (".map"),
 		    Fcons (build_string (".TXT"), Qnil));
 
+  count = SPECPDL_INDEX ();
   specbind (Qfile_name_handler_alist, Qnil);
   fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil);
   unbind_to (count, Qnil);
@@ -525,8 +526,12 @@
       || ! (fp = fdopen (fd, "r")))
     error ("Failure in loading charset map: %S", SDATA (mapfile));
 
-  head = entries = ((struct charset_map_entries *)
-		    xmalloc (sizeof (struct charset_map_entries)));
+  /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+     large (larger than MAX_ALLOCA).  */
+  SAFE_ALLOCA (head, struct charset_map_entries *,
+	       sizeof (struct charset_map_entries));
+  entries = head;
+
   n_entries = 0;
   eof = 0;
   while (1)
@@ -549,8 +554,8 @@
 
       if (n_entries > 0 && (n_entries % 0x10000) == 0)
 	{
-	  entries->next = ((struct charset_map_entries *)
-			   alloca (sizeof (struct charset_map_entries)));
+	  SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+		       sizeof (struct charset_map_entries));
 	  entries = entries->next;
 	}
       idx = n_entries % 0x10000;
@@ -563,7 +568,7 @@
   close (fd);
 
   load_charset_map (charset, head, n_entries, control_flag);
-  xfree (head);
+  SAFE_FREE ();
 }
 
 static void
@@ -578,6 +583,7 @@
   int n_entries;
   int len = ASIZE (vec);
   int i;
+  USE_SAFE_ALLOCA;
 
   if (len % 2 == 1)
     {
@@ -585,8 +591,12 @@
       return;
     }
 
-  head = entries = ((struct charset_map_entries *)
-		    alloca (sizeof (struct charset_map_entries)));
+  /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+     large (larger than MAX_ALLOCA).  */
+  SAFE_ALLOCA (head, struct charset_map_entries *,
+	       sizeof (struct charset_map_entries));
+  entries = head;
+
   n_entries = 0;
   for (i = 0; i < len; i += 2)
     {
@@ -619,8 +629,8 @@
 
       if (n_entries > 0 && (n_entries % 0x10000) == 0)
 	{
-	  entries->next = ((struct charset_map_entries *)
-			   alloca (sizeof (struct charset_map_entries)));
+	  SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+		       sizeof (struct charset_map_entries));
 	  entries = entries->next;
 	}
       idx = n_entries % 0x10000;
@@ -631,6 +641,7 @@
     }
 
   load_charset_map (charset, head, n_entries, control_flag);
+  SAFE_FREE ();
 }