]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge from emacs--devo--0
authorMiles Bader <miles@gnu.org>
Mon, 13 Aug 2007 13:48:35 +0000 (13:48 +0000)
committerMiles Bader <miles@gnu.org>
Mon, 13 Aug 2007 13:48:35 +0000 (13:48 +0000)
Patches applied:

 * emacs--devo--0  (patch 846-851)

   - Update from CVS
   - Merge from emacs--rel--22

 * emacs--rel--22  (patch 88-92)

   - Update from CVS
   - Merge from gnus--rel--5.10

 * gnus--rel--5.10  (patch 242-244)

   - Update from CVS

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-246

56 files changed:
1  2 
admin/nt/README-ftp-server
etc/TODO
lisp/ChangeLog
lisp/bindings.el
lisp/emacs-lisp/autoload.el
lisp/emacs-lisp/byte-opt.el
lisp/emacs-lisp/cl-loaddefs.el
lisp/font-lock.el
lisp/format.el
lisp/international/ja-dic-cnv.el
lisp/international/mule-cmds.el
lisp/international/quail.el
lisp/isearch.el
lisp/mail/rmail.el
lisp/progmodes/sh-script.el
lisp/simple.el
lisp/subr.el
lisp/term.el
lisp/term/mac-win.el
lisp/textmodes/ispell.el
lisp/textmodes/sgml-mode.el
lisp/wid-edit.el
src/ChangeLog
src/buffer.h
src/callproc.c
src/casetab.c
src/category.c
src/ccl.c
src/charset.h
src/coding.h
src/composite.h
src/dired.c
src/editfns.c
src/emacs.c
src/fileio.c
src/fontset.c
src/fontset.h
src/indent.c
src/insdel.c
src/intervals.c
src/keyboard.c
src/keymap.c
src/lisp.h
src/lread.c
src/macterm.c
src/msdos.c
src/print.c
src/process.c
src/regex.c
src/search.c
src/w32term.c
src/w32term.h
src/window.c
src/xdisp.c
src/xterm.c
src/xterm.h

Simple merge
diff --cc etc/TODO
Simple merge
diff --cc lisp/ChangeLog
index 8c3af441f34da517ba775702301fdf538ffc5be8,a5d54560e97fbd531a97dce2efbcdb50e86bf961..8daf2daf71fab16268c6dcf60bd000b3ed0b71bc
 -2007-08-13  Stephen Leake  <stephen_leake@stephe-leake.org>
 -
 -      * pcvs-parse.el (cvs-parse-table): Handle additional instance of
 -      optional quotes around files in NEED-UPDATE . REMOVED case.
 -
 -      * progmodes/ada-xref.el (ada-gnatls-args): Fix docstring.
 -      (ada-treat-cmd-string): Improve error message.
 -      (ada-do-file-completion): Call `ada-require-project-file', so
 -      project variables are set properly.
 -      (ada-prj-find-prj-file): Delete Emacs 20.2 support.
 -      (ada-gnatfind-buffer-name): New constant.
 -      (ada-find-any-references): Use new constant.  Set buffer name
 -      properly in compilation-start.  Toggle read-only properly.
 -      (ada-find-in-src-path): Fix spelling error in docstring.
 -
 -      * progmodes/vhdl-mode.el (vhdl-update-progress-info): Avoid divide
 -      by zero error.
 -
+ 2007-08-13  Nick Roberts  <nickrob@snap.net.nz>
+       * progmodes/gdb-ui.el (gdb-send): Handle CTRL-D more carefully.
+ 2007-08-12  Richard Stallman  <rms@gnu.org>
+       * pcvs.el (cvs-reread-cvsrc, cvs-checkout, cvs-mode-checkout)
+       (cvs-execute-single-file): Use new name split-string-and-unquote.
+       (cvs-header-msg): Use new name combine-and-quote-strings.
+       * emulation/vi.el (vi-next-line): Ignore return value of line-move.
+       * progmodes/gud.el (gud-common-init): Use new name
+       split-string-and-unquote.
+       * progmodes/flymake.el (flymake-err-line-patterns): Fix infloop
+       in javac regexp.
+       * pcvs-util.el (cvs-qtypedesc-strings): Use new names
+       combine-and-quote-strings and split-string-and-unquote.
+       * subr.el (combine-and-quote-strings): Renamed from strings->string.
+       (split-string-and-unquote): Renamed from string->strings.
+ 2007-08-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * log-view.el (log-view-font-lock-keywords): Use `eval' so as to adapt
+       to buffer-local settings.
+       * emacs-lisp/backquote.el (backquote-delay-process): New function.
+       (backquote-process): Add internal arg `level'.  Use the two to
+       correctly handle nested backquotes.
+ 2007-08-09  Riccardo Murri  <riccardo.murri@gmail.com>
+       * vc-bzr.el (vc-bzr-registered): Use \0 instead of literal NULs.
+       (vc-bzr-state-words): Add "kind changed" state word.
+       (vc-bzr-status): New function.  Return Bzr idea of file status,
+       which is different from VC's.
+       (vc-bzr-state): Use vc-bzr-status.
+       (vc-workfile-unchanged-p): Use vc-bzr-status.
+       (vc-bzr-revert): Use synchronous process; expect exitcode 0.
+       (vc-dired-state): Process "kind changed" state word.
+ 2007-08-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * vc-hooks.el (vc-default-find-file-not-found-hook): Do nothing.
+       * vc-rcs.el (vc-rcs-find-file-not-found-hook):
+       Move from vc-default-find-file-not-found-hook.
+ 2007-08-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * man.el: Remove spurious * in docstrings.
+       Merge defvars and toplevel setq-defaults.
+       (Man-highlight-references0): Limit=nil rather than point-max.
+       (Man-mode-map): Move initialization into the declaration.
+       (Man-strip-page-headers, Man-unindent): Use dolist & inhibit-read-only.
+       (Man-view-header-file): Use expand-file-name rather than concat.
+       (Man-notify-when-ready, Man-bgproc-sentinel): Use with-current-buffer.
+       * man.el (Man-next-section): Make sure we do not move backward.
+ 2007-08-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * files.el (auto-mode-alist): Use the purecopied text (duh!).
+ 2007-08-08  Glenn Morris  <rgm@gnu.org>
+       * Replace `iff' in doc-strings and comments.
+ 2007-08-08  Martin Rudalics  <rudalics@gmx.at>
+       * dired.el (dired-pop-to-buffer):
+       * mouse-drag.el (mouse-drag-should-do-col-scrolling):
+       * calendar/calendar.el (generate-calendar-window):
+       * progmodes/compile.el (compilation-set-window-height):
+       * textmodes/two-column.el (2C-two-columns, 2C-merge):
+       Use window-full-width-p instead of comparing frame-width and
+       window-width.
+       * progmodes/compile.el (compilation-find-buffer): Remove extra
+       argument in call to compilation-buffer-internal-p.
+ 2007-08-07  Tom Tromey  <tromey@redhat.com>
+       * progmodes/tcl.el (tcl-indent-level, tcl-continued-indent-level):
+       Add safe-local-variable property.
+ 2007-08-07  Chong Yidong  <cyd@stupidchicken.com>
+       * image-mode.el (image-toggle-display): Use image-refresh.
+ 2007-08-07  Riccardo Murri  <riccardo.murri@gmail.com>
+       * vc-bzr.el: Remove comments about vc-bzr.el being a modified
+       unofficial version.
+       (vc-bzr-command): Remove redundant setting of process-connection-type.
+       (vc-bzr-admin-checkout-format-file): Add autoload.
+       (vc-bzr-root-dir): Remove in favor of vc-bzr-root.
+       (vc-bzr-root): Switch to implementation of vc-bzr-root-dir.
+       (vc-bzr-registered): Compare dirstate format tag with known good
+       value, abort parsing if match fails.  Warn user in docstring.
+       (vc-bzr-workfile-version): Case for different Bzr branch formats.
+       See bzrlib/branch.py in Bzr sources.
+       (vc-bzr-diff): First argument FILES may be a string rather than a list.
+       (vc-bzr-shell-command): Remove in favor of
+       vc-bzr-command-discarding-stderr.
+       (vc-bzr-command-discarding-stderr): New function.
+ 2007-08-06  Riccardo Murri  <riccardo.murri@gmail.com>
+       * vc-bzr.el (vc-bzr-registered): Gracefully handle missing "bzr"
+       program, and return nil
+       (vc-bzr-state): Gracefully handle missing "bzr" program, and return nil.
+       (vc-bzr-state): Look for path names relative to the repository
+       root after status keyword.
+       (vc-bzr-file-name-relative): New function.
+       (vc-bzr-admin-dirname): Reinstate, as other vc-bzr-admin-... paths
+       depend on it.
+       (vc-bzr-admin-dirname, ...-checkout-format-file)
+       (...-branch-format-file, ...-revhistory): Paths to some Bzr internal
+       files that we now parse directly for speed.
+       (vc-bzr-root-dir): Use `vc-bzr-admin-checkout-format-file' as witness.
+       (vc-bzr-registered): Only parse vc-bzr-admin-dirstate file if it exists.
+       (vc-bzr-state): "bzr status" successful only if exitcode is 0
+       (vc-bzr-root): Use `vc-bzr-shell-command'.  Stderr may contain
+       Bzr warnings, so we must discard it.
+       (vc-bzr-workfile-version): Speedup counting lines from
+       `vc-bzr-admin-revhistory' file, but fallback to spawning "bzr revno"
+       if that file doesn't exist.
+       (vc-bzr-responsible-p): Use `vc-bzr-root' instead of
+       `vc-bzr-root-dir' for speed.  Add `vc-bzr-admin-dirname'
+       (not ".bzr"!) to `vc-directory-exclusion-list'
+       (vc-bzr-shell-command): New function.
+ 2007-08-06  Tom Tromey  <tromey@redhat.com>
+       * diff-mode.el (diff-unified->context, diff-reverse-direction)
+       (diff-fixup-modifs): Typo in docstring.
+ 2007-08-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * emulation/tpu-edt.el (tpu-current-line): Use posn-at-point and
+       count-screen-lines.
+       (tpu-edt-off): Disable relevant pieces of advice.
+       * emulation/tpu-extras.el (tpu-before-save-hook): Rename from
+       tpu-write-file-hook.  Activate it with add-hook on buffer-save-hook.
+       (newline, newline-and-indent, do-auto-fill): Use advice instead of
+       redefining the function.
+       (tpu-set-scroll-margins): Activate the pieces of advice.
+ 2007-08-06  Martin Rudalics  <rudalics@gmx.at>
+       * help.el (resize-temp-buffer-window): Use window-full-width-p
+       instead of comparing frame-width and window-width.
 -2007-08-09  Edward O'Connor  <hober0@gmail.com>  (tiny change)
+ 2007-08-13  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * emacs-lisp/autoload.el (autoload-print-form): Use print-quoted.
+ 2007-08-12  Richard Stallman  <rms@gnu.org>
+       * progmodes/sh-script.el (sh): Delete group `unix'.
+       * progmodes/gud.el (gud): Change to group `processes'.
+ 2007-08-11  Glenn Morris  <rgm@gnu.org>
+       * progmodes/compile.el (compilation-buffer-name): Don't check
+       compilation-arguments.  It is superfluous, and the variable isn't
+       even set when this function is called.
+ 2007-08-10  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+       * term/mac-win.el (mac-ae-reopen-application): New function.
+       (mac-apple-event-map): Bind "reopen application" Apple event to it.
+ 2007-08-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * textmodes/tex-mode.el (tex-font-lock-unfontify-region): Fix to
+       take tex-font-script-display into account.
+       (tex-font-script-display, tex-font-lock-suscript): Change from a cons
+       cell to a list of 2 elements to simplify the unfontify code.
++2007-08-09  Edward O'Connor  <hober0@gmail.com> (tiny change)
+       * url/url-auth.el (url-basic-auth): When prompting for username
+       and password, default to the username and password in the URL.
  2007-08-08  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
  
        * ps-print.el (ps-default-fg, ps-default-bg): Docstring fix.
        ps-print-color-p is neither nil nor black-white.  Reported by Christian
        Schlauer <cs-muelleimer-rubbish.bin@arcor.de>.
  
 -      (display-time-world-timer-enable, display-time-world-timer-second)
 -      (display-time-world-mode-map): New.
 -
+ 2007-08-08  Andreas Schwab  <schwab@suse.de>
+       * mail/mailabbrev.el (sendmail-pre-abbrev-expand-hook): Check for
+       self-insert-command, not self-insert.
+ 2007-08-08  Glenn Morris  <rgm@gnu.org>
+       * emacs-lisp/eldoc.el (eldoc-get-fnsym-args-string): Make second
+       argument optional, for backwards compatibility, and only highlight
+       args when present.  Fix symbol name typo (doc/args).
+       * help-mode.el (help-make-xrefs): Search for symbol constituents,
+       rather than just `-'.
+ 2007-08-07  Jay Belanger  <jay.p.belanger@gmail.com>
+       * calc/calc-units.el (calc-convert-temperature):
+       Use `/' to create fractions.
+ 2007-08-07  Michael Albinus  <michael.albinus@gmx.de>
+       * net/tramp.el (tramp-wrong-passwd-regexp): Make the regexp more
+       global matching.
+       (tramp-handle-shell-command): Handle OUTPUT-BUFFER and
+       ERROR-BUFFER more robust.  Display output.
+       (tramp-file-name-handler): Add a connection property when we found
+       a foreign file name handler.  This allows backends like ftp to
+       profit also from usr/host name completion based on connection
+       cache.
+       (tramp-send-command-and-read): Search for trash after the regexp
+       until eol only.  In XEmacs, there is a problem with \n.
+       * net/tramp-cache.el (top): Read persistent connection history
+       when cache is empty.
+ 2007-08-07  Nic Ferrier  <nferrier@tapsellferrier.co.uk>  (tiny change)
+       * net/tramp.el (tramp-handle-process-file): Fix bug inserting
+       resulting output.
+ 2007-08-07  Sam Steingold  <sds@gnu.org>
+       * progmodes/compile.el (compilation-start): Pass nil as startfile
+       to comint-exec.
+ 2007-08-07  Chong Yidong  <cyd@stupidchicken.com>
+       * longlines.el (longlines-decoded): New variable.
+       (longlines-mode): Avoid encoding or decoding the buffer twice.
+ 2007-08-07  Martin Rudalics  <rudalics@gmx.at>
+       * format.el (format-insert-file): Make sure that at most one undo
+       entry is recorded for the insertion.  Inhibit point-motion and
+       modification hooks around call to insert-file-contents.
+ 2007-08-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * vc.el (vc-annotate): Select temp-buffer before running vc-exec-after.
+       Select the buffer's window before moving point.
+ 2007-08-07  Richard Stallman  <rms@gnu.org>
+       * term.el (term): Remove parent group `unix'.
+       * simple.el (default-indent-new-line): New function.
+       It calls comment-line-break-function if there are comments.
+       (do-auto-fill): Use that.
+ 2007-08-07  Ivan Kanis  <apple@kanis.eu>
+       * time.el (display-time-world-mode, display-time-world-display)
+       (display-time-world, display-time-world-list)
+       (display-time-world-time-format, display-time-world-buffer-name)
++      (display-time-world-timer-enable)
++      (display-time-world-timer-second, display-time-world-mode-map): 
++      New.
++      
+ 2007-08-07  Sean O'Rourke  <sorourke@cs.ucsd.edu>
+       * complete.el (PC-lisp-complete-symbol): Complete symbol around point.
+       (PC-do-completion): Add "acronym completion" for symbols and
+       filenames, so e.g. "mvbl" expands to "make-variable-buffer-local".
+ 2007-08-06  Sam Steingold  <sds@gnu.org>
+       * mouse.el (mouse-buffer-menu): Pass mode-name through
+       format-mode-line because it may be a list,
+       e.g., (sgml-xml-mode "XML" "SGML"), and not a string.
  2007-08-06  Vinicius Jose Latorre  <viniciusig@ig.com.br>
  
 -2007-08-05  Jay Belanger  <jay.p.belanger@gmail.com>
