summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog59
-rw-r--r--src/alloc.c2
-rw-r--r--src/bidi.c2
-rw-r--r--src/buffer.c2
-rw-r--r--src/buffer.h66
-rw-r--r--src/bytecode.c2
-rw-r--r--src/callint.c2
-rw-r--r--src/callproc.c2
-rw-r--r--src/casefiddle.c2
-rw-r--r--src/casetab.c2
-rw-r--r--src/category.c2
-rw-r--r--src/character.c3
-rw-r--r--src/cmds.c2
-rw-r--r--src/coding.c2
-rw-r--r--src/composite.c2
-rw-r--r--src/dired.c2
-rw-r--r--src/dispnew.c2
-rw-r--r--src/doc.c2
-rw-r--r--src/dosfns.c2
-rw-r--r--src/editfns.c2
-rw-r--r--src/emacs.c1
-rw-r--r--src/fileio.c2
-rw-r--r--src/filelock.c2
-rw-r--r--src/font.c2
-rw-r--r--src/fontset.c2
-rw-r--r--src/fringe.c1
-rw-r--r--src/indent.c2
-rw-r--r--src/insdel.c2
-rw-r--r--src/intervals.c1
-rw-r--r--src/keyboard.c2
-rw-r--r--src/keymap.c2
-rw-r--r--src/lread.c2
-rw-r--r--src/macros.c1
-rw-r--r--src/marker.c2
-rw-r--r--src/minibuf.c1
-rw-r--r--src/nsfns.m2
-rw-r--r--src/nsmenu.m1
-rw-r--r--src/print.c2
-rw-r--r--src/process.c2
-rw-r--r--src/regex.c2
-rw-r--r--src/region-cache.c1
-rw-r--r--src/search.c2
-rw-r--r--src/syntax.c2
-rw-r--r--src/term.c2
-rw-r--r--src/textprop.c1
-rw-r--r--src/undo.c1
-rw-r--r--src/unexsol.c1
-rw-r--r--src/w16select.c2
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32menu.c1
-rw-r--r--src/window.c1
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xfns.c2
-rw-r--r--src/xmenu.c1
-rw-r--r--src/xml.c1
-rw-r--r--src/xselect.c2
56 files changed, 146 insertions, 74 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 61a2b3d78f3..ec92eadaa39 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,62 @@
+2012-06-16 Andreas Schwab <schwab@linux-m68k.org>
+
+ * buffer.h (FETCH_MULTIBYTE_CHAR): Define as inline.
+ (BUF_FETCH_MULTIBYTE_CHAR): Likewise.
+ * character.c (_fetch_multibyte_char_p): Remove.
+ * alloc.c: Include "character.h" before "buffer.h".
+ * bidi.c: Likewise.
+ * buffer.c: Likewise.
+ * bytecode.c: Likewise.
+ * callint.c: Likewise.
+ * callproc.c: Likewise.
+ * casefiddle.c: Likewise.
+ * casetab.c: Likewise.
+ * category.c: Likewise.
+ * cmds.c: Likewise.
+ * coding.c: Likewise.
+ * composite.c: Likewise.
+ * dired.c: Likewise.
+ * dispnew.c: Likewise.
+ * doc.c: Likewise.
+ * dosfns.c: Likewise.
+ * editfns.c: Likewise.
+ * emacs.c: Likewise.
+ * fileio.c: Likewise.
+ * filelock.c: Likewise.
+ * font.c: Likewise.
+ * fontset.c: Likewise.
+ * fringe.c: Likewise.
+ * indent.c: Likewise.
+ * insdel.c: Likewise.
+ * intervals.c: Likewise.
+ * keyboard.c: Likewise.
+ * keymap.c: Likewise.
+ * lread.c: Likewise.
+ * macros.c: Likewise.
+ * marker.c: Likewise.
+ * minibuf.c: Likewise.
+ * nsfns.m: Likewise.
+ * nsmenu.m: Likewise.
+ * print.c: Likewise.
+ * process.c: Likewise.
+ * regex.c: Likewise.
+ * region-cache.c: Likewise.
+ * search.c: Likewise.
+ * syntax.c: Likewise.
+ * term.c: Likewise.
+ * textprop.c: Likewise.
+ * undo.c: Likewise.
+ * unexsol.c: Likewise.
+ * w16select.c: Likewise.
+ * w32fns.c: Likewise.
+ * w32menu.c: Likewise.
+ * window.c: Likewise.
+ * xdisp.c: Likewise.
+ * xfns.c: Likewise.
+ * xmenu.c: Likewise.
+ * xml.c: Likewise.
+ * xselect.c: Likewise.
+
2012-06-16 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (set_cursor_from_row): Don't dereference glyphs_end. If
diff --git a/src/alloc.c b/src/alloc.c
index 1478ce9ae4e..5c6297faae5 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -38,12 +38,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "process.h"
#include "intervals.h"
#include "puresize.h"
+#include "character.h"
#include "buffer.h"
#include "window.h"
#include "keyboard.h"
#include "frame.h"
#include "blockinput.h"
-#include "character.h"
#include "syssignal.h"
#include "termhooks.h" /* For struct terminal. */
#include <setjmp.h>
diff --git a/src/bidi.c b/src/bidi.c
index 7a716d3f0b0..675e2028d92 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -59,8 +59,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "dispextern.h"
static int bidi_initialized = 0;
diff --git a/src/buffer.c b/src/buffer.c
index 504d477494b..c8cbaa25698 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -33,8 +33,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "intervals.h"
#include "window.h"
#include "commands.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "region-cache.h"
#include "indent.h"
#include "blockinput.h"
diff --git a/src/buffer.h b/src/buffer.h
index 3aa4b11c450..8e0604e90c2 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -355,28 +355,6 @@ while (0)
#define FETCH_BYTE(n) *(BYTE_POS_ADDR ((n)))
-/* Variables used locally in FETCH_MULTIBYTE_CHAR. */
-extern unsigned char *_fetch_multibyte_char_p;
-
-/* Return character code of multi-byte form at byte position POS. If POS
- doesn't point the head of valid multi-byte form, only the byte at
- POS is returned. No range checking.
-
- WARNING: The character returned by this macro could be "unified"
- inside STRING_CHAR, if the original character in the buffer belongs
- to one of the Private Use Areas (PUAs) of codepoints that Emacs
- uses to support non-unified CJK characters. If that happens,
- CHAR_BYTES will return a value that is different from the length of
- the original multibyte sequence stored in the buffer. Therefore,
- do _not_ use FETCH_MULTIBYTE_CHAR if you need to advance through
- the buffer to the next character after fetching this one. Instead,
- use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */
-
-#define FETCH_MULTIBYTE_CHAR(pos) \
- (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0) \
- + (pos) + BEG_ADDR - BEG_BYTE), \
- STRING_CHAR (_fetch_multibyte_char_p))
-
/* Return character at byte position POS. If the current buffer is unibyte
and the character is not ASCII, make the returning character
multibyte. */
@@ -425,16 +403,6 @@ extern unsigned char *_fetch_multibyte_char_p;
#define BUF_FETCH_BYTE(buf, n) \
*(BUF_BYTE_ADDRESS ((buf), (n)))
-
-/* Return character code of multi-byte form at byte position POS in BUF.
- If POS doesn't point the head of valid multi-byte form, only the byte at
- POS is returned. No range checking. */
-
-#define BUF_FETCH_MULTIBYTE_CHAR(buf, pos) \
- (_fetch_multibyte_char_p \
- = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) \
- + (pos) + BUF_BEG_ADDR (buf) - BEG_BYTE), \
- STRING_CHAR (_fetch_multibyte_char_p))
/* Define the actual buffer data structures. */
@@ -945,7 +913,41 @@ EXFUN (Fbuffer_local_value, 2);
extern Lisp_Object Qbefore_change_functions;
extern Lisp_Object Qafter_change_functions;
extern Lisp_Object Qfirst_change_hook;
+
+/* Return character code of multi-byte form at byte position POS. If POS
+ doesn't point the head of valid multi-byte form, only the byte at
+ POS is returned. No range checking.
+
+ WARNING: The character returned by this macro could be "unified"
+ inside STRING_CHAR, if the original character in the buffer belongs
+ to one of the Private Use Areas (PUAs) of codepoints that Emacs
+ uses to support non-unified CJK characters. If that happens,
+ CHAR_BYTES will return a value that is different from the length of
+ the original multibyte sequence stored in the buffer. Therefore,
+ do _not_ use FETCH_MULTIBYTE_CHAR if you need to advance through
+ the buffer to the next character after fetching this one. Instead,
+ use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */
+static inline int
+FETCH_MULTIBYTE_CHAR (ptrdiff_t pos)
+{
+ unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0)
+ + pos + BEG_ADDR - BEG_BYTE);
+ return STRING_CHAR (p);
+}
+
+/* Return character code of multi-byte form at byte position POS in BUF.
+ If POS doesn't point the head of valid multi-byte form, only the byte at
+ POS is returned. No range checking. */
+
+static inline int
+BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
+{
+ unsigned char *p
+ = ((pos >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0)
+ + pos + BUF_BEG_ADDR (buf) - BEG_BYTE);
+ return STRING_CHAR (p);
+}
/* Overlays */
diff --git a/src/bytecode.c b/src/bytecode.c
index e2370254f36..2e6ee3d4445 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -35,8 +35,8 @@ by Hallvard:
#include <config.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "syntax.h"
#include "window.h"
diff --git a/src/callint.c b/src/callint.c
index bfa981ec65a..e5ff99714c0 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -22,12 +22,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "commands.h"
#include "keyboard.h"
#include "window.h"
#include "keymap.h"
-#include "character.h"
Lisp_Object Qminus, Qplus;
Lisp_Object Qcall_interactively;
diff --git a/src/callproc.c b/src/callproc.c
index 976d3061c8b..804af1e9abb 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -44,8 +44,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif /* MSDOS */
#include "commands.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "ccl.h"
#include "coding.h"
#include "composite.h"
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 278806b3030..19fbc832288 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -21,8 +21,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "commands.h"
#include "syntax.h"
#include "composite.h"
diff --git a/src/casetab.c b/src/casetab.c
index c28f0c08d5e..86dbca4d026 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -21,8 +21,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
static Lisp_Object Qcase_table_p, Qcase_table;
Lisp_Object Vascii_downcase_table;
diff --git a/src/category.c b/src/category.c
index 5cb3020a2de..7d0f72d284d 100644
--- a/src/category.c
+++ b/src/category.c
@@ -32,8 +32,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <ctype.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "category.h"
#include "keymap.h"
diff --git a/src/character.c b/src/character.c
index b85cedad937..fbd23409d08 100644
--- a/src/character.c
+++ b/src/character.c
@@ -57,9 +57,6 @@ static Lisp_Object Qauto_fill_chars;
Unicode character. Mainly used by the macro MAYBE_UNIFY_CHAR. */
Lisp_Object Vchar_unify_table;
-/* Variable used locally in the macro FETCH_MULTIBYTE_CHAR. */
-unsigned char *_fetch_multibyte_char_p;
-
static Lisp_Object Qchar_script_table;
diff --git a/src/cmds.c b/src/cmds.c
index 225c26b082c..d617c7f81d9 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -22,8 +22,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
#include "commands.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "syntax.h"
#include "window.h"
#include "keyboard.h"
diff --git a/src/coding.c b/src/coding.c
index 17e342298b9..ab13f0311c0 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -288,8 +288,8 @@ encode_coding_XXX (struct coding_system *coding)
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "ccl.h"
#include "composite.h"
diff --git a/src/composite.c b/src/composite.c
index 50aca156ba4..6070e4070f0 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -25,8 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "coding.h"
#include "intervals.h"
#include "window.h"
diff --git a/src/dired.c b/src/dired.c
index 38dfa23c1bf..1ce236d5674 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -71,9 +71,9 @@ extern struct direct *readdir (DIR *);
#include "lisp.h"
#include "systime.h"
+#include "character.h"
#include "buffer.h"
#include "commands.h"
-#include "character.h"
#include "charset.h"
#include "coding.h"
#include "regex.h"
diff --git a/src/dispnew.c b/src/dispnew.c
index a23f2b9a959..ad675f6e098 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -30,8 +30,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* cm.h must come after dispextern.h on Windows. */
#include "dispextern.h"
#include "cm.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "keyboard.h"
#include "frame.h"
#include "termhooks.h"
diff --git a/src/doc.c b/src/doc.c
index cd23d9266a2..223741c3bf5 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -28,9 +28,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "keyboard.h"
-#include "character.h"
#include "keymap.h"
#include "buildobj.h"
diff --git a/src/dosfns.c b/src/dosfns.c
index d4b96e9df90..e8c0187172d 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <dos.h>
#include <setjmp.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "termchar.h"
#include "frame.h"
@@ -35,7 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "dosfns.h"
#include "msdos.h"
#include "dispextern.h"
-#include "character.h"
#include "coding.h"
#include "process.h"
#include <dpmi.h>
diff --git a/src/editfns.c b/src/editfns.c
index 8f7b2aee76c..1fb20b07e70 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -52,8 +52,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <verify.h>
#include "intervals.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "coding.h"
#include "frame.h"
#include "window.h"
diff --git a/src/emacs.c b/src/emacs.c
index 1d58d25ebfa..8ffbb573f5a 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -45,6 +45,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "commands.h"
#include "intervals.h"
+#include "character.h"
#include "buffer.h"
#include "window.h"
diff --git a/src/fileio.c b/src/fileio.c
index 496f9d7efa4..388ae84b6f3 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -40,8 +40,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "intervals.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "coding.h"
#include "window.h"
#include "blockinput.h"
diff --git a/src/filelock.c b/src/filelock.c
index d8914c73328..a0ac154a0d2 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -40,8 +40,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "coding.h"
#include "systime.h"
diff --git a/src/font.c b/src/font.c
index 16d09af01b3..dbea3a3ca3c 100644
--- a/src/font.c
+++ b/src/font.c
@@ -27,12 +27,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "frame.h"
#include "window.h"
#include "dispextern.h"
#include "charset.h"
-#include "character.h"
#include "composite.h"
#include "fontset.h"
#include "font.h"
diff --git a/src/fontset.c b/src/fontset.c
index b2c7249625e..1d704a5900e 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -32,8 +32,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "blockinput.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "ccl.h"
#include "keyboard.h"
diff --git a/src/fringe.c b/src/fringe.c
index 39f7e8dbb54..0224ea73e3e 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "frame.h"
#include "window.h"
#include "dispextern.h"
+#include "character.h"
#include "buffer.h"
#include "blockinput.h"
#include "termhooks.h"
diff --git a/src/indent.c b/src/indent.c
index 32533438e2a..88cc0ab4798 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -22,8 +22,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "category.h"
#include "composite.h"
#include "indent.h"
diff --git a/src/insdel.c b/src/insdel.c
index 148ba221940..060f83f7a2f 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -25,8 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "intervals.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "window.h"
#include "blockinput.h"
#include "region-cache.h"
diff --git a/src/intervals.c b/src/intervals.c
index 0b332caf897..2c652cd9ad9 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -42,6 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <intprops.h>
#include "lisp.h"
#include "intervals.h"
+#include "character.h"
#include "buffer.h"
#include "puresize.h"
#include "keyboard.h"
diff --git a/src/keyboard.c b/src/keyboard.c
index 093e33ec67c..c0b2ba2f469 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -30,8 +30,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "keyboard.h"
#include "window.h"
#include "commands.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "disptab.h"
#include "dispextern.h"
#include "syntax.h"
diff --git a/src/keymap.c b/src/keymap.c
index 2f5558c171f..6c59a4a78d0 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -43,8 +43,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
#include "commands.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "keyboard.h"
#include "frame.h"
diff --git a/src/lread.c b/src/lread.c
index 8a9088b8ed2..a6d77204cf8 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -28,8 +28,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
#include "intervals.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "coding.h"
#include <epaths.h>
diff --git a/src/macros.c b/src/macros.c
index 0db7e63d622..7c8bc4c13b8 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "macros.h"
#include "commands.h"
+#include "character.h"
#include "buffer.h"
#include "window.h"
#include "keyboard.h"
diff --git a/src/marker.c b/src/marker.c
index 37953494459..2c09b8e19a2 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -20,8 +20,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
/* Record one cached position found recently by
buf_charpos_to_bytepos or buf_bytepos_to_charpos. */
diff --git a/src/minibuf.c b/src/minibuf.c
index d921e80be48..bed9bb39d31 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -25,6 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "commands.h"
+#include "character.h"
#include "buffer.h"
#include "dispextern.h"
#include "keyboard.h"
diff --git a/src/nsfns.m b/src/nsfns.m
index 5cea73c39ca..113fff394c4 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -38,11 +38,11 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
#include "blockinput.h"
#include "nsterm.h"
#include "window.h"
+#include "character.h"
#include "buffer.h"
#include "keyboard.h"
#include "termhooks.h"
#include "fontset.h"
-#include "character.h"
#include "font.h"
#if 0
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 4bfe0cc003a..1f86417b53a 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -28,6 +28,7 @@ Carbon version by Yamamoto Mitsuharu. */
#include "lisp.h"
#include "window.h"
+#include "character.h"
#include "buffer.h"
#include "keymap.h"
#include "coding.h"
diff --git a/src/print.c b/src/print.c
index 2158d06dbca..a388832b07b 100644
--- a/src/print.c
+++ b/src/print.c
@@ -23,8 +23,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "keyboard.h"
#include "frame.h"
diff --git a/src/process.c b/src/process.c
index 4d59ff0d452..6e454db6b4c 100644
--- a/src/process.c
+++ b/src/process.c
@@ -93,8 +93,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "systty.h"
#include "window.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "coding.h"
#include "process.h"
#include "frame.h"
diff --git a/src/regex.c b/src/regex.c
index 0dd3a187898..7ef53c606c9 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -130,13 +130,13 @@
# include <setjmp.h>
# include "lisp.h"
+# include "character.h"
# include "buffer.h"
/* Make syntax table lookup grant data in gl_state. */
# define SYNTAX_ENTRY_VIA_PROPERTY
# include "syntax.h"
-# include "character.h"
# include "category.h"
# ifdef malloc
diff --git a/src/region-cache.c b/src/region-cache.c
index 9f4e5921877..2642e824680 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "region-cache.h"
diff --git a/src/search.c b/src/search.c
index 99519b839ef..71ab60d9f85 100644
--- a/src/search.c
+++ b/src/search.c
@@ -24,8 +24,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "syntax.h"
#include "category.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "region-cache.h"
#include "commands.h"
diff --git a/src/syntax.c b/src/syntax.c
index 71da13e7a66..0518a47f92d 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -25,8 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
#include "commands.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "keymap.h"
#include "regex.h"
diff --git a/src/term.c b/src/term.c
index 8ce2efc0929..3a41552c02e 100644
--- a/src/term.c
+++ b/src/term.c
@@ -32,8 +32,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "termchar.h"
#include "termopts.h"
#include "tparam.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "coding.h"
#include "composite.h"
diff --git a/src/textprop.c b/src/textprop.c
index 83d07c56f28..afeb0339d5c 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
#include "intervals.h"
+#include "character.h"
#include "buffer.h"
#include "window.h"
diff --git a/src/undo.c b/src/undo.c
index 9b763984d7f..1cb048690ba 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <setjmp.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "commands.h"
#include "window.h"
diff --git a/src/unexsol.c b/src/unexsol.c
index ef1e34e6f0f..336f3b4faea 100644
--- a/src/unexsol.c
+++ b/src/unexsol.c
@@ -7,6 +7,7 @@
#include <setjmp.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "charset.h"
#include "coding.h"
diff --git a/src/w16select.c b/src/w16select.c
index 03f63bedf0d..270118358b4 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -36,8 +36,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "dispextern.h" /* frame.h seems to want this */
#include "frame.h" /* Need this to get the X window of selected_frame */
#include "blockinput.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "coding.h"
#include "composite.h"
diff --git a/src/w32fns.c b/src/w32fns.c
index a8becea1b74..915114138d8 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -32,13 +32,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "w32term.h"
#include "frame.h"
#include "window.h"
+#include "character.h"
#include "buffer.h"
#include "intervals.h"
#include "dispextern.h"
#include "keyboard.h"
#include "blockinput.h"
#include "epaths.h"
-#include "character.h"
#include "charset.h"
#include "coding.h"
#include "ccl.h"
diff --git a/src/w32menu.c b/src/w32menu.c
index f5f5c6656c4..b957da67567 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -31,6 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "termhooks.h"
#include "window.h"
#include "blockinput.h"
+#include "character.h"
#include "buffer.h"
#include "charset.h"
#include "coding.h"
diff --git a/src/window.c b/src/window.c
index a3461cef90f..8cdfff04fba 100644
--- a/src/window.c
+++ b/src/window.c
@@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
#include "keyboard.h"
#include "keymap.h"
diff --git a/src/xdisp.c b/src/xdisp.c
index 04baeea9706..cd5f03d34ad 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -281,8 +281,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "window.h"
#include "termchar.h"
#include "dispextern.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "indent.h"
#include "commands.h"
diff --git a/src/xfns.c b/src/xfns.c
index 43ccdfaef1a..d49f0ea1458 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -32,13 +32,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "xterm.h"
#include "frame.h"
#include "window.h"
+#include "character.h"
#include "buffer.h"
#include "intervals.h"
#include "dispextern.h"
#include "keyboard.h"
#include "blockinput.h"
#include <epaths.h>
-#include "character.h"
#include "charset.h"
#include "coding.h"
#include "fontset.h"
diff --git a/src/xmenu.c b/src/xmenu.c
index 79ead5f598c..dc98b980278 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -47,6 +47,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "termhooks.h"
#include "window.h"
#include "blockinput.h"
+#include "character.h"
#include "buffer.h"
#include "charset.h"
#include "coding.h"
diff --git a/src/xml.c b/src/xml.c
index e462a1adf57..7bc6130b8b1 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <libxml/HTMLparser.h>
#include "lisp.h"
+#include "character.h"
#include "buffer.h"
diff --git a/src/xselect.c b/src/xselect.c
index 48baeb32581..f1eda5d7c85 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -35,11 +35,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "dispextern.h" /* frame.h seems to want this */
#include "frame.h" /* Need this to get the X window of selected_frame */
#include "blockinput.h"
+#include "character.h"
#include "buffer.h"
#include "process.h"
#include "termhooks.h"
#include "keyboard.h"
-#include "character.h"
#include <X11/Xproto.h>