diff options
author | Eli Zaretskii <eliz@gnu.org> | 2012-04-06 16:10:30 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2012-04-06 16:10:30 +0300 |
commit | 2f8e16b2a3c5782a3c8266cc76fbba80d506b93d (patch) | |
tree | 208db075f932b76c4720ffd4de7d8ef732da8ae8 /src/character.h | |
parent | ea0ff31442804544d4096f1e7eaff9ecb10e479d (diff) | |
download | emacs-2f8e16b2a3c5782a3c8266cc76fbba80d506b93d.tar.gz |
Warning comments about subtleties of fetching characters from buffers/strings.
src/buffer.h (FETCH_CHAR, FETCH_MULTIBYTE_CHAR):
src/character.h (STRING_CHAR, STRING_CHAR_AND_LENGTH): Add comments
about subtle differences between FETCH_CHAR* and STRING_CHAR*
macros related to unification of CJK characters. For the details,
see the discussion following the message here:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11073#14.
Diffstat (limited to 'src/character.h')
-rw-r--r-- | src/character.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/character.h b/src/character.h index 5ae6cb8c49c..a829def428d 100644 --- a/src/character.h +++ b/src/character.h @@ -292,7 +292,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ } while (0) /* Return the character code of character whose multibyte form is at - P. */ + P. Note that this macro unifies CJK characters whose codepoints + are in the Private Use Areas (PUAs), so it might return a different + codepoint from the one actually stored at P. */ #define STRING_CHAR(p) \ (!((p)[0] & 0x80) \ @@ -309,7 +311,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte - form. */ + form. + + Note: This macro returns the actual length of the character's + multibyte sequence as it is stored in a buffer or string. The + character it returns might have a different codepoint that has a + different multibyte sequence of a different legth, due to possible + unification of CJK characters inside string_char. Therefore do NOT + assume that the length returned by this macro is identical to the + length of the multibyte sequence of the character it returns. */ #define STRING_CHAR_AND_LENGTH(p, actual_len) \ (!((p)[0] & 0x80) \ |