+       * printing.el (pr-update-menus): Docstring fix.
+ 2007-08-06  Jason Rumney  <jasonr@gnu.org>
+       * menu-bar.el (menu-bar-vc-filter): Use vc-call-backend.
+       * vc-hooks.el (vc-call): Add doc string.
+ 2007-08-06  Michael Albinus  <michael.albinus@gmx.de>
+       * net/ange-ftp.el (ange-ftp-hook-function): Catch also errors in
+       process-filter.
+ 2007-08-06  Kenichi Handa  <handa@m17n.org>
+       * international/quail.el: Wrap (require 'help-mode) by
+       eval-when-compile.
+       (quail-help-init): New function.
+       (quail-help): Call quail-help-init.
+       (quail-store-decode-map-key): Change it to a function.
+ 2007-08-05  Jason Rumney  <jasonr@gnu.org>
+       * vc.el (vc-rollback): Add norevert argument back.
+       (vc-revert-buffer): Add back as obsolete alias.
+ 2007-08-05  Peter Povinec  <ppovinec@yahoo.com>  (tiny change)
+       * term.el: Honor term-default-fg-color and term-default-bg-color
+       settings when modifying term-current-face.
+       (term-default-fg-color, term-default-bg-color): Initialize from
+       default term-current-face.
+       (term-mode, term-reset-terminal): Set term-current-face with
+       term-default-fg-color and term-default-bg-color.
+       (term-handle-colors-array): term-current-face has term-default-fg-color
+       and term-default-bg-color after reset escape sequence.
+       (term-handle-colors-array): Set term-current-color with
+       term-default-fg/bg-color instead of ansi-term-color-vector when the
+       index (term-ansi-current-color or term-ansi-current-bg-color) is zero.
 -      * calc/calc-nlfit.el (math-nlfit-curve): Remove unnecessary variables.
++2007-08-05  Jay Belanger  <belanger@localhost.localdomain>
++      * calc/calc-nlfit.el (math-nlfit-curve):
++      Remove unnecessary variables.
+       (math-nlfit-givens): Let bind free variables.
+ 2007-08-05  Vinicius Jose Latorre  <viniciusig@ig.com.br>
        * printing.el: Require lpr and ps-print when loading printing package.
        Reported by Glenn Morris <rgm@gnu.org>.
-       (pr-update-menus): Docstring fix.
+ 2007-08-05  Michael Albinus  <michael.albinus@gmx.de>
+       * files.el (set-auto-mode): Handle also remote files wrt
+       `auto-mode-alist'.
 -2007-08-04  Jay Belanger  <jay.p.belanger@gmail.com>
++2007-08-04  Jay Belanger  <belanger@localhost.localdomain>
+       * calc/calcalg3.el (calc-curve-fit): Add support for nonlinear
+       curves and plotting.
+       * calc/calc-nlfit.el: New file.
+ 2007-08-04  Glenn Morris  <rgm@gnu.org>
+       * autorevert.el (auto-revert-tail-mode): auto-revert-tail-pos is
+       zero, not nil, when the library is first loaded.  Check for a file
+       that has been modified on disk.
+       * progmodes/cperl-mode.el (cperl-compilation-error-regexp-alist):
+       Remove duplicate defvar preventing initialization.
+       (cperl-mode): Fix compilation-error-regexp-alist-alist setting.
+ 2007-08-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+       * diff-mode.el (diff-font-lock-keywords): Fix up false positives.
+       (diff-beginning-of-file): Adjust to the fact that diff-file-header-re
+       may match up to 4 lines.
+       (diff-beginning-of-file-and-junk): Rewrite.
  
  2007-08-03  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
  
        (deactivate-mark): Replace (defvar VAR nil) by (defvar VAR).
        (pr-global-menubar): Fix code.
  
+ 2007-08-03  Dan Nicolaescu  <dann@ics.uci.edu>
+       * term.el (term-erase-in-display): Fix case when point is not at
+       the beginning of the line.
  2007-08-03  Jay Belanger  <jay.p.belanger@gmail.com>
  
 -      * calc/calc-ext.el (math-get-value, math-get-sdev)
 +      * calc/calc-ext.el (math-get-value,math-get-sdev)
        (math-contains-sdev): New functions.
  
        * calc/calc-graph.el (calc-graph-format-data)
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc lisp/format.el
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc lisp/isearch.el
Simple merge
Simple merge
Simple merge
diff --cc lisp/simple.el
Simple merge
diff --cc lisp/subr.el
Simple merge
diff --cc lisp/term.el
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc src/ChangeLog
Simple merge
diff --cc src/buffer.h
Simple merge
diff --cc src/callproc.c
Simple merge
diff --cc src/casetab.c
Simple merge
diff --cc src/category.c
Simple merge
diff --cc src/ccl.c
Simple merge
diff --cc src/charset.h
index 1b5fba67064e6b05e839b93bca74108252d26a14,c20766f910b49f806463d6469bab8a29b9f3fd00..6d34a5feea3d78038019223857d003e55a407e15
@@@ -30,523 -26,866 +30,523 @@@ Boston, MA 02110-1301, USA.  *
  #ifndef EMACS_CHARSET_H
  #define EMACS_CHARSET_H
  
 -/* #define BYTE_COMBINING_DEBUG */
 -
 -/*** GENERAL NOTE on CHARACTER SET (CHARSET) ***
 -
 -  A character set ("charset" hereafter) is a meaningful collection
 -  (i.e. language, culture, functionality, etc) of characters.  Emacs
 -  handles multiple charsets at once.  Each charset corresponds to one
 -  of the ISO charsets.  Emacs identifies a charset by a unique
 -  identification number, whereas ISO identifies a charset by a triplet
 -  of DIMENSION, CHARS and FINAL-CHAR.  So, hereafter, just saying
 -  "charset" means an identification number (integer value).
 -
 -  The value range of charsets is 0x00, 0x81..0xFE.  There are four
 -  kinds of charset depending on DIMENSION (1 or 2) and CHARS (94 or
 -  96).  For instance, a charset of DIMENSION2_CHARS94 contains 94x94
 -  characters.
 -
 -  Within Emacs Lisp, a charset is treated as a symbol which has a
 -  property `charset'.  The property value is a vector containing
 -  various information about the charset.  For readability of C code,
 -  we use the following convention for C variable names:
 -      charset_symbol: Emacs Lisp symbol of a charset
 -      charset_id: Emacs Lisp integer of an identification number of a charset
 -      charset: C integer of an identification number of a charset
 -
 -  Each charset (except for ascii) is assigned a base leading-code
 -  (range 0x80..0x9E).  In addition, a charset of greater than 0xA0
 -  (whose base leading-code is 0x9A..0x9D) is assigned an extended
 -  leading-code (range 0xA0..0xFE).  In this case, each base
 -  leading-code specifies the allowable range of extended leading-code
 -  as shown in the table below.  A leading-code is used to represent a
 -  character in Emacs' buffer and string.
 -
 -  We call a charset which has extended leading-code a "private
 -  charset" because those are mainly for a charset which is not yet
 -  registered by ISO.  On the contrary, we call a charset which does
 -  not have extended leading-code an "official charset".
 -
 -  ---------------------------------------------------------------------------
 -  charset     dimension        base leading-code      extended leading-code
 -  ---------------------------------------------------------------------------
 -  0x00                official dim1    -- none --             -- none --
 -              (ASCII)
 -  0x01..0x7F  --never used--
 -  0x80                official dim1    -- none --             -- none --
 -              (eight-bit-graphic)
 -  0x81..0x8F  official dim1    same as charset        -- none --
 -  0x90..0x99  official dim2    same as charset        -- none --
 -  0x9A..0x9D  --never used--
 -  0x9E                official dim1    same as charset        -- none --
 -              (eight-bit-control)
 -  0x9F                --never used--
 -  0xA0..0xDF  private dim1        0x9A                same as charset
 -              of 1-column width
 -  0xE0..0xEF  private dim1        0x9B                same as charset
 -              of 2-column width
 -  0xF0..0xF4  private dim2        0x9C                same as charset
 -              of 1-column width
 -  0xF5..0xFE  private dim2        0x9D                same as charset
 -              of 2-column width
 -  0xFF                --never used--
 -  ---------------------------------------------------------------------------
 -
 -*/
 -
 -/* Definition of special leading-codes.  */
 -/* Leading-code followed by extended leading-code.  */
 -#define LEADING_CODE_PRIVATE_11       0x9A /* for private DIMENSION1 of 1-column */
 -#define LEADING_CODE_PRIVATE_12       0x9B /* for private DIMENSION1 of 2-column */
 -#define LEADING_CODE_PRIVATE_21       0x9C /* for private DIMENSION2 of 1-column */
 -#define LEADING_CODE_PRIVATE_22       0x9D /* for private DIMENSION2 of 2-column */
 -
 -#define LEADING_CODE_8_BIT_CONTROL 0x9E /* for `eight-bit-control' */
 -
 -/* Extended leading-code.  */
 -/* Start of each extended leading-codes.  */
 -#define LEADING_CODE_EXT_11 0xA0 /* follows LEADING_CODE_PRIVATE_11 */
 -#define LEADING_CODE_EXT_12 0xE0 /* follows LEADING_CODE_PRIVATE_12 */
 -#define LEADING_CODE_EXT_21 0xF0 /* follows LEADING_CODE_PRIVATE_21 */
 -#define LEADING_CODE_EXT_22 0xF5 /* follows LEADING_CODE_PRIVATE_22 */
 -/* Maximum value of extended leading-codes.  */
 -#define LEADING_CODE_EXT_MAX 0xFE
 -
 -/* Definition of minimum/maximum charset of each DIMENSION.  */
 -#define MIN_CHARSET_OFFICIAL_DIMENSION1       0x80
 -#define MAX_CHARSET_OFFICIAL_DIMENSION1       0x8F
 -#define MIN_CHARSET_OFFICIAL_DIMENSION2       0x90
 -#define MAX_CHARSET_OFFICIAL_DIMENSION2 0x99
 -#define MIN_CHARSET_PRIVATE_DIMENSION1        LEADING_CODE_EXT_11
 -#define MIN_CHARSET_PRIVATE_DIMENSION2        LEADING_CODE_EXT_21
 -
 -/* Maximum value of overall charset identification number.  */
 -#define MAX_CHARSET 0xFE
 -
 -/* Definition of special charsets.  */
 -#define CHARSET_ASCII         0       /* 0x00..0x7F */
 -#define CHARSET_8_BIT_CONTROL 0x9E    /* 0x80..0x9F */
 -#define CHARSET_8_BIT_GRAPHIC 0x80    /* 0xA0..0xFF */
 -
 -extern int charset_latin_iso8859_1; /* ISO8859-1 (Latin-1) */
 -extern int charset_jisx0208_1978; /* JISX0208.1978 (Japanese Kanji old set) */
 -extern int charset_jisx0208;  /* JISX0208.1983 (Japanese Kanji) */
 -extern int charset_katakana_jisx0201; /* JISX0201.Kana (Japanese Katakana) */
 -extern int charset_latin_jisx0201; /* JISX0201.Roman (Japanese Roman) */
 -extern int charset_big5_1;    /* Big5 Level 1 (Chinese Traditional) */
 -extern int charset_big5_2;    /* Big5 Level 2 (Chinese Traditional) */
 -extern int charset_mule_unicode_0100_24ff;
 -extern int charset_mule_unicode_2500_33ff;
 -extern int charset_mule_unicode_e000_ffff;
 -
 -/* Check if CH is an ASCII character or a base leading-code.
 -   Nowadays, any byte can be the first byte of a character in a
 -   multibyte buffer/string.  So this macro name is not appropriate.  */
 -#define CHAR_HEAD_P(ch) ((unsigned char) (ch) < 0xA0)
 -
 -/*** GENERAL NOTE on CHARACTER REPRESENTATION ***
 -
 -  Firstly, the term "character" or "char" is used for a multilingual
 -  character (of course, including ASCII characters), not for a byte in
 -  computer memory.  We use the term "code" or "byte" for the latter
 -  case.
 -
 -  A character is identified by charset and one or two POSITION-CODEs.
 -  POSITION-CODE is the position of the character in the charset.  A
 -  character of DIMENSION1 charset has one POSITION-CODE: POSITION-CODE-1.
 -  A character of DIMENSION2 charset has two POSITION-CODE:
 -  POSITION-CODE-1 and POSITION-CODE-2.  The code range of
 -  POSITION-CODE is 0x20..0x7F.
 -
 -  Emacs has two kinds of representation of a character: multi-byte
 -  form (for buffers and strings) and single-word form (for character
 -  objects in Emacs Lisp).  The latter is called "character code"
 -  hereafter.  Both representations encode the information of charset
 -  and POSITION-CODE but in a different way (for instance, the MSB of
 -  POSITION-CODE is set in multi-byte form).
 -
 -  For details of the multi-byte form, see the section "2. Emacs
 -  internal format handlers" of `coding.c'.
 -
 -  Emacs uses 19 bits for a character code.  The bits are divided into
 -  3 fields: FIELD1(5bits):FIELD2(7bits):FIELD3(7bits).
 -
 -  A character code of DIMENSION1 character uses FIELD2 to hold charset
 -  and FIELD3 to hold POSITION-CODE-1.  A character code of DIMENSION2
 -  character uses FIELD1 to hold charset, FIELD2 and FIELD3 to hold
 -  POSITION-CODE-1 and POSITION-CODE-2 respectively.
 -
 -  More precisely...
 -
 -  FIELD2 of DIMENSION1 character (except for ascii, eight-bit-control,
 -  and eight-bit-graphic) is "charset - 0x70".  This is to make all
 -  character codes except for ASCII and 8-bit codes greater than 256.
 -  So, the range of FIELD2 of DIMENSION1 character is 0, 1, or
 -  0x11..0x7F.
 -
 -  FIELD1 of DIMENSION2 character is "charset - 0x8F" for official
 -  charset and "charset - 0xE0" for private charset.  So, the range of
 -  FIELD1 of DIMENSION2 character is 0x01..0x1E.
 -
 -  -----------------------------------------------------------------------------
 -  charset             FIELD1 (5-bit)      FIELD2 (7-bit)      FIELD3 (7-bit)
 -  -----------------------------------------------------------------------------
 -  ascii                       0                   0                   0x00..0x7F
 -  eight-bit-control   0                   1                   0x00..0x1F
 -  eight-bit-graphic   0                   1                   0x20..0x7F
 -  DIMENSION1          0                   charset - 0x70      POSITION-CODE-1
 -  DIMENSION2(o)               charset - 0x8F      POSITION-CODE-1     POSITION-CODE-2
 -  DIMENSION2(p)               charset - 0xE0      POSITION-CODE-1     POSITION-CODE-2
 -  -----------------------------------------------------------------------------
 -  "(o)": official, "(p)": private
 -  -----------------------------------------------------------------------------
 -*/
 -
 -/* Masks of each field of character code.  */
 -#define CHAR_FIELD1_MASK (0x1F << 14)
 -#define CHAR_FIELD2_MASK (0x7F << 7)
 -#define CHAR_FIELD3_MASK 0x7F
 -
 -/* Macros to access each field of character C.  */
 -#define CHAR_FIELD1(c) (((c) & CHAR_FIELD1_MASK) >> 14)
 -#define CHAR_FIELD2(c) (((c) & CHAR_FIELD2_MASK) >> 7)
 -#define CHAR_FIELD3(c) ((c) & CHAR_FIELD3_MASK)
 -
 -/* Minimum character code of character of each DIMENSION.  */
 -#define MIN_CHAR_OFFICIAL_DIMENSION1 \
 -  ((0x81 - 0x70) << 7)
 -#define MIN_CHAR_PRIVATE_DIMENSION1 \
 -  ((MIN_CHARSET_PRIVATE_DIMENSION1 - 0x70) << 7)
 -#define MIN_CHAR_OFFICIAL_DIMENSION2 \
 -  ((MIN_CHARSET_OFFICIAL_DIMENSION2 - 0x8F) << 14)
 -#define MIN_CHAR_PRIVATE_DIMENSION2 \
 -  ((MIN_CHARSET_PRIVATE_DIMENSION2 - 0xE0) << 14)
 -/* Maximum character code currently used plus 1.  */
 -#define MAX_CHAR (0x1F << 14)
 -
 -/* 1 if C is a single byte character, else 0.  */
 -#define SINGLE_BYTE_CHAR_P(c) (((unsigned)(c) & 0xFF) == (c))
 -
 -/* 1 if BYTE is an ASCII character in itself, in multibyte mode.  */
 -#define ASCII_BYTE_P(byte) ((byte) < 0x80)
 -
 -/* A char-table containing information on each character set.
 -
 -   Unlike ordinary char-tables, this doesn't contain any nested tables.
 -   Only the top level elements are used.  Each element is a vector of
 -   the following information:
 -      CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
 -      LEADING-CODE-BASE, LEADING-CODE-EXT,
 -      ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
 -      REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
 -      PLIST.
 -
 -   CHARSET-ID (integer) is the identification number of the charset.
 -
 -   BYTES (integer) is the length of the multi-byte form of a character
 -   in the charset: one of 1, 2, 3, and 4.
 -
 -   DIMENSION (integer) is the number of bytes to represent a character: 1 or 2.
 -
 -   CHARS (integer) is the number of characters in a dimension: 94 or 96.
 -
 -   WIDTH (integer) is the number of columns a character in the charset
 -   occupies on the screen: one of 0, 1, and 2..
 -
 -   DIRECTION (integer) is the rendering direction of characters in the
 -   charset when rendering.  If 0, render from left to right, else
 -   render from right to left.
 -
 -   LEADING-CODE-BASE (integer) is the base leading-code for the
 -   charset.
 -
 -   LEADING-CODE-EXT (integer) is the extended leading-code for the
 -   charset.  All charsets of less than 0xA0 have the value 0.
 -
 -   ISO-FINAL-CHAR (character) is the final character of the
 -   corresponding ISO 2022 charset.  It is -1 for such a character
 -   that is used only internally (e.g. `eight-bit-control').
 -
 -   ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
 -   while encoding to variants of ISO 2022 coding system, one of the
 -   following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).  It
 -   is -1 for such a character that is used only internally
 -   (e.g. `eight-bit-control').
 -
 -   REVERSE-CHARSET (integer) is the charset which differs only in
 -   LEFT-TO-RIGHT value from the charset.  If there's no such a
 -   charset, the value is -1.
 -
 -   SHORT-NAME (string) is the short name to refer to the charset.
 -
 -   LONG-NAME (string) is the long name to refer to the charset.
 -
 -   DESCRIPTION (string) is the description string of the charset.
 -
 -   PLIST (property list) may contain any type of information a user
 -   wants to put and get by functions `put-charset-property' and
 -   `get-charset-property' respectively.  */
 -extern Lisp_Object Vcharset_table;
 -
 -/* Macros to access various information of CHARSET in Vcharset_table.
 -   We provide these macros for efficiency.  No range check of CHARSET.  */
 -
 -/* Return entry of CHARSET (C integer) in Vcharset_table.  */
 -#define CHARSET_TABLE_ENTRY(charset)                                  \
 -  XCHAR_TABLE (Vcharset_table)->contents[((charset) == CHARSET_ASCII  \
 -                                        ? 0 : (charset) + 128)]
 -
 -/* Return information INFO-IDX of CHARSET.  */
 -#define CHARSET_TABLE_INFO(charset, info_idx) \
 -  XVECTOR (CHARSET_TABLE_ENTRY (charset))->contents[info_idx]
 -
 -#define CHARSET_ID_IDX (0)
 -#define CHARSET_BYTES_IDX (1)
 -#define CHARSET_DIMENSION_IDX (2)
 -#define CHARSET_CHARS_IDX (3)
 -#define CHARSET_WIDTH_IDX (4)
 -#define CHARSET_DIRECTION_IDX (5)
 -#define CHARSET_LEADING_CODE_BASE_IDX (6)
 -#define CHARSET_LEADING_CODE_EXT_IDX (7)
 -#define CHARSET_ISO_FINAL_CHAR_IDX (8)
 -#define CHARSET_ISO_GRAPHIC_PLANE_IDX (9)
 -#define CHARSET_REVERSE_CHARSET_IDX (10)
 -#define CHARSET_SHORT_NAME_IDX (11)
 -#define CHARSET_LONG_NAME_IDX (12)
 -#define CHARSET_DESCRIPTION_IDX (13)
 -#define CHARSET_PLIST_IDX (14)
 -/* Size of a vector of each entry of Vcharset_table.  */
 -#define CHARSET_MAX_IDX (15)
 -
 -/* And several more macros to be used frequently.  */
 -#define CHARSET_BYTES(charset) \
 -  XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_BYTES_IDX))
 -#define CHARSET_DIMENSION(charset) \
 -  XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIMENSION_IDX))
 -#define CHARSET_CHARS(charset) \
 -  XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_CHARS_IDX))
 -#define CHARSET_WIDTH(charset) \
 -  XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_WIDTH_IDX))
 -#define CHARSET_DIRECTION(charset) \
 -  XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIRECTION_IDX))
 -#define CHARSET_LEADING_CODE_BASE(charset) \
 -  XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_BASE_IDX))
 -#define CHARSET_LEADING_CODE_EXT(charset) \
 -  XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_EXT_IDX))
 -#define CHARSET_ISO_FINAL_CHAR(charset) \
 -  XINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_FINAL_CHAR_IDX))
 -#define CHARSET_ISO_GRAPHIC_PLANE(charset) \
 -  XINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_GRAPHIC_PLANE_IDX))
 -#define CHARSET_REVERSE_CHARSET(charset) \
 -  XINT (CHARSET_TABLE_INFO (charset, CHARSET_REVERSE_CHARSET_IDX))
 -
 -/* Macros to specify direction of a charset.  */
 -#define CHARSET_DIRECTION_LEFT_TO_RIGHT 0
 -#define CHARSET_DIRECTION_RIGHT_TO_LEFT 1
 -
 -/* A vector of charset symbol indexed by charset-id.  This is used
 -   only for returning charset symbol from C functions.  */
 -extern Lisp_Object Vcharset_symbol_table;
 -
 -/* Return symbol of CHARSET.  */
 -#define CHARSET_SYMBOL(charset) \
 -  XVECTOR (Vcharset_symbol_table)->contents[charset]
 -
 -/* 1 if CHARSET is in valid value range, else 0.  */
 -#define CHARSET_VALID_P(charset)                                       \
 -  ((charset) == 0                                                      \
 -   || ((charset) > 0x80 && (charset) <= MAX_CHARSET_OFFICIAL_DIMENSION2) \
 -   || ((charset) >= MIN_CHARSET_PRIVATE_DIMENSION1                     \
 -       && (charset) <= MAX_CHARSET)                                    \
 -   || ((charset) == CHARSET_8_BIT_CONTROL)                             \
 -   || ((charset) == CHARSET_8_BIT_GRAPHIC))
 -
 -/* 1 if CHARSET is already defined, else 0.  */
 -#define CHARSET_DEFINED_P(charset)                    \
 -  (((charset) >= 0) && ((charset) <= MAX_CHARSET)     \
 -   && !NILP (CHARSET_TABLE_ENTRY (charset)))
 -
 -/* Since the information CHARSET-BYTES and CHARSET-WIDTH of
 -   Vcharset_table can be retrieved only by the first byte of
 -   multi-byte form (an ASCII code or a base leading-code), we provide
 -   here tables to be used by macros BYTES_BY_CHAR_HEAD and
 -   WIDTH_BY_CHAR_HEAD for faster information retrieval.  */
 -extern int bytes_by_char_head[256];
 -extern int width_by_char_head[256];
 -
 -#define BYTES_BY_CHAR_HEAD(char_head) \
 -  (ASCII_BYTE_P (char_head) ? 1 : bytes_by_char_head[char_head])
 -#define WIDTH_BY_CHAR_HEAD(char_head) \
 -  (ASCII_BYTE_P (char_head) ? 1 : width_by_char_head[char_head])
 -
 -/* Charset of the character C.  */
 -#define CHAR_CHARSET(c)                                                       \
 -  (SINGLE_BYTE_CHAR_P (c)                                             \
 -   ? (ASCII_BYTE_P (c)                                                        \
 -      ? CHARSET_ASCII                                                 \
 -      : (c) < 0xA0 ? CHARSET_8_BIT_CONTROL : CHARSET_8_BIT_GRAPHIC)   \
 -   : ((c) < MIN_CHAR_OFFICIAL_DIMENSION2                              \
 -      ? CHAR_FIELD2 (c) + 0x70                                                \
 -      : ((c) < MIN_CHAR_PRIVATE_DIMENSION2                            \
 -       ? CHAR_FIELD1 (c) + 0x8F                                       \
 -       : CHAR_FIELD1 (c) + 0xE0)))
 +/* Index to arguments of Fdefine_charset_internal.  */
 +
 +enum define_charset_arg_index
 +  {
 +    charset_arg_name,
 +    charset_arg_dimension,
 +    charset_arg_code_space,
 +    charset_arg_min_code,
 +    charset_arg_max_code,
 +    charset_arg_iso_final,
 +    charset_arg_iso_revision,
 +    charset_arg_emacs_mule_id,
 +    charset_arg_ascii_compatible_p,
 +    charset_arg_supplementary_p,
 +    charset_arg_invalid_code,
 +    charset_arg_code_offset,
 +    charset_arg_map,
 +    charset_arg_subset,
 +    charset_arg_superset,
 +    charset_arg_unify_map,
 +    charset_arg_plist,
 +    charset_arg_max
 +  };
 +
 +
 +/* Indices to charset attributes vector.  */
 +
 +enum charset_attr_index
 +  {
 +    /* ID number of the charset.  */
 +    charset_id,
 +
 +    /* Name of the charset (symbol).  */
 +    charset_name,
 +
 +    /* Property list of the charset.  */
 +    charset_plist,
 +
 +    /* If the method of the charset is `MAP_DEFERRED', the value is a
 +       mapping vector or a file name that contains mapping vector.
 +       Otherwise, nil.  */
 +    charset_map,
 +
 +    /* If the method of the charset is `MAP', the value is a vector
 +       that maps code points of the charset to characters.  The vector
 +       is indexed by a character index.  A character index is
 +       calculated from a code point and the code-space table of the
 +       charset.  */
 +    charset_decoder,
 +
 +    /* If the method of the charset is `MAP', the value is a
 +       char-table that maps characters of the charset to code
 +       points.  */
 +    charset_encoder,
 +
 +    /* If the method of the charset is `SUBSET', the value is a vector
 +       that has this form:
 +
 +      [ CHARSET-ID MIN-CODE MAX-CODE OFFSET ]
 +
 +       CHARSET-ID is an ID number of a parent charset.  MIN-CODE and
 +       MAX-CODE specify the range of characters inherited from the
 +       parent.  OFFSET is an integer value to add to a code point of
 +       the parent charset to get the corresponding code point of this
 +       charset.  */
 +    charset_subset,
 +
 +    /* If the method of the charset is `SUPERSET', the value is a list
 +       whose elements have this form:
 +
 +      (CHARSET-ID . OFFSET)
 +
 +      CHARSET-IDs are ID numbers of parent charsets.  OFFSET is an
 +      integer value to add to a code point of the parent charset to
 +      get the corresponding code point of this charset.  */
 +    charset_superset,
 +
 +    /* The value is a mapping vector or a file name that contains the
 +       mapping.  This defines how characters in the charset should be
 +       unified with Unicode.  The value of the member
 +       `charset_deunifier' is created from this information.  */
 +    charset_unify_map,
 +
 +    /* If characters in the charset must be unified Unicode, the value
 +       is a char table that maps a unified Unicode character code to
 +       the non-unified character code in the charset.  */
 +    charset_deunifier,
 +
 +    /* The length of the charset attribute vector.  */
 +    charset_attr_max
 +  };
 +
 +/* Methods for converting code points and characters of charsets.  */
 +
 +enum charset_method
 +  {
 +    /* For a charset of this method, a character code is calculated
 +       from a character index (which is calculated from a code point)
 +       simply by adding an offset value.  */
 +    CHARSET_METHOD_OFFSET,
 +
 +    /* For a charset of this method, a decoder vector and an encoder
 +       char-table is used for code point <-> character code
 +       conversion.  */
 +    CHARSET_METHOD_MAP,
 +
 +    /* Same as above but decoder and encoder are loaded from a file on
 +       demand.  Once loaded, the method is changed to
 +       CHARSET_METHOD_MAP.  */
 +    CHARSET_METHOD_MAP_DEFERRED,
 +
 +    /* A charset of this method is a subset of another charset.  */
 +    CHARSET_METHOD_SUBSET,
 +
 +    /* A charset of this method is a superset of other charsets.  */
 +    CHARSET_METHOD_SUPERSET
 +  };
 +
 +struct charset
 +{
 +  /* Index to charset_table.  */
 +  int id;
  
 -/* Check if two characters C1 and C2 belong to the same charset.  */
 -#define SAME_CHARSET_P(c1, c2)                                \
 -  (c1 < MIN_CHAR_OFFICIAL_DIMENSION2                  \
 -   ? (c1 & CHAR_FIELD2_MASK) == (c2 & CHAR_FIELD2_MASK)       \
 -   : (c1 & CHAR_FIELD1_MASK) == (c2 & CHAR_FIELD1_MASK))
 -
 -/* Return a character of which charset is CHARSET and position-codes
 -   are C1 and C2.  DIMENSION1 character ignores C2.  */
 -#define MAKE_CHAR(charset, c1, c2)                                        \
 -  ((charset) == CHARSET_ASCII                                             \
 -   ? (c1) & 0x7F                                                          \
 -   : (((charset) == CHARSET_8_BIT_CONTROL                                 \
 -       || (charset) == CHARSET_8_BIT_GRAPHIC)                             \
 -      ? ((c1) & 0x7F) | 0x80                                              \
 -      : ((CHARSET_DEFINED_P (charset)                                     \
 -        ? CHARSET_DIMENSION (charset) == 1                                \
 -        : (charset) < MIN_CHARSET_PRIVATE_DIMENSION2)                     \
 -       ? (((charset) - 0x70) << 7) | ((c1) <= 0 ? 0 : ((c1) & 0x7F))      \
 -       : ((((charset)                                                     \
 -            - ((charset) < MIN_CHARSET_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \
 -           << 14)                                                         \
 -          | ((c2) <= 0 ? 0 : ((c2) & 0x7F))                               \
 -          | ((c1) <= 0 ? 0 : (((c1) & 0x7F) << 7))))))
 -
 -
 -/* If GENERICP is nonzero, return nonzero if C is a valid normal or
 -   generic character.  If GENERICP is zero, return nonzero if C is a
 -   valid normal character.  */
 -#define CHAR_VALID_P(c, genericp)     \
 -  ((c) >= 0                           \
 -   && (SINGLE_BYTE_CHAR_P (c) || char_valid_p (c, genericp)))
 -
 -/* This default value is used when nonascii-translation-table or
 -   nonascii-insert-offset fail to convert unibyte character to a valid
 -   multibyte character.  This makes a Latin-1 character.  */
 -
 -#define DEFAULT_NONASCII_INSERT_OFFSET 0x800
 -
 -/* Parse multibyte string STR of length LENGTH and set BYTES to the
 -   byte length of a character at STR.  */
 -
 -#ifdef BYTE_COMBINING_DEBUG
 -
 -#define PARSE_MULTIBYTE_SEQ(str, length, bytes)                       \
 +  /* Index to Vcharset_hash_table.  */
 +  int hash_index;
 +
 +  /* Dimension of the charset: 1, 2, 3, or 4.  */
 +  int dimension;
 +
 +  /* Byte code range of each dimension.  <code_space>[4N] is a mininum
 +     byte code of the (N+1)th dimension, <code_space>[4N+1] is a
 +     maximum byte code of the (N+1)th dimension, <code_space>[4N+2] is
 +     (<code_space>[4N+1] - <code_space>[4N] + 1), <code_space>[4N+3]
 +     is a number of characters containd in the first to (N+1)th
 +     dismesions.  We get `char-index' of a `code-point' from this
 +     information.  */
 +  int code_space[16];
 +
 +  /* If B is a byte of Nth dimension of a code-point, the (N-1)th bit
 +     of code_space_mask[B] is set.  This array is used to quickly
 +     check if a code-point is in a valid range.  */
 +  unsigned char *code_space_mask;
 +
 +  /* 1 if there's no gap in code-points.  */
 +  int code_linear_p;
 +
 +  /* If the charset is treated as 94-chars in ISO-2022, the value is 0.
 +     If the charset is treated as 96-chars in ISO-2022, the value is 1.  */
 +  int iso_chars_96;
 +
 +  /* ISO final byte of the charset: 48..127.  It may be -1 if the
 +     charset doesn't conform to ISO-2022.  */
 +  int iso_final;
 +
 +  /* ISO revision number of the charset.  */
 +  int iso_revision;
 +
 +  /* If the charset is identical to what supported by Emacs 21 and the
 +     priors, the identification number of the charset used in those
 +     version.  Otherwise, -1.  */
 +  int emacs_mule_id;
 +
-   /* Nonzero iff the charset is compatible with ASCII.  */
++  /* Nonzero if the charset is compatible with ASCII.  */
 +  int ascii_compatible_p;
 +
-   /* Nonzero iff the charset is supplementary.  */
++  /* Nonzero if the charset is supplementary.  */
 +  int supplementary_p;
 +
-   /* Nonzero iff all the code points are representable by Lisp_Int.  */
++  /* Nonzero if all the code points are representable by Lisp_Int.  */
 +  int compact_codes_p;
 +
 +  /* The method for encoding/decoding characters of the charset.  */
 +  enum charset_method method;
 +
 +  /* Mininum and Maximum code points of the charset.  */
 +  unsigned min_code, max_code;
 +
 +  /* Offset value used by macros CODE_POINT_TO_INDEX and
 +      INDEX_TO_CODE_POINT. .  */
 +  unsigned char_index_offset;
 +
 +  /* Mininum and Maximum character codes of the charset.  If the
 +     charset is compatible with ASCII, min_char is a minimum non-ASCII
 +     character of the charset.  If the method of charset is
 +     CHARSET_METHOD_OFFSET, even if the charset is unified, min_char
 +     and max_char doesn't change.  */
 +  int min_char, max_char;
 +
 +  /* The code returned by ENCODE_CHAR if a character is not encodable
 +     by the charset.  */
 +  unsigned invalid_code;
 +
 +  /* If the method of the charset is CHARSET_METHOD_MAP, this is a
 +     table of bits used to quickly and roughly guess if a character
 +     belongs to the charset.
 +
 +     The first 64 elements are 512 bits for characters less than
 +     0x10000.  Each bit corresponds to 128-character block.  The last
 +     126 elements are 1008 bits for the greater characters
 +     (0x10000..0x3FFFFF).  Each bit corresponds to 4096-character
 +     block.
 +
 +     If a bit is 1, at least one character in the corresponding block is
 +     in this charset.  */
 +  unsigned char fast_map[190];
 +
 +  /* Offset value to calculate a character code from code-point, and
 +     visa versa.  */
 +  int code_offset;
 +
 +  int unified_p;
 +};
 +
 +/* Hash table of charset symbols vs. the correponding attribute
 +   vectors.  */
 +extern Lisp_Object Vcharset_hash_table;
 +
 +/* Table of struct charset.  */
 +extern struct charset *charset_table;
 +
 +#define CHARSET_FROM_ID(id) (charset_table + (id))
 +
 +extern Lisp_Object Vcharset_ordered_list;
 +
 +/* Incremented everytime we change the priority of charsets.  */
 +extern unsigned short charset_ordered_list_tick;
 +
 +extern Lisp_Object Vcharset_list;
 +extern Lisp_Object Viso_2022_charset_list;
 +extern Lisp_Object Vemacs_mule_charset_list;
 +
 +extern struct charset *emacs_mule_charset[256];
 +
 +
 +/* Macros to access information about charset.  */
 +
 +/* Return the attribute vector of charset whose symbol is SYMBOL.  */
 +#define CHARSET_SYMBOL_ATTRIBUTES(symbol)     \
 +  Fgethash ((symbol), Vcharset_hash_table, Qnil)
 +
 +#define CHARSET_ATTR_ID(attrs)                AREF ((attrs), charset_id)
 +#define CHARSET_ATTR_NAME(attrs)      AREF ((attrs), charset_name)
 +#define CHARSET_ATTR_PLIST(attrs)     AREF ((attrs), charset_plist)
 +#define CHARSET_ATTR_MAP(attrs)               AREF ((attrs), charset_map)
 +#define CHARSET_ATTR_DECODER(attrs)   AREF ((attrs), charset_decoder)
 +#define CHARSET_ATTR_ENCODER(attrs)   AREF ((attrs), charset_encoder)
 +#define CHARSET_ATTR_SUBSET(attrs)    AREF ((attrs), charset_subset)
 +#define CHARSET_ATTR_SUPERSET(attrs)  AREF ((attrs), charset_superset)
 +#define CHARSET_ATTR_UNIFY_MAP(attrs) AREF ((attrs), charset_unify_map)
 +#define CHARSET_ATTR_DEUNIFIER(attrs) AREF ((attrs), charset_deunifier)
 +
 +#define CHARSET_SYMBOL_ID(symbol)     \
 +  CHARSET_ATTR_ID (CHARSET_SYMBOL_ATTRIBUTES (symbol))
 +
 +/* Return an index to Vcharset_hash_table of the charset whose symbol
 +   is SYMBOL.  */
 +#define CHARSET_SYMBOL_HASH_INDEX(symbol)     \
 +  hash_lookup (XHASH_TABLE (Vcharset_hash_table), symbol, NULL)
 +
 +/* Return the attribute vector of CHARSET.  */
 +#define CHARSET_ATTRIBUTES(charset)   \
 +  (HASH_VALUE (XHASH_TABLE (Vcharset_hash_table), (charset)->hash_index))
 +
 +#define CHARSET_ID(charset)           ((charset)->id)
 +#define CHARSET_HASH_INDEX(charset)   ((charset)->hash_index)
 +#define CHARSET_DIMENSION(charset)    ((charset)->dimension)
 +#define CHARSET_CODE_SPACE(charset)   ((charset)->code_space)
 +#define CHARSET_CODE_LINEAR_P(charset)        ((charset)->code_linear_p)
 +#define CHARSET_ISO_CHARS_96(charset) ((charset)->iso_chars_96)
 +#define CHARSET_ISO_FINAL(charset)    ((charset)->iso_final)
 +#define CHARSET_ISO_PLANE(charset)    ((charset)->iso_plane)
 +#define CHARSET_ISO_REVISION(charset) ((charset)->iso_revision)
 +#define CHARSET_EMACS_MULE_ID(charset)        ((charset)->emacs_mule_id)
 +#define CHARSET_ASCII_COMPATIBLE_P(charset) ((charset)->ascii_compatible_p)
 +#define CHARSET_COMPACT_CODES_P(charset) ((charset)->compact_codes_p)
 +#define CHARSET_METHOD(charset)               ((charset)->method)
 +#define CHARSET_MIN_CODE(charset)     ((charset)->min_code)
 +#define CHARSET_MAX_CODE(charset)     ((charset)->max_code)
 +#define CHARSET_INVALID_CODE(charset) ((charset)->invalid_code)
 +#define CHARSET_MIN_CHAR(charset)     ((charset)->min_char)
 +#define CHARSET_MAX_CHAR(charset)     ((charset)->max_char)
 +#define CHARSET_CODE_OFFSET(charset)  ((charset)->code_offset)
 +#define CHARSET_UNIFIED_P(charset)    ((charset)->unified_p)
 +
 +#define CHARSET_NAME(charset)         \
 +  (CHARSET_ATTR_NAME (CHARSET_ATTRIBUTES (charset)))
 +#define CHARSET_MAP(charset)  \
 +  (CHARSET_ATTR_MAP (CHARSET_ATTRIBUTES (charset)))
 +#define CHARSET_DECODER(charset)      \
 +  (CHARSET_ATTR_DECODER (CHARSET_ATTRIBUTES (charset)))
 +#define CHARSET_ENCODER(charset)      \
 +  (CHARSET_ATTR_ENCODER (CHARSET_ATTRIBUTES (charset)))
 +#define CHARSET_SUBSET(charset)       \
 +  (CHARSET_ATTR_SUBSET (CHARSET_ATTRIBUTES (charset)))
 +#define CHARSET_SUPERSET(charset)     \
 +  (CHARSET_ATTR_SUPERSET (CHARSET_ATTRIBUTES (charset)))
 +#define CHARSET_UNIFY_MAP(charset)    \
 +  (CHARSET_ATTR_UNIFY_MAP (CHARSET_ATTRIBUTES (charset)))
 +#define CHARSET_DEUNIFIER(charset)    \
 +  (CHARSET_ATTR_DEUNIFIER (CHARSET_ATTRIBUTES (charset)))
 +
 +
- /* Nonzero iff OBJ is a valid charset symbol.  */
++/* Nonzero if OBJ is a valid charset symbol.  */
 +#define CHARSETP(obj) (CHARSET_SYMBOL_HASH_INDEX (obj) >= 0)
 +
 +/* Check if X is a valid charset symbol.  If not, signal an error.  */
 +#define CHECK_CHARSET(x)                                      \
    do {                                                                \
 -    int i = 1;                                                        \
 -    while (i < (length) && ! CHAR_HEAD_P ((str)[i])) i++;     \
 -    (bytes) = BYTES_BY_CHAR_HEAD ((str)[0]);                  \
 -    if ((bytes) > i)                                          \
 -      abort ();                                                       \
 +    if (! SYMBOLP (x) || CHARSET_SYMBOL_HASH_INDEX (x) < 0)   \
 +      x = wrong_type_argument (Qcharsetp, (x));                       \
    } while (0)
  
 -#else  /* not BYTE_COMBINING_DEBUG */
 -
 -#define PARSE_MULTIBYTE_SEQ(str, length, bytes)       \
 -  ((void)(length), (bytes) = BYTES_BY_CHAR_HEAD ((str)[0]))
 -
 -#endif /* not BYTE_COMBINING_DEBUG */
 -
 -#define VALID_LEADING_CODE_P(code)    \
 -  (! NILP (CHARSET_TABLE_ENTRY (code)))
 -
 -/* Return 1 if the byte sequence at unibyte string STR (LENGTH bytes)
 -   is valid as a multibyte form.  If valid, by a side effect, BYTES is
 -   set to the byte length of the multibyte form.  */
 -
 -#define UNIBYTE_STR_AS_MULTIBYTE_P(str, length, bytes)                \
 -  (((str)[0] < 0x80 || (str)[0] >= 0xA0)                      \
 -   ? ((bytes) = 1)                                            \
 -   : (((bytes) = BYTES_BY_CHAR_HEAD ((str)[0])),              \
 -      ((bytes) <= (length)                                    \
 -       && !CHAR_HEAD_P ((str)[1])                             \
 -       && ((bytes) == 2                                               \
 -         ? (str)[0] != LEADING_CODE_8_BIT_CONTROL             \
 -         : (!CHAR_HEAD_P ((str)[2])                           \
 -            && ((bytes) == 3                                  \
 -                ? (((str)[0] != LEADING_CODE_PRIVATE_11       \
 -                    && (str)[0] != LEADING_CODE_PRIVATE_12)   \
 -                   || VALID_LEADING_CODE_P (str[1]))          \
 -                : (!CHAR_HEAD_P ((str)[3])                    \
 -                   && VALID_LEADING_CODE_P (str[1]))))))))
 -
 -
 -/* Return 1 if the byte sequence at multibyte string STR is valid as
 -   a unibyte form.  By a side effect, BYTES is set to the byte length
 -   of one character at STR.  */
 -
 -#define MULTIBYTE_STR_AS_UNIBYTE_P(str, bytes)        \
 -  ((bytes) = BYTES_BY_CHAR_HEAD ((str)[0]),   \
 -   (str)[0] != LEADING_CODE_8_BIT_CONTROL)
 -
 -/* The charset of character C is stored in CHARSET, and the
 -   position-codes of C are stored in C1 and C2.
 -   We store -1 in C2 if the dimension of the charset is 1.  */
 -
 -#define SPLIT_CHAR(c, charset, c1, c2)                                            \
 -  (SINGLE_BYTE_CHAR_P (c)                                                 \
 -   ? ((charset                                                                    \
 -       = (ASCII_BYTE_P (c)                                                \
 -        ? CHARSET_ASCII                                                   \
 -        : ((c) < 0xA0 ? CHARSET_8_BIT_CONTROL : CHARSET_8_BIT_GRAPHIC))), \
 -      c1 = (c), c2 = -1)                                                  \
 -   : ((c) & CHAR_FIELD1_MASK                                              \
 -      ? (charset = (CHAR_FIELD1 (c)                                       \
 -                  + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)),   \
 -       c1 = CHAR_FIELD2 (c),                                              \
 -       c2 = CHAR_FIELD3 (c))                                              \
 -      : (charset = CHAR_FIELD2 (c) + 0x70,                                \
 -       c1 = CHAR_FIELD3 (c),                                              \
 -       c2 = -1)))
 -
 -/* Return 1 if character C has valid printable glyph.  */
 -#define CHAR_PRINTABLE_P(c) (ASCII_BYTE_P (c) || char_printable_p (c))
 -
 -/* The charset of the character at STR is stored in CHARSET, and the
 -   position-codes are stored in C1 and C2.
 -   We store -1 in C2 if the character is just 2 bytes.  */
 -
 -#define SPLIT_STRING(str, len, charset, c1, c2)                       \
 -  ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) < 2           \
 -    || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > len      \
 -    || split_string (str, len, &charset, &c1, &c2) < 0)               \
 -   ? c1 = *(str), charset = CHARSET_ASCII                     \
 -   : charset)
  
 -/* Mapping table from ISO2022's charset (specified by DIMENSION,
 -   CHARS, and FINAL_CHAR) to Emacs' charset.  Should be accessed by
 -   macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR).  */
 -extern int iso_charset_table[2][2][128];
 -
 -#define ISO_CHARSET_TABLE(dimension, chars, final_char) \
 -  iso_charset_table[XINT (dimension) - 1][XINT (chars) > 94][XINT (final_char)]
 -
 -#define BASE_LEADING_CODE_P(c) (BYTES_BY_CHAR_HEAD ((unsigned char) (c)) > 1)
 -
 -/* Return how many bytes C will occupy in a multibyte buffer.  */
 -#define CHAR_BYTES(c)                                 \
 -  (SINGLE_BYTE_CHAR_P (c)                             \
 -   ? ((ASCII_BYTE_P (c) || (c) >= 0xA0) ? 1 : 2)      \
 -   : char_bytes (c))
 -
 -/* The following two macros CHAR_STRING and STRING_CHAR are the main
 -   entry points to convert between Emacs's two types of character
 -   representations: multi-byte form and single-word form (character
 -   code).  */
 -
 -/* Store multi-byte form of the character C in STR.  The caller should
 -   allocate at least MAX_MULTIBYTE_LENGTH bytes area at STR in
 -   advance.  Returns the length of the multi-byte form.  If C is an
 -   invalid character code, signal an error.  */
 -
 -#define CHAR_STRING(c, str)                                             \
 -  (SINGLE_BYTE_CHAR_P (c)                                               \
 -   ? ((ASCII_BYTE_P (c) || c >= 0xA0)                   \
 -      ? (*(str) = (unsigned char)(c), 1)                                \
 -      : (*(str) = LEADING_CODE_8_BIT_CONTROL, *((str)+ 1) = c + 0x20, 2)) \
 -   : char_to_string (c, (unsigned char *) str))
 -
 -/* Like CHAR_STRING but don't signal an error if C is invalid.
 -   Value is -1 in this case.  */
 -
 -#define CHAR_STRING_NO_SIGNAL(c, str)                                   \
 -  (SINGLE_BYTE_CHAR_P (c)                                               \
 -   ? ((ASCII_BYTE_P (c) || c >= 0xA0)                                   \
 -      ? (*(str) = (unsigned char)(c), 1)                                \
 -      : (*(str) = LEADING_CODE_8_BIT_CONTROL, *((str)+ 1) = c + 0x20, 2)) \
 -   : char_to_string_1 (c, (unsigned char *) str))
 -
 -/* Return a character code of the character of which multi-byte form
 -   is at STR and the length is LEN.  If STR doesn't contain valid
 -   multi-byte form, only the first byte in STR is returned.  */
 -
 -#define STRING_CHAR(str, len)                         \
 -  (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1   \
 -   ? (unsigned char) *(str)                           \
 -   : string_to_char (str, len, 0))
 -
 -/* This is like STRING_CHAR but the third arg ACTUAL_LEN is set to the
 -   length of the multi-byte form.  Just to know the length, use
 -   MULTIBYTE_FORM_LENGTH.  */
 -
 -#define STRING_CHAR_AND_LENGTH(str, len, actual_len)  \
 -  (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1   \
 -   ? ((actual_len) = 1), (unsigned char) *(str)               \
 -   : string_to_char (str, len, &(actual_len)))
 -
 -/* Fetch the "next" character from Lisp string STRING at byte position
 -   BYTEIDX, character position CHARIDX.  Store it into OUTPUT.
 -
 -   All the args must be side-effect-free.
 -   BYTEIDX and CHARIDX must be lvalues;
 -   we increment them past the character fetched.  */
 -
 -#define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX)      \
 -if (1)                                                                           \
 -  {                                                                      \
 -    CHARIDX++;                                                                   \
 -    if (STRING_MULTIBYTE (STRING))                                       \
 -      {                                                                          \
 -      const unsigned char *ptr = SDATA (STRING) + BYTEIDX;               \
 -      int space_left = SBYTES (STRING) - BYTEIDX;                        \
 -      int actual_len;                                                    \
 -                                                                         \
 -      OUTPUT = STRING_CHAR_AND_LENGTH (ptr, space_left, actual_len);     \
 -      BYTEIDX += actual_len;                                             \
 -      }                                                                          \
 -    else                                                                 \
 -      OUTPUT = SREF (STRING, BYTEIDX++);                                 \
 -  }                                                                      \
 -else
 -
 -/* Like FETCH_STRING_CHAR_ADVANCE but assume STRING is multibyte.  */
 -
 -#define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX)  \
 -if (1)                                                                              \
 -  {                                                                         \
 -    const unsigned char *fetch_string_char_ptr = SDATA (STRING) + BYTEIDX;    \
 -    int fetch_string_char_space_left = SBYTES (STRING) - BYTEIDX;           \
 -    int actual_len;                                                         \
 -                                                                            \
 -    OUTPUT                                                                  \
 -      = STRING_CHAR_AND_LENGTH (fetch_string_char_ptr,                              \
 -                              fetch_string_char_space_left, actual_len);    \
 -                                                                            \
 -    BYTEIDX += actual_len;                                                  \
 -    CHARIDX++;                                                                      \
 -  }                                                                         \
 -else
 -
 -/* Like FETCH_STRING_CHAR_ADVANCE but fetch character from the current
 -   buffer.  */
 -
 -#define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX)                    \
 -if (1)                                                                          \
 -  {                                                                     \
 -    CHARIDX++;                                                                  \
 -    if (!NILP (current_buffer->enable_multibyte_characters))            \
 -      {                                                                         \
 -      unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX);                     \
 -      int space_left = ((CHARIDX < GPT ? GPT_BYTE : Z_BYTE) - BYTEIDX); \
 -      int actual_len;                                                   \
 -                                                                        \
 -      OUTPUT= STRING_CHAR_AND_LENGTH (ptr, space_left, actual_len);     \
 -      BYTEIDX += actual_len;                                            \
 -      }                                                                         \
 -    else                                                                \
 -      {                                                                         \
 -      OUTPUT = *(BYTE_POS_ADDR (BYTEIDX));                              \
 -      BYTEIDX++;                                                        \
 -      }                                                                         \
 -  }                                                                     \
 -else
 -
 -/* Return the length of the multi-byte form at string STR of length LEN.  */
 -
 -#define MULTIBYTE_FORM_LENGTH(str, len)                       \
 -  (BYTES_BY_CHAR_HEAD (*(unsigned char *)(str)) == 1  \
 -   ? 1                                                        \
 -   : multibyte_form_length (str, len))
 -
 -/* If P is before LIMIT, advance P to the next character boundary.  It
 -   assumes that P is already at a character boundary of the sane
 -   mulitbyte form whose end address is LIMIT.  */
 -
 -#define NEXT_CHAR_BOUNDARY(p, limit)  \
 -  do {                                        \
 -    if ((p) < (limit))                        \
 -      (p) += BYTES_BY_CHAR_HEAD (*(p));       \
 +/* Check if X is a valid charset symbol.  If valid, set ID to the id
 +   number of the charset.  Otherwise, signal an error. */
 +#define CHECK_CHARSET_GET_ID(x, id)                                   \
 +  do {                                                                        \
 +    int idx;                                                          \
 +                                                                      \
 +    if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0)   \
 +      x = wrong_type_argument (Qcharsetp, (x));                               \
 +    id = XINT (AREF (HASH_VALUE (XHASH_TABLE (Vcharset_hash_table), idx), \
 +                   charset_id));                                      \
    } while (0)
  
  
 -/* If P is after LIMIT, advance P to the previous character boundary.  */
 -
 -#define PREV_CHAR_BOUNDARY(p, limit)                                  \
 +/* Check if X is a valid charset symbol.  If valid, set ATTR to the
 +   attr vector of the charset.  Otherwise, signal an error. */
 +#define CHECK_CHARSET_GET_ATTR(x, attr)                               \
    do {                                                                        \
 -    if ((p) > (limit))                                                        \
 -      {                                                                       \
 -      const unsigned char *p0 = (p);                                  \
 -      const unsigned char *p_limit = max (limit, p0 - MAX_MULTIBYTE_LENGTH);\
 -      do {                                                            \
 -        p0--;                                                         \
 -      } while (p0 >= p_limit && ! CHAR_HEAD_P (*p0));                 \
 -      /* If BBCH(*p0) > p-p0, it means we were not on a boundary.  */ \
 -      (p) = (BYTES_BY_CHAR_HEAD (*p0) >= (p) - p0) ? p0 : (p) - 1;    \
 -      }                                                                       \
 +    if (!SYMBOLP (x) || NILP (attr = CHARSET_SYMBOL_ATTRIBUTES (x)))  \
 +      x = wrong_type_argument (Qcharsetp, (x));                               \
    } while (0)
  
 -#define AT_CHAR_BOUNDARY_P(result, p, limit)  \
 +
 +#define CHECK_CHARSET_GET_CHARSET(x, charset) \
    do {                                                \
 -    if (CHAR_HEAD_P (*(p)) || (p) <= limit)   \
 -      /* Optimization for the common case. */ \
 -      (result) = 1;                           \
 -    else                                      \
 -      {                                               \
 -      const unsigned char *p_aux = (p)+1;     \
 -      PREV_CHAR_BOUNDARY (p_aux, limit);      \
 -      (result) = (p_aux == (p));              \
 -      }                                               \
 -} while (0)
 -
 -#ifdef emacs
 -
 -/* Increase the buffer byte position POS_BYTE of the current buffer to
 -   the next character boundary.  This macro relies on the fact that
 -   *GPT_ADDR and *Z_ADDR are always accessible and the values are
 -   '\0'.  No range checking of POS.  */
 -
 -#ifdef BYTE_COMBINING_DEBUG
 -
 -#define INC_POS(pos_byte)                             \
 -  do {                                                        \
 -    unsigned char *p = BYTE_POS_ADDR (pos_byte);      \
 -    if (BASE_LEADING_CODE_P (*p))                     \
 -      {                                                       \
 -      int len, bytes;                                 \
 -      len = Z_BYTE - pos_byte;                        \
 -      PARSE_MULTIBYTE_SEQ (p, len, bytes);            \
 -      pos_byte += bytes;                              \
 -      }                                                       \
 -    else                                              \
 -      pos_byte++;                                     \
 +    int id;                                   \
 +    CHECK_CHARSET_GET_ID (x, id);             \
 +    charset = CHARSET_FROM_ID (id);           \
    } while (0)
  
 -#else  /* not BYTE_COMBINING_DEBUG */
  
 -#define INC_POS(pos_byte)                             \
 -  do {                                                        \
 -    unsigned char *p = BYTE_POS_ADDR (pos_byte);      \
 -    pos_byte += BYTES_BY_CHAR_HEAD (*p);              \
 -  } while (0)
 +/* Lookup Vcharset_order_list and return the first charset that
 +   contains the character C.  */
 +#define CHAR_CHARSET(c)                               \
 +  ((c) < 0x80 ? CHARSET_FROM_ID (charset_ascii)       \
 +   : char_charset ((c), Qnil, NULL))
  
 -#endif /* not BYTE_COMBINING_DEBUG */
 +#if 0
 +/* Char-table of charset-sets.  Each element is a bool vector indexed
 +   by a charset ID.  */
 +extern Lisp_Object Vchar_charset_set;
  
 -/* Decrease the buffer byte position POS_BYTE of the current buffer to
 -   the previous character boundary.  No range checking of POS.  */
 -#define DEC_POS(pos_byte)                                             \
 -  do {                                                                        \
 -    unsigned char *p, *p_min;                                         \
 -                                                                      \
 -    pos_byte--;                                                               \
 -    if (pos_byte < GPT_BYTE)                                          \
 -      p = BEG_ADDR + pos_byte - BEG_BYTE, p_min = BEG_ADDR;           \
 -    else                                                              \
 -      p = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE, p_min = GAP_END_ADDR;\
 -    if (p > p_min && !CHAR_HEAD_P (*p))                                       \
 -      {                                                                       \
 -      unsigned char *pend = p--;                                      \
 -      int len, bytes;                                                 \
 -        if (p_min < p - MAX_MULTIBYTE_LENGTH)                         \
 -          p_min = p - MAX_MULTIBYTE_LENGTH;                           \
 -      while (p > p_min && !CHAR_HEAD_P (*p)) p--;                     \
 -      len = pend + 1 - p;                                             \
 -      PARSE_MULTIBYTE_SEQ (p, len, bytes);                            \
 -      if (bytes == len)                                               \
 -        pos_byte -= len - 1;                                          \
 -      }                                                                       \
 -  } while (0)
 +/* Charset-bag of character C.  */
 +#define CHAR_CHARSET_SET(c) \
 +  CHAR_TABLE_REF (Vchar_charset_set, c)
  
 -/* Increment both CHARPOS and BYTEPOS, each in the appropriate way.  */
 +/* Check if two characters C1 and C2 belong to the same charset.  */
 +#define SAME_CHARSET_P(c1, c2)        \
 +  intersection_p (CHAR_CHARSET_SET (c1), CHAR_CHARSET_SET (c2))
 +
 +#endif
 +
 +
 +/* Return a character correponding to the code-point CODE of CHARSET.
 +   Try some optimization before calling decode_char.  */
 +
 +#define DECODE_CHAR(charset, code)                                    \
 +  ((ASCII_BYTE_P (code) && (charset)->ascii_compatible_p)             \
 +   ? (code)                                                           \
 +   : ((code) < (charset)->min_code || (code) > (charset)->max_code)   \
 +   ? -1                                                                       \
 +   : (charset)->unified_p                                             \
 +   ? decode_char ((charset), (code))                                  \
 +   : (charset)->method == CHARSET_METHOD_OFFSET                               \
 +   ? ((charset)->code_linear_p                                                \
 +      ? (code) - (charset)->min_code + (charset)->code_offset         \
 +      : decode_char ((charset), (code)))                              \
 +   : (charset)->method == CHARSET_METHOD_MAP                          \
 +   ? ((charset)->code_linear_p                                                \
 +      ? XINT (AREF (CHARSET_DECODER (charset),                                \
 +                      (code) - (charset)->min_code))                  \
 +      : decode_char ((charset), (code)))                              \
 +   : decode_char ((charset), (code)))
 +
 +
 +/* If CHARSET is a simple offset base charset, return it's offset,
 +   otherwise return -1.  */
 +#define CHARSET_OFFSET(charset)                               \
 +  (((charset)->method == CHARSET_METHOD_OFFSET                \
 +    && (charset)->code_linear_p                               \
 +    && ! (charset)->unified_p)                                \
 +   ? (charset)->code_offset - (charset)->min_code     \
 +   : -1)
 +
 +extern Lisp_Object charset_work;
 +
 +/* Return a code point of CHAR in CHARSET.
 +   Try some optimization before calling encode_char.  */
 +
 +#define ENCODE_CHAR(charset, c)                                                \
 +  ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p)                         \
 +   ? (c)                                                               \
 +   : ((charset)->unified_p                                             \
 +      || (charset)->method == CHARSET_METHOD_SUBSET                    \
 +      || (charset)->method == CHARSET_METHOD_SUPERSET)                         \
 +   ? encode_char ((charset), (c))                                      \
 +   : ((c) < (charset)->min_char || (c) > (charset)->max_char)          \
 +   ? (charset)->invalid_code                                           \
 +   : (charset)->method == CHARSET_METHOD_OFFSET                                \
 +   ? ((charset)->code_linear_p                                                 \
 +      ? (c) - (charset)->code_offset + (charset)->min_code             \
 +      : encode_char ((charset), (c)))                                  \
 +   : (charset)->method == CHARSET_METHOD_MAP                           \
 +   ? ((charset)->compact_codes_p                                       \
 +      ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), (c)), \
 +       (NILP (charset_work)                                            \
 +        ? (charset)->invalid_code                                      \
 +        : XFASTINT (charset_work)))                                    \
 +      : encode_char ((charset), (c)))                                  \
 +   : encode_char ((charset), (c)))
 +
 +
 +/* Set to 1 when a charset map is loaded to warn that a buffer text
 +   and a string data may be relocated.  */
 +extern int charset_map_loaded;
 +
 +
 +/* Set CHARSET to the charset highest priority of C, CODE to the
 +   code-point of C in CHARSET.  */
 +#define SPLIT_CHAR(c, charset, code)  \
 +  ((charset) = char_charset ((c), Qnil, &(code)))
 +
 +
 +#define ISO_MAX_DIMENSION 3
 +#define ISO_MAX_CHARS 2
 +#define ISO_MAX_FINAL 0x80    /* only 0x30..0xFF are used */
  
 -#define INC_BOTH(charpos, bytepos)                            \
 -do                                                            \
 -  {                                                           \
 -    (charpos)++;                                              \
 -    if (NILP (current_buffer->enable_multibyte_characters))   \
 -      (bytepos)++;                                            \
 -    else                                                      \
 -      INC_POS ((bytepos));                                    \
 -  }                                                           \
 -while (0)
 -
 -/* Decrement both CHARPOS and BYTEPOS, each in the appropriate way.  */
 -
 -#define DEC_BOTH(charpos, bytepos)                            \
 -do                                                            \
 -  {                                                           \
 -    (charpos)--;                                              \
 -    if (NILP (current_buffer->enable_multibyte_characters))   \
 -      (bytepos)--;                                            \
 -    else                                                      \
 -      DEC_POS ((bytepos));                                    \
 -  }                                                           \
 -while (0)
 +/* Mapping table from ISO2022's charset (specified by DIMENSION,
 +   CHARS, and FINAL_CHAR) to Emacs' charset ID.  Should be accessed by
 +   macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR).  */
 +extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
  
 -/* Increase the buffer byte position POS_BYTE of the current buffer to
 -   the next character boundary.  This macro relies on the fact that
 -   *GPT_ADDR and *Z_ADDR are always accessible and the values are
 -   '\0'.  No range checking of POS_BYTE.  */
 +/* A charset of type iso2022 who has DIMENSION, CHARS, and FINAL
 +   (final character).  */
 +#define ISO_CHARSET_TABLE(dimension, chars_96, final) \
 +  iso_charset_table[(dimension) - 1][(chars_96)][(final)]
  
