diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2012-06-16 14:24:15 +0200 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2012-06-16 14:24:15 +0200 |
commit | e5560ff7d28c684003ed598a9390e17f9fb92d34 (patch) | |
tree | f8b34c072e755a8bd4bd0a021815a234d112b331 /src/buffer.h | |
parent | 946fdb736dc076e181a3e82cfd4cc307cc061114 (diff) | |
download | emacs-e5560ff7d28c684003ed598a9390e17f9fb92d34.tar.gz emacs-e5560ff7d28c684003ed598a9390e17f9fb92d34.tar.bz2 emacs-e5560ff7d28c684003ed598a9390e17f9fb92d34.zip |
* 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.
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 66 |
1 files changed, 34 insertions, 32 deletions
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 */ |