diff options
| author | Andreas Schwab | 2012-06-16 14:24:15 +0200 |
|---|---|---|
| committer | Andreas Schwab | 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.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) | |||
| 355 | 355 | ||
| 356 | #define FETCH_BYTE(n) *(BYTE_POS_ADDR ((n))) | 356 | #define FETCH_BYTE(n) *(BYTE_POS_ADDR ((n))) |
| 357 | 357 | ||
| 358 | /* Variables used locally in FETCH_MULTIBYTE_CHAR. */ | ||
| 359 | extern unsigned char *_fetch_multibyte_char_p; | ||
| 360 | |||
| 361 | /* Return character code of multi-byte form at byte position POS. If POS | ||
| 362 | doesn't point the head of valid multi-byte form, only the byte at | ||
| 363 | POS is returned. No range checking. | ||
| 364 | |||
| 365 | WARNING: The character returned by this macro could be "unified" | ||
| 366 | inside STRING_CHAR, if the original character in the buffer belongs | ||
| 367 | to one of the Private Use Areas (PUAs) of codepoints that Emacs | ||
| 368 | uses to support non-unified CJK characters. If that happens, | ||
| 369 | CHAR_BYTES will return a value that is different from the length of | ||
| 370 | the original multibyte sequence stored in the buffer. Therefore, | ||
| 371 | do _not_ use FETCH_MULTIBYTE_CHAR if you need to advance through | ||
| 372 | the buffer to the next character after fetching this one. Instead, | ||
| 373 | use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */ | ||
| 374 | |||
| 375 | #define FETCH_MULTIBYTE_CHAR(pos) \ | ||
| 376 | (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0) \ | ||
| 377 | + (pos) + BEG_ADDR - BEG_BYTE), \ | ||
| 378 | STRING_CHAR (_fetch_multibyte_char_p)) | ||
| 379 | |||
| 380 | /* Return character at byte position POS. If the current buffer is unibyte | 358 | /* Return character at byte position POS. If the current buffer is unibyte |
| 381 | and the character is not ASCII, make the returning character | 359 | and the character is not ASCII, make the returning character |
| 382 | multibyte. */ | 360 | multibyte. */ |
| @@ -425,16 +403,6 @@ extern unsigned char *_fetch_multibyte_char_p; | |||
| 425 | 403 | ||
| 426 | #define BUF_FETCH_BYTE(buf, n) \ | 404 | #define BUF_FETCH_BYTE(buf, n) \ |
| 427 | *(BUF_BYTE_ADDRESS ((buf), (n))) | 405 | *(BUF_BYTE_ADDRESS ((buf), (n))) |
| 428 | |||
| 429 | /* Return character code of multi-byte form at byte position POS in BUF. | ||
| 430 | If POS doesn't point the head of valid multi-byte form, only the byte at | ||
| 431 | POS is returned. No range checking. */ | ||
| 432 | |||
| 433 | #define BUF_FETCH_MULTIBYTE_CHAR(buf, pos) \ | ||
| 434 | (_fetch_multibyte_char_p \ | ||
| 435 | = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) \ | ||
| 436 | + (pos) + BUF_BEG_ADDR (buf) - BEG_BYTE), \ | ||
| 437 | STRING_CHAR (_fetch_multibyte_char_p)) | ||
| 438 | 406 | ||
| 439 | /* Define the actual buffer data structures. */ | 407 | /* Define the actual buffer data structures. */ |
| 440 | 408 | ||
| @@ -945,7 +913,41 @@ EXFUN (Fbuffer_local_value, 2); | |||
| 945 | extern Lisp_Object Qbefore_change_functions; | 913 | extern Lisp_Object Qbefore_change_functions; |
| 946 | extern Lisp_Object Qafter_change_functions; | 914 | extern Lisp_Object Qafter_change_functions; |
| 947 | extern Lisp_Object Qfirst_change_hook; | 915 | extern Lisp_Object Qfirst_change_hook; |
| 916 | |||
| 917 | /* Return character code of multi-byte form at byte position POS. If POS | ||
| 918 | doesn't point the head of valid multi-byte form, only the byte at | ||
| 919 | POS is returned. No range checking. | ||
| 920 | |||
| 921 | WARNING: The character returned by this macro could be "unified" | ||
| 922 | inside STRING_CHAR, if the original character in the buffer belongs | ||
| 923 | to one of the Private Use Areas (PUAs) of codepoints that Emacs | ||
| 924 | uses to support non-unified CJK characters. If that happens, | ||
| 925 | CHAR_BYTES will return a value that is different from the length of | ||
| 926 | the original multibyte sequence stored in the buffer. Therefore, | ||
| 927 | do _not_ use FETCH_MULTIBYTE_CHAR if you need to advance through | ||
| 928 | the buffer to the next character after fetching this one. Instead, | ||
| 929 | use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */ | ||
| 948 | 930 | ||
| 931 | static inline int | ||
| 932 | FETCH_MULTIBYTE_CHAR (ptrdiff_t pos) | ||
| 933 | { | ||
| 934 | unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0) | ||
| 935 | + pos + BEG_ADDR - BEG_BYTE); | ||
| 936 | return STRING_CHAR (p); | ||
| 937 | } | ||
| 938 | |||
| 939 | /* Return character code of multi-byte form at byte position POS in BUF. | ||
| 940 | If POS doesn't point the head of valid multi-byte form, only the byte at | ||
| 941 | POS is returned. No range checking. */ | ||
| 942 | |||
| 943 | static inline int | ||
| 944 | BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) | ||
| 945 | { | ||
| 946 | unsigned char *p | ||
| 947 | = ((pos >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) | ||
| 948 | + pos + BUF_BEG_ADDR (buf) - BEG_BYTE); | ||
| 949 | return STRING_CHAR (p); | ||
| 950 | } | ||
| 949 | 951 | ||
| 950 | /* Overlays */ | 952 | /* Overlays */ |
| 951 | 953 | ||