- /* Nonzero iff the charset who has FAST_MAP may contain C.  */
 -#ifdef BYTE_COMBINING_DEBUG
++/* Nonzero if the charset who has FAST_MAP may contain C.  */
 +#define CHARSET_FAST_MAP_REF(c, fast_map)             \
 +  ((c) < 0x10000                                      \
 +   ? fast_map[(c) >> 10] & (1 << (((c) >> 7) & 7))    \
 +   : fast_map[((c) >> 15) + 62] & (1 << (((c) >> 12) & 7)))
  
 -#define BUF_INC_POS(buf, pos_byte)                            \
 +#define CHARSET_FAST_MAP_SET(c, fast_map)                     \
    do {                                                                \
 -    unsigned char *p = BUF_BYTE_ADDRESS (buf, pos_byte);      \
 -    if (BASE_LEADING_CODE_P (*p))                             \
 -      {                                                               \
 -      int len, bytes;                                         \
 -      len = BUF_Z_BYTE (buf) - pos_byte;                      \
 -      PARSE_MULTIBYTE_SEQ (p, len, bytes);                    \
 -      pos_byte += bytes;                                      \
 -      }                                                               \
 +    if ((c) < 0x10000)                                                \
 +      (fast_map)[(c) >> 10] |= 1 << (((c) >> 7) & 7);         \
      else                                                      \
 -      pos_byte++;                                             \
 +      (fast_map)[((c) >> 15) + 62] |= 1 << (((c) >> 12) & 7); \
    } while (0)
  
 -#else  /* not BYTE_COMBINING_DEBUG */
  
 -#define BUF_INC_POS(buf, pos_byte)                            \
 -  do {                                                                \
 -    unsigned char *p = BUF_BYTE_ADDRESS (buf, pos_byte);      \
 -    pos_byte += BYTES_BY_CHAR_HEAD (*p);                      \
 -  } while (0)
  
