aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.h
diff options
context:
space:
mode:
authorStephen Berman2013-06-14 22:07:55 +0200
committerStephen Berman2013-06-14 22:07:55 +0200
commitbd358779861f265a7acff31ead40172735af693e (patch)
tree345217a9889dbd29b09bdc80a94265c17719d41f /src/coding.h
parent2a97b47f0878cbda86cb6ba0e7e744924810b70e (diff)
parentf7394b12358ae453a0c8b85fc307afc1b740010d (diff)
downloademacs-bd358779861f265a7acff31ead40172735af693e.tar.gz
emacs-bd358779861f265a7acff31ead40172735af693e.zip
Merge from trunk.
Diffstat (limited to 'src/coding.h')
-rw-r--r--src/coding.h69
1 files changed, 36 insertions, 33 deletions
diff --git a/src/coding.h b/src/coding.h
index c45d2ef86e2..d13fd42fe4f 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -1,5 +1,5 @@
1/* Header for coding system handler. 1/* Header for coding system handler.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011 4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
@@ -272,37 +272,31 @@ enum coding_result_code
272 CODING_RESULT_SUCCESS, 272 CODING_RESULT_SUCCESS,
273 CODING_RESULT_INSUFFICIENT_SRC, 273 CODING_RESULT_INSUFFICIENT_SRC,
274 CODING_RESULT_INSUFFICIENT_DST, 274 CODING_RESULT_INSUFFICIENT_DST,
275 CODING_RESULT_INCONSISTENT_EOL,
276 CODING_RESULT_INVALID_SRC, 275 CODING_RESULT_INVALID_SRC,
277 CODING_RESULT_INTERRUPT, 276 CODING_RESULT_INTERRUPT
278 CODING_RESULT_INSUFFICIENT_MEM
279 }; 277 };
280 278
281 279
282/* Macros used for the member `mode' of the struct coding_system. */ 280/* Macros used for the member `mode' of the struct coding_system. */
283 281
284/* If set, recover the original CR or LF of the already decoded text
285 when the decoding routine encounters an inconsistent eol format. */
286#define CODING_MODE_INHIBIT_INCONSISTENT_EOL 0x01
287
288/* If set, the decoding/encoding routines treat the current data as 282/* If set, the decoding/encoding routines treat the current data as
289 the last block of the whole text to be converted, and do the 283 the last block of the whole text to be converted, and do the
290 appropriate finishing job. */ 284 appropriate finishing job. */
291#define CODING_MODE_LAST_BLOCK 0x02 285#define CODING_MODE_LAST_BLOCK 0x01
292 286
293/* If set, it means that the current source text is in a buffer which 287/* If set, it means that the current source text is in a buffer which
294 enables selective display. */ 288 enables selective display. */
295#define CODING_MODE_SELECTIVE_DISPLAY 0x04 289#define CODING_MODE_SELECTIVE_DISPLAY 0x02
296 290
297/* This flag is used by the decoding/encoding routines on the fly. If 291/* This flag is used by the decoding/encoding routines on the fly. If
298 set, it means that right-to-left text is being processed. */ 292 set, it means that right-to-left text is being processed. */
299#define CODING_MODE_DIRECTION 0x08 293#define CODING_MODE_DIRECTION 0x04
300 294
301#define CODING_MODE_FIXED_DESTINATION 0x10 295#define CODING_MODE_FIXED_DESTINATION 0x08
302 296
303/* If set, it means that the encoding routines produces some safe 297/* If set, it means that the encoding routines produces some safe
304 ASCII characters (usually '?') for unsupported characters. */ 298 ASCII characters (usually '?') for unsupported characters. */
305#define CODING_MODE_SAFE_ENCODING 0x20 299#define CODING_MODE_SAFE_ENCODING 0x10
306 300
307 /* For handling composition sequence. */ 301 /* For handling composition sequence. */
308#include "composite.h" 302#include "composite.h"
@@ -446,9 +440,15 @@ struct coding_system
446 /* How may heading bytes we can skip for decoding. This is set to 440 /* How may heading bytes we can skip for decoding. This is set to
447 -1 in setup_coding_system, and updated by detect_coding. So, 441 -1 in setup_coding_system, and updated by detect_coding. So,
448 when this is equal to the byte length of the text being 442 when this is equal to the byte length of the text being
449 converted, we can skip the actual conversion process. */ 443 converted, we can skip the actual conversion process except for
444 the eol format. */
450 ptrdiff_t head_ascii; 445 ptrdiff_t head_ascii;
451 446
447 ptrdiff_t detected_utf8_chars;
448
449 /* Used internally in coding.c. See the comment of detect_ascii. */
450 int eol_seen;
451
452 /* The following members are set by encoding/decoding routine. */ 452 /* The following members are set by encoding/decoding routine. */
453 ptrdiff_t produced, produced_char, consumed, consumed_char; 453 ptrdiff_t produced, produced_char, consumed, consumed_char;
454 454
@@ -646,10 +646,8 @@ struct coding_system
646 for file names, if any. */ 646 for file names, if any. */
647#define ENCODE_FILE(name) \ 647#define ENCODE_FILE(name) \
648 (! NILP (Vfile_name_coding_system) \ 648 (! NILP (Vfile_name_coding_system) \
649 && !EQ (Vfile_name_coding_system, make_number (0)) \
650 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ 649 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \
651 : (! NILP (Vdefault_file_name_coding_system) \ 650 : (! NILP (Vdefault_file_name_coding_system) \
652 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
653 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ 651 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \
654 : name)) 652 : name))
655 653
@@ -658,10 +656,8 @@ struct coding_system
658 for file names, if any. */ 656 for file names, if any. */
659#define DECODE_FILE(name) \ 657#define DECODE_FILE(name) \
660 (! NILP (Vfile_name_coding_system) \ 658 (! NILP (Vfile_name_coding_system) \
661 && !EQ (Vfile_name_coding_system, make_number (0)) \
662 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ 659 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \
663 : (! NILP (Vdefault_file_name_coding_system) \ 660 : (! NILP (Vdefault_file_name_coding_system) \
664 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
665 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ 661 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \
666 : name)) 662 : name))
667 663
@@ -670,7 +666,6 @@ struct coding_system
670 for system functions, if any. */ 666 for system functions, if any. */
671#define ENCODE_SYSTEM(str) \ 667#define ENCODE_SYSTEM(str) \
672 (! NILP (Vlocale_coding_system) \ 668 (! NILP (Vlocale_coding_system) \
673 && !EQ (Vlocale_coding_system, make_number (0)) \
674 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \ 669 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \
675 : str) 670 : str)
676 671
@@ -678,7 +673,6 @@ struct coding_system
678 for system functions, if any. */ 673 for system functions, if any. */
679#define DECODE_SYSTEM(str) \ 674#define DECODE_SYSTEM(str) \
680 (! NILP (Vlocale_coding_system) \ 675 (! NILP (Vlocale_coding_system) \
681 && !EQ (Vlocale_coding_system, make_number (0)) \
682 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ 676 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \
683 : str) 677 : str)
684 678
@@ -707,23 +701,32 @@ extern void encode_coding_object (struct coding_system *,
707 Lisp_Object, ptrdiff_t, ptrdiff_t, 701 Lisp_Object, ptrdiff_t, ptrdiff_t,
708 ptrdiff_t, ptrdiff_t, Lisp_Object); 702 ptrdiff_t, ptrdiff_t, Lisp_Object);
709 703
710/* Macros for backward compatibility. */ 704#if defined (WINDOWSNT) || defined (CYGWIN)
711 705
712#define decode_coding_region(coding, from, to) \ 706/* These functions use Lisp string objects to store the UTF-16LE
713 decode_coding_object (coding, Fcurrent_buffer (), \ 707 strings that modern versions of Windows expect. These strings are
714 from, CHAR_TO_BYTE (from), \ 708 not particularly useful to Lisp, and all Lisp strings should be
715 to, CHAR_TO_BYTE (to), Fcurrent_buffer ()) 709 native Emacs multibyte. */
716 710
711/* Access the wide-character string stored in a Lisp string object. */
712#define WCSDATA(x) ((wchar_t *) SDATA (x))
717 713
718#define encode_coding_region(coding, from, to) \ 714/* Convert the multi-byte string in STR to UTF-16LE encoded unibyte
719 encode_coding_object (coding, Fcurrent_buffer (), \ 715 string, and store it in *BUF. BUF may safely point to STR on entry. */
720 from, CHAR_TO_BYTE (from), \ 716extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
721 to, CHAR_TO_BYTE (to), Fcurrent_buffer ())
722 717
718/* Convert STR, a UTF-16LE encoded string embedded in a unibyte string
719 object, to a multi-byte Emacs string and return it. This function
720 calls code_convert_string_norecord internally and has all its
721 failure modes. STR itself is not modified. */
722extern Lisp_Object from_unicode (Lisp_Object str);
723 723
724#define decode_coding_string(coding, string, nocopy) \ 724/* Convert WSTR to an Emacs string. */
725 decode_coding_object (coding, string, 0, 0, SCHARS (string), \ 725extern Lisp_Object from_unicode_buffer (const wchar_t* wstr);
726 SBYTES (string), Qt) 726
727#endif /* WINDOWSNT || CYGWIN */
728
729/* Macros for backward compatibility. */
727 730
728#define encode_coding_string(coding, string, nocopy) \ 731#define encode_coding_string(coding, string, nocopy) \
729 (STRING_MULTIBYTE(string) ? \ 732 (STRING_MULTIBYTE(string) ? \
@@ -751,7 +754,7 @@ extern Lisp_Object Qcoding_system_p;
751extern Lisp_Object Qraw_text, Qemacs_mule, Qno_conversion, Qundecided; 754extern Lisp_Object Qraw_text, Qemacs_mule, Qno_conversion, Qundecided;
752extern Lisp_Object Qbuffer_file_coding_system; 755extern Lisp_Object Qbuffer_file_coding_system;
753 756
754extern Lisp_Object Qunix, Qdos, Qmac; 757extern Lisp_Object Qunix, Qdos;
755 758
756extern Lisp_Object Qtranslation_table; 759extern Lisp_Object Qtranslation_table;
757extern Lisp_Object Qtranslation_table_id; 760extern Lisp_Object Qtranslation_table_id;