aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.h
diff options
context:
space:
mode:
authorBill Wohler2012-11-24 19:43:02 -0800
committerBill Wohler2012-11-24 19:43:02 -0800
commit5244bc019bf7376caff3bb198ff674e0ad9fb0e6 (patch)
tree02ee1615e904771f692ec2957c79a08ae029a13d /src/coding.h
parent9f7e719509474e92f85955e22e57ffeebd4e96f3 (diff)
parentc07a6ded1df2f4156badc9add2953579622c3722 (diff)
downloademacs-5244bc019bf7376caff3bb198ff674e0ad9fb0e6.tar.gz
emacs-5244bc019bf7376caff3bb198ff674e0ad9fb0e6.zip
Merge from trunk.
Diffstat (limited to 'src/coding.h')
-rw-r--r--src/coding.h100
1 files changed, 55 insertions, 45 deletions
diff --git a/src/coding.h b/src/coding.h
index b694e6c6b6e..192be58f083 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-2011 Free Software Foundation, Inc. 2 Copyright (C) 2001-2012 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)
@@ -177,7 +177,6 @@ enum coding_attr_index
177#define CODING_ATTR_PRE_WRITE(attrs) AREF (attrs, coding_attr_pre_write) 177#define CODING_ATTR_PRE_WRITE(attrs) AREF (attrs, coding_attr_pre_write)
178#define CODING_ATTR_DEFAULT_CHAR(attrs) AREF (attrs, coding_attr_default_char) 178#define CODING_ATTR_DEFAULT_CHAR(attrs) AREF (attrs, coding_attr_default_char)
179#define CODING_ATTR_FOR_UNIBYTE(attrs) AREF (attrs, coding_attr_for_unibyte) 179#define CODING_ATTR_FOR_UNIBYTE(attrs) AREF (attrs, coding_attr_for_unibyte)
180#define CODING_ATTR_FLUSHING(attrs) AREF (attrs, coding_attr_flushing)
181#define CODING_ATTR_PLIST(attrs) AREF (attrs, coding_attr_plist) 180#define CODING_ATTR_PLIST(attrs) AREF (attrs, coding_attr_plist)
182#define CODING_ATTR_CATEGORY(attrs) AREF (attrs, coding_attr_category) 181#define CODING_ATTR_CATEGORY(attrs) AREF (attrs, coding_attr_category)
183#define CODING_ATTR_SAFE_CHARSETS(attrs)AREF (attrs, coding_attr_safe_charsets) 182#define CODING_ATTR_SAFE_CHARSETS(attrs)AREF (attrs, coding_attr_safe_charsets)
@@ -322,7 +321,7 @@ struct composition_status
322{ 321{
323 enum composition_state state; 322 enum composition_state state;
324 enum composition_method method; 323 enum composition_method method;
325 int old_form; /* 0:pre-21 form, 1:post-21 form */ 324 bool old_form; /* true if pre-21 form */
326 int length; /* number of elements produced in charbuf */ 325 int length; /* number of elements produced in charbuf */
327 int nchars; /* number of characters composed */ 326 int nchars; /* number of characters composed */
328 int ncomps; /* number of composition components */ 327 int ncomps; /* number of composition components */
@@ -351,18 +350,18 @@ struct iso_2022_spec
351 there was an invalid designation previously. */ 350 there was an invalid designation previously. */
352 int current_designation[4]; 351 int current_designation[4];
353 352
354 /* Set to 1 temporarily only when graphic register 2 or 3 is invoked
355 by single-shift while encoding. */
356 int single_shifting;
357
358 /* Set to 1 temporarily only when processing at beginning of line. */
359 int bol;
360
361 /* If positive, we are now scanning CTEXT extended segment. */ 353 /* If positive, we are now scanning CTEXT extended segment. */
362 int ctext_extended_segment_len; 354 int ctext_extended_segment_len;
363 355
364 /* If nonzero, we are now scanning embedded UTF-8 sequence. */ 356 /* True temporarily only when graphic register 2 or 3 is invoked by
365 int embedded_utf_8; 357 single-shift while encoding. */
358 unsigned single_shifting : 1;
359
360 /* True temporarily only when processing at beginning of line. */
361 unsigned bol : 1;
362
363 /* If true, we are now scanning embedded UTF-8 sequence. */
364 unsigned embedded_utf_8 : 1;
366 365
367 /* The current composition. */ 366 /* The current composition. */
368 struct composition_status cmp_status; 367 struct composition_status cmp_status;
@@ -370,7 +369,6 @@ struct iso_2022_spec
370 369
371struct emacs_mule_spec 370struct emacs_mule_spec
372{ 371{
373 int full_support;
374 struct composition_status cmp_status; 372 struct composition_status cmp_status;
375}; 373};
376 374
@@ -449,32 +447,28 @@ struct coding_system
449 -1 in setup_coding_system, and updated by detect_coding. So, 447 -1 in setup_coding_system, and updated by detect_coding. So,
450 when this is equal to the byte length of the text being 448 when this is equal to the byte length of the text being
451 converted, we can skip the actual conversion process. */ 449 converted, we can skip the actual conversion process. */
452 EMACS_INT head_ascii; 450 ptrdiff_t head_ascii;
453 451
454 /* The following members are set by encoding/decoding routine. */ 452 /* The following members are set by encoding/decoding routine. */
455 EMACS_INT produced, produced_char, consumed, consumed_char; 453 ptrdiff_t produced, produced_char, consumed, consumed_char;
456 454
457 /* Number of error source data found in a decoding routine. */ 455 /* Number of error source data found in a decoding routine. */
458 int errors; 456 int errors;
459 457
460 /* Store the positions of error source data. */ 458 /* Store the positions of error source data. */
461 EMACS_INT *error_positions; 459 ptrdiff_t *error_positions;
462 460
463 /* Finish status of code conversion. */ 461 /* Finish status of code conversion. */
464 enum coding_result_code result; 462 enum coding_result_code result;
465 463
466 EMACS_INT src_pos, src_pos_byte, src_chars, src_bytes; 464 ptrdiff_t src_pos, src_pos_byte, src_chars, src_bytes;
467 Lisp_Object src_object; 465 Lisp_Object src_object;
468 const unsigned char *source; 466 const unsigned char *source;
469 467
470 EMACS_INT dst_pos, dst_pos_byte, dst_bytes; 468 ptrdiff_t dst_pos, dst_pos_byte, dst_bytes;
471 Lisp_Object dst_object; 469 Lisp_Object dst_object;
472 unsigned char *destination; 470 unsigned char *destination;
473 471
474 /* Set to 1 if the source of conversion is not in the member
475 `charbuf', but at `src_object'. */
476 int chars_at_source;
477
478 /* If an element is non-negative, it is a character code. 472 /* If an element is non-negative, it is a character code.
479 473
480 If it is in the range -128..-1, it is a 8-bit character code 474 If it is in the range -128..-1, it is a 8-bit character code
@@ -485,23 +479,26 @@ struct coding_system
485 element. The following elements are OFFSET, ANNOTATION-TYPE, and 479 element. The following elements are OFFSET, ANNOTATION-TYPE, and
486 a sequence of actual data for the annotation. OFFSET is a 480 a sequence of actual data for the annotation. OFFSET is a
487 character position offset from dst_pos or src_pos, 481 character position offset from dst_pos or src_pos,
488 ANNOTATION-TYPE specfies the meaning of the annotation and how to 482 ANNOTATION-TYPE specifies the meaning of the annotation and how to
489 handle the following data.. */ 483 handle the following data.. */
490 int *charbuf; 484 int *charbuf;
491 int charbuf_size, charbuf_used; 485 int charbuf_size, charbuf_used;
492 486
487 /* True if the source of conversion is not in the member
488 `charbuf', but at `src_object'. */
489 unsigned chars_at_source : 1;
490
493 /* Set to 1 if charbuf contains an annotation. */ 491 /* Set to 1 if charbuf contains an annotation. */
494 int annotated; 492 unsigned annotated : 1;
495 493
496 unsigned char carryover[64]; 494 unsigned char carryover[64];
497 int carryover_bytes; 495 int carryover_bytes;
498 496
499 int default_char; 497 int default_char;
500 498
501 int (*detector) (struct coding_system *, 499 bool (*detector) (struct coding_system *, struct coding_detection_info *);
502 struct coding_detection_info *);
503 void (*decoder) (struct coding_system *); 500 void (*decoder) (struct coding_system *);
504 int (*encoder) (struct coding_system *); 501 bool (*encoder) (struct coding_system *);
505}; 502};
506 503
507/* Meanings of bits in the member `common_flags' of the structure 504/* Meanings of bits in the member `common_flags' of the structure
@@ -649,10 +646,8 @@ struct coding_system
649 for file names, if any. */ 646 for file names, if any. */
650#define ENCODE_FILE(name) \ 647#define ENCODE_FILE(name) \
651 (! NILP (Vfile_name_coding_system) \ 648 (! NILP (Vfile_name_coding_system) \
652 && !EQ (Vfile_name_coding_system, make_number (0)) \
653 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ 649 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \
654 : (! NILP (Vdefault_file_name_coding_system) \ 650 : (! NILP (Vdefault_file_name_coding_system) \
655 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
656 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ 651 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \
657 : name)) 652 : name))
658 653
@@ -661,10 +656,8 @@ struct coding_system
661 for file names, if any. */ 656 for file names, if any. */
662#define DECODE_FILE(name) \ 657#define DECODE_FILE(name) \
663 (! NILP (Vfile_name_coding_system) \ 658 (! NILP (Vfile_name_coding_system) \
664 && !EQ (Vfile_name_coding_system, make_number (0)) \
665 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ 659 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \
666 : (! NILP (Vdefault_file_name_coding_system) \ 660 : (! NILP (Vdefault_file_name_coding_system) \
667 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
668 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ 661 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \
669 : name)) 662 : name))
670 663
@@ -673,7 +666,6 @@ struct coding_system
673 for system functions, if any. */ 666 for system functions, if any. */
674#define ENCODE_SYSTEM(str) \ 667#define ENCODE_SYSTEM(str) \
675 (! NILP (Vlocale_coding_system) \ 668 (! NILP (Vlocale_coding_system) \
676 && !EQ (Vlocale_coding_system, make_number (0)) \
677 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \ 669 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \
678 : str) 670 : str)
679 671
@@ -681,7 +673,6 @@ struct coding_system
681 for system functions, if any. */ 673 for system functions, if any. */
682#define DECODE_SYSTEM(str) \ 674#define DECODE_SYSTEM(str) \
683 (! NILP (Vlocale_coding_system) \ 675 (! NILP (Vlocale_coding_system) \
684 && !EQ (Vlocale_coding_system, make_number (0)) \
685 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ 676 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \
686 : str) 677 : str)
687 678
@@ -689,28 +680,48 @@ struct coding_system
689#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) 680#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1)
690 681
691/* Extern declarations. */ 682/* Extern declarations. */
692extern Lisp_Object code_conversion_save (int, int); 683extern Lisp_Object code_conversion_save (bool, bool);
693extern int decoding_buffer_size (struct coding_system *, int);
694extern int encoding_buffer_size (struct coding_system *, int);
695extern void setup_coding_system (Lisp_Object, struct coding_system *); 684extern void setup_coding_system (Lisp_Object, struct coding_system *);
696extern Lisp_Object coding_charset_list (struct coding_system *); 685extern Lisp_Object coding_charset_list (struct coding_system *);
697extern Lisp_Object coding_system_charset_list (Lisp_Object); 686extern Lisp_Object coding_system_charset_list (Lisp_Object);
698extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object, 687extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object,
699 Lisp_Object, int, int, int); 688 Lisp_Object, bool, bool, bool);
700extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, 689extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object,
701 int); 690 bool);
702extern Lisp_Object raw_text_coding_system (Lisp_Object); 691extern Lisp_Object raw_text_coding_system (Lisp_Object);
703extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); 692extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object);
704extern Lisp_Object complement_process_encoding_system (Lisp_Object); 693extern Lisp_Object complement_process_encoding_system (Lisp_Object);
705 694
706extern int decode_coding_gap (struct coding_system *, 695extern void decode_coding_gap (struct coding_system *,
707 EMACS_INT, EMACS_INT); 696 ptrdiff_t, ptrdiff_t);
708extern void decode_coding_object (struct coding_system *, 697extern void decode_coding_object (struct coding_system *,
709 Lisp_Object, EMACS_INT, EMACS_INT, 698 Lisp_Object, ptrdiff_t, ptrdiff_t,
710 EMACS_INT, EMACS_INT, Lisp_Object); 699 ptrdiff_t, ptrdiff_t, Lisp_Object);
711extern void encode_coding_object (struct coding_system *, 700extern void encode_coding_object (struct coding_system *,
712 Lisp_Object, EMACS_INT, EMACS_INT, 701 Lisp_Object, ptrdiff_t, ptrdiff_t,
713 EMACS_INT, EMACS_INT, Lisp_Object); 702 ptrdiff_t, ptrdiff_t, Lisp_Object);
703
704#if defined (WINDOWSNT) || defined (CYGWIN)
705
706/* These functions use Lisp string objects to store the UTF-16LE
707 strings that modern versions of Windows expect. These strings are
708 not particularly useful to Lisp, and all Lisp strings should be
709 native Emacs multibyte. */
710
711/* Access the wide-character string stored in a Lisp string object. */
712#define WCSDATA(x) ((wchar_t *) SDATA (x))
713
714/* Convert the multi-byte string in STR to UTF-16LE encoded unibyte
715 string, and store it in *BUF. BUF may safely point to STR on entry. */
716extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
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
724#endif /* WINDOWSNT || CYGWIN */
714 725
715/* Macros for backward compatibility. */ 726/* Macros for backward compatibility. */
716 727
@@ -779,6 +790,5 @@ extern struct coding_system safe_terminal_coding;
779extern Lisp_Object Qcoding_system_error; 790extern Lisp_Object Qcoding_system_error;
780 791
781extern char emacs_mule_bytes[256]; 792extern char emacs_mule_bytes[256];
782extern int emacs_mule_string_char (unsigned char *);
783 793
784#endif /* EMACS_CODING_H */ 794#endif /* EMACS_CODING_H */