- /* 1 iff CHARSET may contain the character C.  */
 -#endif /* not BYTE_COMBINING_DEBUG */
++/* 1 if CHARSET may contain the character C.  */
 +#define CHAR_CHARSET_P(c, charset)                                     \
 +  ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p)                         \
 +   || ((CHARSET_UNIFIED_P (charset)                                    \
 +      || (charset)->method == CHARSET_METHOD_SUBSET                    \
 +      || (charset)->method == CHARSET_METHOD_SUPERSET)                 \
 +       ? encode_char ((charset), (c)) != (charset)->invalid_code       \
 +       : (CHARSET_FAST_MAP_REF ((c), (charset)->fast_map)              \
 +        && ((charset)->method == CHARSET_METHOD_OFFSET                 \
 +            ? (c) >= (charset)->min_char && (c) <= (charset)->max_char \
 +            : ((charset)->method == CHARSET_METHOD_MAP                 \
 +               && (charset)->compact_codes_p)                          \
 +            ? ! NILP (CHAR_TABLE_REF (CHARSET_ENCODER (charset), (c))) \
 +            : encode_char ((charset), (c)) != (charset)->invalid_code))))
  
 -/* Decrease the buffer byte position POS_BYTE of the current buffer to
 -   the previous character boundary.  No range checking of POS_BYTE.  */
 -#define BUF_DEC_POS(buf, pos_byte)                                    \
 -  do {                                                                        \
 -    unsigned char *p, *p_min;                                         \
 -    pos_byte--;                                                               \
 -    if (pos_byte < BUF_GPT_BYTE (buf))                                        \
 -      {                                                                       \
 -      p = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE;                   \
 -      p_min = BUF_BEG_ADDR (buf);                                     \
 -      }                                                                       \
 -    else                                                              \
 -      {                                                                       \
 -      p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\
 -      p_min = BUF_GAP_END_ADDR (buf);                                 \
 -      }                                                                       \
 -    if (p > p_min && !CHAR_HEAD_P (*p))                                       \
 -      {                                                                       \
 -      unsigned char *pend = p--;                                      \
 -      int len, bytes;                                                 \
 -        if (p_min < p - MAX_MULTIBYTE_LENGTH)                         \
 -          p_min = p - MAX_MULTIBYTE_LENGTH;                           \
 -      while (p > p_min && !CHAR_HEAD_P (*p)) p--;                     \
 -      len = pend + 1 - p;                                             \
 -      PARSE_MULTIBYTE_SEQ (p, len, bytes);                            \
 -      if (bytes == len)                                               \
 -        pos_byte -= len - 1;                                          \
 -      }                                                                       \
 -  } while (0)
 +\f
 +/* Special macros for emacs-mule encoding.  */
  
 -#endif /* emacs */
 -
 -/* This is the maximum byte length of multi-byte sequence.  */
 -#define MAX_MULTIBYTE_LENGTH 4
 -
 -extern void invalid_character P_ ((int)) NO_RETURN;
 -
 -extern int translate_char P_ ((Lisp_Object, int, int, int, int));
 -extern int split_string P_ ((const unsigned char *, int, int *,
 -                                     unsigned char *, unsigned char *));
 -extern int char_to_string P_ ((int, unsigned char *));
 -extern int char_to_string_1 P_ ((int, unsigned char *));
 -extern int string_to_char P_ ((const unsigned char *, int, int *));
 -extern int char_printable_p P_ ((int c));
 -extern int multibyte_form_length P_ ((const unsigned char *, int));
 -extern void parse_str_as_multibyte P_ ((const unsigned char *, int, int *,
 -                                      int *));
 -extern int str_as_multibyte P_ ((unsigned char *, int, int, int *));
 -extern int parse_str_to_multibyte P_ ((unsigned char *, int));
 -extern int str_to_multibyte P_ ((unsigned char *, int, int));
 -extern int str_as_unibyte P_ ((unsigned char *, int));
 -extern int get_charset_id P_ ((Lisp_Object));
 -extern int find_charset_in_text P_ ((const unsigned char *, int, int, int *,
 -                                  Lisp_Object));
 -extern int strwidth P_ ((unsigned char *, int));
 -extern int c_string_width P_ ((const unsigned char *, int, int, int *, int *));
 -extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *));
 -extern int char_bytes P_ ((int));
 -extern int char_valid_p P_ ((int, int));
 -
 -EXFUN (Funibyte_char_to_multibyte, 1);
 -
 -extern Lisp_Object Vtranslation_table_vector;
 -
 -/* Return a translation table of id number ID.  */
 -#define GET_TRANSLATION_TABLE(id) \
 -  (XCDR(XVECTOR(Vtranslation_table_vector)->contents[(id)]))
 -
 -/* A char-table for characters which may invoke auto-filling.  */
 -extern Lisp_Object Vauto_fill_chars;
 -
 -/* Copy LEN bytes from FROM to TO.  This macro should be used only
 -   when a caller knows that LEN is short and the obvious copy loop is
 -   faster than calling bcopy which has some overhead.  Copying a
 -   multibyte sequence of a multibyte character is the typical case.  */
 -
 -#define BCOPY_SHORT(from, to, len)            \
 -  do {                                                \
 -    int i = len;                              \
 -    const unsigned char *from_p = from;               \
 -    unsigned char *to_p = to;                 \
 -    while (i--) *to_p++ = *from_p++;          \
 -  } while (0)
 +/* Leading-code followed by extended leading-code.    DIMENSION/COLUMN */
 +#define EMACS_MULE_LEADING_CODE_PRIVATE_11    0x9A /* 1/1 */
 +#define EMACS_MULE_LEADING_CODE_PRIVATE_12    0x9B /* 1/2 */
 +#define EMACS_MULE_LEADING_CODE_PRIVATE_21    0x9C /* 2/2 */
 +#define EMACS_MULE_LEADING_CODE_PRIVATE_22    0x9D /* 2/2 */
 +
 +extern struct charset *emacs_mule_charset[256];
 +
 +\f
 +
 +extern Lisp_Object Qcharsetp;
 +
 +extern Lisp_Object Qascii, Qunicode;
 +extern int charset_ascii, charset_eight_bit;
 +extern int charset_iso_8859_1;
 +extern int charset_unicode;
 +extern int charset_jisx0201_roman;
 +extern int charset_jisx0208_1978;
 +extern int charset_jisx0208;
 +
 +extern int charset_unibyte;
 +
 +extern struct charset *char_charset P_ ((int, Lisp_Object, unsigned *));
 +extern Lisp_Object charset_attributes P_ ((int));
 +
 +extern int decode_char P_ ((struct charset *, unsigned));
 +extern unsigned encode_char P_ ((struct charset *, int));
 +extern int string_xstring_p P_ ((Lisp_Object));
 +
 +extern void map_charset_chars P_ ((void (*) (Lisp_Object, Lisp_Object),
 +                                 Lisp_Object, Lisp_Object,
 +                                 struct charset *, unsigned, unsigned));
 +
 +EXFUN (Funify_charset, 3);
  
  #endif /* EMACS_CHARSET_H */
  
diff --cc src/coding.h
index d4b159c3dfaa75c367977196f0d935c25879ef42,2efcd4f47e2a740f8605c06df517572e6602b907..134402f3256314eea5f2066fb74d4116da06fb9c
@@@ -29,238 -26,203 +29,238 @@@ Boston, MA 02110-1301, USA.  *
  #ifndef EMACS_CODING_H
  #define EMACS_CODING_H
  
 -#include "ccl.h"
 +/* Index to arguments of Fdefine_coding_system_internal.  */
  
 -/*** EMACS' INTERNAL FORMAT (emacs-mule) section ***/
 +enum define_coding_system_arg_index
 +  {
 +    coding_arg_name,
 +    coding_arg_mnemonic,
 +    coding_arg_coding_type,
 +    coding_arg_charset_list,
 +    coding_arg_ascii_compatible_p,
 +    coding_arg_decode_translation_table,
 +    coding_arg_encode_translation_table,
 +    coding_arg_post_read_conversion,
 +    coding_arg_pre_write_conversion,
 +    coding_arg_default_char,
 +    coding_arg_for_unibyte,
 +    coding_arg_plist,
 +    coding_arg_eol_type,
 +    coding_arg_max
 +  };
  
 -/* All code (1-byte) of Emacs' internal format is classified into one
 -   of the followings.  See also `charset.h'.  */
 -enum emacs_code_class_type
 +enum define_coding_iso2022_arg_index
    {
 -    EMACS_control_code,               /* Control codes in the range
 -                                 0x00..0x1F and 0x7F except for the
 -                                 following two codes.  */
 -    EMACS_linefeed_code,      /* 0x0A (linefeed) to denote
 -                                 end-of-line.  */
 -    EMACS_carriage_return_code,       /* 0x0D (carriage-return) to be used
 -                                 in selective display mode.  */
 -    EMACS_ascii_code,         /* ASCII characters.  */
 -    EMACS_leading_code_2,     /* Base leading code of official
 -                                 TYPE9N character.  */
 -    EMACS_leading_code_3,     /* Base leading code of private TYPE9N
 -                                 or official TYPE9Nx9N character.  */
 -    EMACS_leading_code_4,     /* Base leading code of private
 -                                 TYPE9Nx9N character.  */
 -    EMACS_invalid_code                /* Invalid code, i.e. a base leading
 -                                 code not yet assigned to any
 -                                 charset, or a code of the range
 -                                 0xA0..0xFF.  */
 +    coding_arg_iso2022_initial = coding_arg_max,
 +    coding_arg_iso2022_reg_usage,
 +    coding_arg_iso2022_request,
 +    coding_arg_iso2022_flags,
 +    coding_arg_iso2022_max
    };
  
 -extern enum emacs_code_class_type emacs_code_class[256];
 -
 -/*** ISO2022 section ***/
 -
 -/* Macros to define code of control characters for ISO2022's functions.  */
 -                      /* code */      /* function */
 -#define ISO_CODE_LF   0x0A            /* line-feed */
 -#define ISO_CODE_CR   0x0D            /* carriage-return */
 -#define ISO_CODE_SO   0x0E            /* shift-out */
 -#define ISO_CODE_SI   0x0F            /* shift-in */
 -#define ISO_CODE_SS2_7        0x19            /* single-shift-2 for 7-bit code */
 -#define ISO_CODE_ESC  0x1B            /* escape */
 -#define ISO_CODE_SS2  0x8E            /* single-shift-2 */
 -#define ISO_CODE_SS3  0x8F            /* single-shift-3 */
 -#define ISO_CODE_CSI  0x9B            /* control-sequence-introduce */
 -
 -/* All code (1-byte) of ISO2022 is classified into one of the
 -   followings.  */
 -enum iso_code_class_type
 +enum define_coding_utf16_arg_index
    {
 -    ISO_control_0,            /* Control codes in the range
 -                                 0x00..0x1F and 0x7F, except for the
 -                                 following 5 codes.  */
 -    ISO_carriage_return,      /* ISO_CODE_CR (0x0D) */
 -    ISO_shift_out,            /* ISO_CODE_SO (0x0E) */
 -    ISO_shift_in,             /* ISO_CODE_SI (0x0F) */
 -    ISO_single_shift_2_7,     /* ISO_CODE_SS2_7 (0x19) */
 -    ISO_escape,                       /* ISO_CODE_SO (0x1B) */
 -    ISO_control_1,            /* Control codes in the range
 -                                 0x80..0x9F, except for the
 -                                 following 3 codes.  */
 -    ISO_single_shift_2,               /* ISO_CODE_SS2 (0x8E) */
 -    ISO_single_shift_3,               /* ISO_CODE_SS3 (0x8F) */
 -    ISO_control_sequence_introducer, /* ISO_CODE_CSI (0x9B) */
 -    ISO_0x20_or_0x7F,         /* Codes of the values 0x20 or 0x7F.  */
 -    ISO_graphic_plane_0,      /* Graphic codes in the range 0x21..0x7E.  */
 -    ISO_0xA0_or_0xFF,         /* Codes of the values 0xA0 or 0xFF.  */
 -    ISO_graphic_plane_1               /* Graphic codes in the range 0xA1..0xFE.  */
 +    coding_arg_utf16_bom = coding_arg_max,
 +    coding_arg_utf16_endian,
 +    coding_arg_utf16_max
    };
  
 -/** The macros CODING_FLAG_ISO_XXX defines a flag bit of the `flags'
 -  element in the structure `coding_system'.  This information is used
 -  while encoding a text to ISO2022.  **/
 +enum define_coding_ccl_arg_index
 +  {
 +    coding_arg_ccl_decoder = coding_arg_max,
 +    coding_arg_ccl_encoder,
 +    coding_arg_ccl_valids,
 +    coding_arg_ccl_max
 +  };
  
 -/* If set, produce short-form designation sequence (e.g. ESC $ A)
 -   instead of long-form sequence (e.g. ESC $ ( A).  */
 -#define CODING_FLAG_ISO_SHORT_FORM    0x0001
 +/* Hash table for all coding systems.  Keys are coding system symbols
 +   and values are spec vectors of the corresponding coding system.  A
 +   spec vector has the form [ ATTRS ALIASES EOL-TYPE ].  ATTRS is a
 +   vector of attribute of the coding system.  ALIASES is a list of
 +   aliases (symbols) of the coding system.  EOL-TYPE is `unix', `dos',
 +   `mac' or a vector of coding systems (symbols).  */
  
 -/* If set, reset graphic planes and registers at end-of-line to the
 -   initial state.  */
 -#define CODING_FLAG_ISO_RESET_AT_EOL  0x0002
 +extern Lisp_Object Vcoding_system_hash_table;
  
 -/* If set, reset graphic planes and registers before any control
 -   characters to the initial state.  */
 -#define CODING_FLAG_ISO_RESET_AT_CNTL 0x0004
  
 -/* If set, encode by 7-bit environment.  */
 -#define CODING_FLAG_ISO_SEVEN_BITS    0x0008
 +/* Enumeration of coding system type.  */
  
 -/* If set, use locking-shift function.  */
 -#define CODING_FLAG_ISO_LOCKING_SHIFT 0x0010
 +enum coding_system_type
 +  {
 +    coding_type_charset,
 +    coding_type_utf_8,
 +    coding_type_utf_16,
 +    coding_type_iso_2022,
 +    coding_type_emacs_mule,
 +    coding_type_sjis,
 +    coding_type_ccl,
 +    coding_type_raw_text,
 +    coding_type_undecided,
 +    coding_type_max
 +  };
  
 -/* If set, use single-shift function.  Overwrite
 -   CODING_FLAG_ISO_LOCKING_SHIFT.  */
 -#define CODING_FLAG_ISO_SINGLE_SHIFT  0x0020
  
 -/* If set, designate JISX0201-Roman instead of ASCII.  */
 -#define CODING_FLAG_ISO_USE_ROMAN     0x0040
 +/* Enumeration of end-of-line format type.  */
  
 -/* If set, designate JISX0208-1978 instead of JISX0208-1983.  */
 -#define CODING_FLAG_ISO_USE_OLDJIS    0x0080
 +enum end_of_line_type
 +  {
 +    eol_lf,           /* Line-feed only, same as Emacs' internal
 +                         format.  */
 +    eol_crlf,         /* Sequence of carriage-return and
 +                         line-feed.  */
 +    eol_cr,           /* Carriage-return only.  */
 +    eol_any,          /* Accept any of above.  Produce line-feed
 +                         only.  */
 +    eol_undecided,    /* This value is used to denote that the
 +                         eol-type is not yet undecided.  */
 +    eol_type_max
 +  };
  
 -/* If set, do not produce ISO6429's direction specifying sequence.  */
 -#define CODING_FLAG_ISO_NO_DIRECTION  0x0100
 +/* Enumeration of index to an attribute vector of a coding system.  */
  
 -/* If set, assume designation states are reset at beginning of line on
 -   output.  */
 -#define CODING_FLAG_ISO_INIT_AT_BOL   0x0200
 +enum coding_attr_index
 +  {
 +    coding_attr_base_name,
 +    coding_attr_docstring,
 +    coding_attr_mnemonic,
 +    coding_attr_type,
 +    coding_attr_charset_list,
 +    coding_attr_ascii_compat,
 +    coding_attr_decode_tbl,
 +    coding_attr_encode_tbl,
 +    coding_attr_trans_tbl,
 +    coding_attr_post_read,
 +    coding_attr_pre_write,
 +    coding_attr_default_char,
 +    coding_attr_for_unibyte,
 +    coding_attr_plist,
 +
 +    coding_attr_category,
 +    coding_attr_safe_charsets,
 +
 +    /* The followings are extra attributes for each type.  */
 +    coding_attr_charset_valids,
 +
 +    coding_attr_ccl_decoder,
 +    coding_attr_ccl_encoder,
 +    coding_attr_ccl_valids,
 +
 +    coding_attr_iso_initial,
 +    coding_attr_iso_usage,
 +    coding_attr_iso_request,
 +    coding_attr_iso_flags,
 +
 +    coding_attr_utf_16_bom,
 +    coding_attr_utf_16_endian,
 +
 +    coding_attr_emacs_mule_full,
 +
 +    coding_attr_last_index
 +  };
  
 -/* If set, designation sequence should be placed at beginning of line
 -   on output.  */
 -#define CODING_FLAG_ISO_DESIGNATE_AT_BOL 0x0400
  
 -/* If set, do not encode unsafe characters on output.  */
 -#define CODING_FLAG_ISO_SAFE          0x0800
 +/* Macros to access an element of an attribute vector.  */
  
 -/* If set, extra latin codes (128..159) are accepted as a valid code
 -   on input.  */
 -#define CODING_FLAG_ISO_LATIN_EXTRA   0x1000
 +#define CODING_ATTR_BASE_NAME(attrs)  AREF (attrs, coding_attr_base_name)
 +#define CODING_ATTR_TYPE(attrs)               AREF (attrs, coding_attr_type)
 +#define CODING_ATTR_CHARSET_LIST(attrs)       AREF (attrs, coding_attr_charset_list)
 +#define CODING_ATTR_MNEMONIC(attrs)   AREF (attrs, coding_attr_mnemonic)
 +#define CODING_ATTR_DOCSTRING(attrs)  AREF (attrs, coding_attr_docstring)
 +#define CODING_ATTR_ASCII_COMPAT(attrs)       AREF (attrs, coding_attr_ascii_compat)
 +#define CODING_ATTR_DECODE_TBL(attrs) AREF (attrs, coding_attr_decode_tbl)
 +#define CODING_ATTR_ENCODE_TBL(attrs) AREF (attrs, coding_attr_encode_tbl)
 +#define CODING_ATTR_TRANS_TBL(attrs)  AREF (attrs, coding_attr_trans_tbl)
 +#define CODING_ATTR_POST_READ(attrs)  AREF (attrs, coding_attr_post_read)
 +#define CODING_ATTR_PRE_WRITE(attrs)  AREF (attrs, coding_attr_pre_write)
 +#define CODING_ATTR_DEFAULT_CHAR(attrs)       AREF (attrs, coding_attr_default_char)
 +#define CODING_ATTR_FOR_UNIBYTE(attrs)        AREF (attrs, coding_attr_for_unibyte)
 +#define CODING_ATTR_FLUSHING(attrs)   AREF (attrs, coding_attr_flushing)
 +#define CODING_ATTR_PLIST(attrs)      AREF (attrs, coding_attr_plist)
 +#define CODING_ATTR_CATEGORY(attrs)   AREF (attrs, coding_attr_category)
 +#define CODING_ATTR_SAFE_CHARSETS(attrs)AREF (attrs, coding_attr_safe_charsets)
  
 -/* If set, use designation escape sequence.  */
 -#define CODING_FLAG_ISO_DESIGNATION   0x10000
  
 -/* A character to be produced on output if encoding of the original
 -   character is inhibitted by CODING_MODE_INHIBIT_UNENCODABLE_CHAR.
 -   It must be an ASCII character.  */
 -#define CODING_REPLACEMENT_CHARACTER '?'
 +/* Return the name of a coding system specified by ID.  */
 +#define CODING_ID_NAME(id) \
 +  (HASH_KEY (XHASH_TABLE (Vcoding_system_hash_table), id))
  
 -/* Structure of the field `spec.iso2022' in the structure `coding_system'.  */
 -struct iso2022_spec
 -{
 -  /* The current graphic register invoked to each graphic plane.  */
 -  int current_invocation[2];
 +/* Return the attribute vector of a coding system specified by ID.  */
  
 -  /* The current charset designated to each graphic register.  */
 -  int current_designation[4];
 +#define CODING_ID_ATTRS(id)   \
 +  (AREF (HASH_VALUE (XHASH_TABLE (Vcoding_system_hash_table), id), 0))
  
 -  /* A charset initially designated to each graphic register.  */
 -  int initial_designation[4];
 +/* Return the list of aliases of a coding system specified by ID.  */
  
 -  /* If not -1, it is a graphic register specified in an invalid
 -     designation sequence.  */
 -  int last_invalid_designation_register;
 +#define CODING_ID_ALIASES(id) \
 +  (AREF (HASH_VALUE (XHASH_TABLE (Vcoding_system_hash_table), id), 1))
  
 -  /* A graphic register to which each charset should be designated.  */
 -  unsigned char requested_designation[MAX_CHARSET + 1];
 +/* Return the eol-type of a coding system specified by ID.  */
  
 -  /* A revision number to be specified for each charset on encoding.
 -     The value 255 means no revision number for the corresponding
 -     charset.  */
 -  unsigned char charset_revision_number[MAX_CHARSET + 1];
 +#define CODING_ID_EOL_TYPE(id)        \
 +  (AREF (HASH_VALUE (XHASH_TABLE (Vcoding_system_hash_table), id), 2))
  
 -  /* Set to 1 temporarily only when graphic register 2 or 3 is invoked
 -     by single-shift while encoding.  */
 -  int single_shifting;
  
 -  /* Set to 1 temporarily only when processing at beginning of line.  */
 -  int bol;
 -};
 +/* Return the spec vector of CODING_SYSTEM_SYMBOL.  */
 +
 +#define CODING_SYSTEM_SPEC(coding_system_symbol)      \
 +  (Fgethash (coding_system_symbol, Vcoding_system_hash_table, Qnil))
 +
 +
 +/* Return the ID of CODING_SYSTEM_SYMBOL.  */
 +
 +#define CODING_SYSTEM_ID(coding_system_symbol)                        \
 +  hash_lookup (XHASH_TABLE (Vcoding_system_hash_table),               \
 +             coding_system_symbol, NULL)
 +
- /* Return 1 iff CODING_SYSTEM_SYMBOL is a coding system.  */
++/* Return 1 if CODING_SYSTEM_SYMBOL is a coding system.  */
 +
 +#define CODING_SYSTEM_P(coding_system_symbol)         \
 +  (CODING_SYSTEM_ID (coding_system_symbol) >= 0               \
 +   || (! NILP (coding_system_symbol)                  \
 +       && ! NILP (Fcoding_system_p (coding_system_symbol))))
 +
 +/* Check if X is a coding system or not.  */
 +
 +#define CHECK_CODING_SYSTEM(x)                                \
 +  do {                                                        \
 +    if (CODING_SYSTEM_ID (x) < 0                      \
 +      && NILP (Fcheck_coding_system (x)))             \
 +      wrong_type_argument (Qcoding_system_p, (x));    \
 +  } while (0)
 +
 +
 +/* Check if X is a coding system or not.  If it is, set SEPC to the
 +   spec vector of the coding system.  */
 +
 +#define CHECK_CODING_SYSTEM_GET_SPEC(x, spec)         \
 +  do {                                                        \
 +    spec = CODING_SYSTEM_SPEC (x);                    \
 +    if (NILP (spec))                                  \
 +      {                                                       \
 +      Fcheck_coding_system (x);                       \
 +      spec = CODING_SYSTEM_SPEC (x);                  \
 +      }                                                       \
 +    if (NILP (spec))                                  \
 +      x = wrong_type_argument (Qcoding_system_p, (x));        \
 +  } while (0)
 +
 +
 +/* Check if X is a coding system or not.  If it is, set ID to the
 +   ID of the coding system.  */
 +
 +#define CHECK_CODING_SYSTEM_GET_ID(x, id)                     \
 +  do                                                          \
 +    {                                                         \
 +      id = CODING_SYSTEM_ID (x);                              \
 +      if (id < 0)                                             \
 +      {                                                       \
 +        Fcheck_coding_system (x);                             \
 +        id = CODING_SYSTEM_ID (x);                            \
 +      }                                                       \
 +      if (id < 0)                                             \
 +      x = wrong_type_argument (Qcoding_system_p, (x));        \
 +    } while (0)
  
 -/* Macros to access each field in the structure `spec.iso2022'.  */
 -#define CODING_SPEC_ISO_INVOCATION(coding, plane) \
 -  (coding)->spec.iso2022.current_invocation[plane]
 -#define CODING_SPEC_ISO_DESIGNATION(coding, reg) \
 -  (coding)->spec.iso2022.current_designation[reg]
 -#define CODING_SPEC_ISO_INITIAL_DESIGNATION(coding, reg) \
 -  (coding)->spec.iso2022.initial_designation[reg]
 -#define CODING_SPEC_ISO_REQUESTED_DESIGNATION(coding, charset) \
 -  (coding)->spec.iso2022.requested_designation[charset]
 -#define CODING_SPEC_ISO_REVISION_NUMBER(coding, charset) \
 -  (coding)->spec.iso2022.charset_revision_number[charset]
 -#define CODING_SPEC_ISO_SINGLE_SHIFTING(coding) \
 -  (coding)->spec.iso2022.single_shifting
 -#define CODING_SPEC_ISO_BOL(coding) \
 -  (coding)->spec.iso2022.bol
 -
 -/* A value which may appear in
 -   coding->spec.iso2022.requested_designation indicating that the
 -   corresponding charset does not request any graphic register to be
 -   designated.  */
 -#define CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION 4
 -
 -/* Return a charset which is currently designated to the graphic plane
 -   PLANE in the coding-system CODING.  */
 -#define CODING_SPEC_ISO_PLANE_CHARSET(coding, plane)  \
 -  ((CODING_SPEC_ISO_INVOCATION (coding, plane) < 0)   \
 -   ? -1                                                       \
 -   : CODING_SPEC_ISO_DESIGNATION (coding,             \
 -                                CODING_SPEC_ISO_INVOCATION (coding, plane)))
 -
 -/*** BIG5 section ***/
 -
 -/* Macros to denote each type of BIG5 coding system.  */
 -#define CODING_FLAG_BIG5_HKU  0x00 /* BIG5-HKU is one of variants of
 -                                      BIG5 developed by Hong Kong
 -                                      University.  */
 -#define CODING_FLAG_BIG5_ETEN 0x01 /* BIG5_ETen is one of variants
 -                                      of BIG5 developed by the
 -                                      company ETen in Taiwan.  */
  
  /*** GENERAL section ***/
  
@@@ -407,77 -416,42 +407,77 @@@ struct coding_syste
    /* Number of error source data found in a decoding routine.  */
    int errors;
  
 -  /* Finish status of code conversion.  It should be one of macros
 -     CODING_FINISH_XXXX.  */
 -  int result;
 +  /* Store the positions of error source data. */
 +  EMACS_INT *error_positions;
  
 -  /* If nonzero, suppress error notification.  */
 -  int suppress_error;
 +  /* Finish status of code conversion.  */
 +  enum coding_result_code result;
  
 -  /* The following members are all Lisp symbols.  We don't have to
 -     protect them from GC because the current garbage collection
 -     doesn't relocate Lisp symbols.  But, when it is changed, we must
 -     find a way to protect them.  */
 +  EMACS_INT src_pos, src_pos_byte, src_chars, src_bytes;
 +  Lisp_Object src_object;
 +  const unsigned char *source;
  
 -  /* Backward pointer to the Lisp symbol of the coding system.  */
 -  Lisp_Object symbol;
 +  EMACS_INT dst_pos, dst_pos_byte, dst_bytes;
 +  Lisp_Object dst_object;
 +  unsigned char *destination;
  
-   /* Set to 1 iff the source of conversion is not in the member
 -  /* Lisp function (symbol) to be called after decoding to do
 -     additional conversion, or nil.  */
 -  Lisp_Object post_read_conversion;
++  /* Set to 1 if the source of conversion is not in the member
 +     `charbuf', but at `src_object'.  */
 +  int chars_at_source;
  
 -  /* Lisp function (symbol) to be called before encoding to do
 -     additional conversion, or nil.  */
 -  Lisp_Object pre_write_conversion;
 +  /* If an element is non-negative, it is a character code.
  
 -  /* Character translation tables to look up, or nil.  */
 -  Lisp_Object translation_table_for_decode;
 -  Lisp_Object translation_table_for_encode;
 -};
 +     If it is in the range -128..-1, it is a 8-bit character code
 +     minus 256.
 +
 +     If it is less than -128, it specifies the start of an annotation
 +     chunk.  The length of the chunk is -128 minus the value of the
 +     element.  The following elements are OFFSET, ANNOTATION-TYPE, and
 +     a sequence of actual data for the annotation.  OFFSET is a
 +     character position offset from dst_pos or src_pos,
 +     ANNOTATION-TYPE specfies the meaning of the annotation and how to
 +     handle the following data..  */
 +  int *charbuf;
 +  int charbuf_size, charbuf_used;
 +
 +  /* Set to 1 if charbuf contains an annotation.  */
 +  int annotated;
 +
 +  unsigned char carryover[64];
 +  int carryover_bytes;
 +
 +  int default_char;
  
 -/* Mask bits for (struct coding_system *)->common_flags.  */
 -#define CODING_REQUIRE_FLUSHING_MASK  0x01
 -#define CODING_REQUIRE_DECODING_MASK  0x02
 -#define CODING_REQUIRE_ENCODING_MASK  0x04
 -#define CODING_REQUIRE_DETECTION_MASK 0x08
 -#define CODING_ASCII_INCOMPATIBLE_MASK        0x10
 +  int (*detector) P_ ((struct coding_system *,
 +                     struct coding_detection_info *));
 +  void (*decoder) P_ ((struct coding_system *));
 +  int (*encoder) P_ ((struct coding_system *));
 +};
  
 -/* Return 1 if the coding system CODING requires specific code to be
 +/* Meanings of bits in the member `common_flags' of the structure
 +   coding_system.  The lowest 8 bits are reserved for various kind of
 +   annotations (currently two of them are used).  */
 +#define CODING_ANNOTATION_MASK                        0x00FF
 +#define CODING_ANNOTATE_COMPOSITION_MASK      0x0001
 +#define CODING_ANNOTATE_DIRECTION_MASK                0x0002
 +#define CODING_ANNOTATE_CHARSET_MASK          0x0003
 +#define CODING_FOR_UNIBYTE_MASK                       0x0100
 +#define CODING_REQUIRE_FLUSHING_MASK          0x0200
 +#define CODING_REQUIRE_DECODING_MASK          0x0400
 +#define CODING_REQUIRE_ENCODING_MASK          0x0800
 +#define CODING_REQUIRE_DETECTION_MASK         0x1000
 +#define CODING_RESET_AT_BOL_MASK              0x2000
 +
 +/* Return 1 if the coding context CODING requires annotaion
 +   handling.  */
 +#define CODING_REQUIRE_ANNOTATION(coding) \
 +  ((coding)->common_flags & CODING_ANNOTATION_MASK)
 +
 +/* Return 1 if the coding context CODING prefers decoding into unibyte.  */
 +#define CODING_FOR_UNIBYTE(coding) \
 +  ((coding)->common_flags & CODING_FOR_UNIBYTE_MASK)
 +
 +/* Return 1 if the coding context CODING requires specific code to be
     attached at the tail of converted text.  */
  #define CODING_REQUIRE_FLUSHING(coding) \
    ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK)
diff --cc src/composite.h
Simple merge
diff --cc src/dired.c
Simple merge
diff --cc src/editfns.c
Simple merge
diff --cc src/emacs.c
Simple merge
diff --cc src/fileio.c
Simple merge
diff --cc src/fontset.c
index 26b412804ca10326489bfbf42461fdb666734451,9056e2da6ecf597ba42944d2c3b5de973f1a1d82..47a682cc97594531e34c06b46ca7240d5874b942
@@@ -971,9 -500,9 +971,9 @@@ free_face_fontset (f, face
  }
  
  
- /* Return 1 iff FACE is suitable for displaying character C.
+ /* Return 1 if FACE is suitable for displaying character C.
     Otherwise return 0.  Called from the macro FACE_SUITABLE_FOR_CHAR_P
 -   when C is not a single byte character..  */
 +   when C is not an ASCII character.  */
  
  int
  face_suitable_for_char_p (face, c)
diff --cc src/fontset.h
Simple merge
diff --cc src/indent.c
Simple merge
diff --cc src/insdel.c
Simple merge
diff --cc src/intervals.c
Simple merge
diff --cc src/keyboard.c
Simple merge
diff --cc src/keymap.c
Simple merge
diff --cc src/lisp.h
Simple merge
diff --cc src/lread.c
Simple merge
diff --cc src/macterm.c
Simple merge
diff --cc src/msdos.c
Simple merge
diff --cc src/print.c
Simple merge
diff --cc src/process.c
Simple merge
diff --cc src/regex.c
Simple merge
diff --cc src/search.c
index aea0f30141d6df1f01441c30720b8585938a9583,d91110f4b0e5d0c38eaedcdf87b10b166c6959df..edcf315b2cde12ce33069ed3f5d37e1389c1dc61
@@@ -1639,7 -1662,7 +1639,7 @@@ simple_search (n, pat, len, len_byte, t
     have nontrivial translation are the same aside from the last byte.
     This makes it possible to translate just the last byte of a
     character, and do so after just a simple test of the context.
-    CHAR_BASE is nonzero iff there is such a non-ASCII character.
 -   CHARSET_BASE is nonzero if there is such a non-ASCII character.
++   CHAR_BASE is nonzero if there is such a non-ASCII character.
  
     If that criterion is not satisfied, do not call this function.  */
  
diff --cc src/w32term.c
Simple merge
diff --cc src/w32term.h
Simple merge
diff --cc src/window.c
Simple merge
diff --cc src/xdisp.c
Simple merge
diff --cc src/xterm.c
Simple merge
diff --cc src/xterm.h
Simple merge