Show
Ignore:
Timestamp:
02/17/98 01:45:05 (11 years ago)
Author:
himi
Message:

Meadow--Multilingual Enhancement to GNU Emacs with ADvantages Over Windows

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/GNU/src/coding.h

    r1488 r1490  
    136136#define CODING_FLAG_ISO_DESIGNATE_AT_BOL 0x0400 
    137137 
    138 /* If set, do not encode unsafe charactes on output.  */ 
     138/* If set, do not encode unexpected charactes on output.  */ 
    139139#define CODING_FLAG_ISO_SAFE            0x0800 
    140140 
     
    142142   on input.  */ 
    143143#define CODING_FLAG_ISO_LATIN_EXTRA     0x1000 
    144  
    145 /* If set, use designation escape sequence.  */ 
    146 #define CODING_FLAG_ISO_DESIGNATION     0x10000 
    147144 
    148145/* A character to be produced on output if encoding of the original 
     
    162159  int initial_designation[4]; 
    163160 
    164   /* If not -1, it is a graphic register specified in an invalid 
    165      designation sequence.  */ 
    166   int last_invalid_designation_register; 
    167  
    168161  /* A graphic register to which each charset should be designated.  */ 
    169162  unsigned char requested_designation[MAX_CHARSET + 1]; 
    170163 
    171   /* A revision number to be specified for each charset on encoding. 
    172      The value 255 means no revision number for the corresponding 
    173      charset.  */ 
    174   unsigned char charset_revision_number[MAX_CHARSET + 1]; 
     164  /* Table of expected character sets for this coding system.  If the 
     165     Nth element is 0, the charset of ID N is not an expected 
     166     character set.  Such a character set is not encoded when 
     167     CODING_ISO_FLAG_SAFE is set.  */ 
     168  unsigned char expected_charsets[MAX_CHARSET + 1]; 
    175169 
    176170  /* Set to 1 temporarily only when graphic register 2 or 3 is invoked 
     
    184178/* Macros to access each field in the structure `spec.iso2022'.  */ 
    185179#define CODING_SPEC_ISO_INVOCATION(coding, plane) \ 
    186   (coding)->spec.iso2022.current_invocation[plane] 
     180  coding->spec.iso2022.current_invocation[plane] 
    187181#define CODING_SPEC_ISO_DESIGNATION(coding, reg) \ 
    188   (coding)->spec.iso2022.current_designation[reg] 
     182  coding->spec.iso2022.current_designation[reg] 
    189183#define CODING_SPEC_ISO_INITIAL_DESIGNATION(coding, reg) \ 
    190   (coding)->spec.iso2022.initial_designation[reg] 
     184  coding->spec.iso2022.initial_designation[reg] 
    191185#define CODING_SPEC_ISO_REQUESTED_DESIGNATION(coding, charset) \ 
    192   (coding)->spec.iso2022.requested_designation[charset] 
    193 #define CODING_SPEC_ISO_REVISION_NUMBER(coding, charset) \ 
    194   (coding)->spec.iso2022.charset_revision_number[charset] 
     186  coding->spec.iso2022.requested_designation[charset] 
     187#define CODING_SPEC_ISO_EXPECTED_CHARSETS(coding) \ 
     188  coding->spec.iso2022.expected_charsets 
    195189#define CODING_SPEC_ISO_SINGLE_SHIFTING(coding) \ 
    196   (coding)->spec.iso2022.single_shifting 
     190  coding->spec.iso2022.single_shifting 
    197191#define CODING_SPEC_ISO_BOL(coding) \ 
    198   (coding)->spec.iso2022.bol 
     192  coding->spec.iso2022.bol 
    199193 
    200194/* A value which may appear in 
     
    277271#define COMPOSING_WITH_RULE_P(composing) ((composing) & 1) 
    278272 
    279 /* Macros used for the member finish_status of the struct 
    280    coding_system.  */ 
    281 #define CODING_FINISH_NORMAL            0 
    282 #define CODING_FINISH_INSUFFICIENT_SRC  1 
    283 #define CODING_FINISH_INSUFFICIENT_DST  2 
    284 #define CODING_FINISH_INCONSISTENT_EOL  3 
    285  
    286 /* Macros used for the member `mode' of the struct coding_system.  */ 
    287  
    288 /* If set, recover the original CR or LF of the already decoded text 
    289    when the decoding routine encounters an inconsistent eol format.  */ 
    290 #define CODING_MODE_INHIBIT_INCONSISTENT_EOL    0x01 
    291  
    292 /* If set, the decoding/encoding routines treat the current data as 
    293    the last block of the whole text to be converted, and do 
    294    appropriate fisishing job.  */ 
    295 #define CODING_MODE_LAST_BLOCK                  0x02 
    296  
    297 /* If set, it means that the current source text is in a buffer which 
    298    enables selective display.  */ 
    299 #define CODING_MODE_SELECTIVE_DISPLAY           0x04 
    300  
    301 /* This flag is used by the decoding/encoding routines on the fly.  If 
    302    set, it means that right-to-left text is being processed.  */ 
    303 #define CODING_MODE_DIRECTION                   0x08 
    304  
    305273struct coding_system 
    306274{ 
     
    308276  enum coding_type type; 
    309277 
    310   /* Type of end-of-line format (LF, CRLF, or CR) of the coding system.  */ 
    311   int eol_type; 
    312  
    313   /* Flag bits of the coding system.  The meaning of each bit is common 
    314      to all types of coding systems.  */ 
    315   unsigned int common_flags; 
     278  /* If the coding system requires specific code to be attached at the 
     279     tail of converted text, this value should be set to `1'.  */ 
     280  int require_flushing; 
    316281 
    317282  /* Flag bits of the coding system.  The meaning of each bit depends 
     
    319284  unsigned int flags; 
    320285 
    321   /* Mode bits of the coding system.  See the comments of the macros 
    322      CODING_MODE_XXX.  */ 
    323   unsigned int mode; 
    324  
    325   /* Table of safe character sets for this coding system.  If the Nth 
    326      element is 0, the charset of ID N is not a safe character set. 
    327      Such a character set is not encoded when CODING_ISO_FLAG_SAFE is 
    328      set.  */ 
    329   unsigned char safe_charsets[MAX_CHARSET + 1]; 
     286  /* Type of end-of-line format (LF, CRLF, or CR) of the coding system.  */ 
     287  int eol_type; 
     288 
     289  /* Non-zero means that the current source text is the last block of the 
     290     whole text to be converted.  */ 
     291  int last_block; 
    330292 
    331293  /* Non-zero means that characters are being composed currently while 
     
    333295     meaing of each non-zero value.  */ 
    334296  int composing; 
     297 
     298  /* 0 (left-to-right) or 1 (right-to-left): the direction of the text 
     299     being processed currently.  */ 
     300  int direction; 
     301 
     302  /* Non-zero means that the current source text is in a buffer which 
     303     enables selective display.  */ 
     304  int selective; 
    335305 
    336306  /* Detailed information specific to each type of coding system.  */ 
     
    341311    } spec; 
    342312 
    343   /* Index number of coding category of the coding system.  */ 
    344   int category_idx; 
    345  
    346   /* How may heading bytes we can skip for decoding.  This is set to 
    347      -1 in setup_coding_system, and updated by detect_coding.  So, 
    348      when this is equal to the byte length of the text being 
    349      converted, we can skip the actual conversion process.  */ 
    350   int heading_ascii; 
    351  
    352   /* The following members are set by encoding/decoding routine.  */ 
    353   int produced, produced_char, consumed, consumed_char; 
    354  
    355   /* Encoding routines set this to 1 when they produce a byte sequence 
    356      which can be parsed as a multibyte character.  Decoding routines 
    357      set this to 1 when they encounter an invalid code and, as the 
    358      result, produce an unexpected multibyte character.  */ 
    359   int fake_multibyte; 
    360  
    361   /* The following members are all Lisp symbols.  We don't have to 
    362      protect them from GC because the current garbage collection 
    363      doesn't relocate Lisp symbols.  But, when it is changed, we must 
    364      find a way to protect them.  */ 
    365  
    366313  /* Backward pointer to the Lisp symbol of the coding system.  */ 
    367314  Lisp_Object symbol; 
    368315 
    369316  /* Lisp function (symbol) to be called after decoding to do 
    370      additional conversion, or nil. */ 
     317     additional conversion. */ 
    371318  Lisp_Object post_read_conversion; 
    372319 
    373320  /* Lisp function (symbol) to be called before encoding to do 
    374      additional conversion, or nil. */ 
     321     additional conversion. */ 
    375322  Lisp_Object pre_write_conversion; 
    376323 
    377   /* Character translation tables to look up, or nil.  */ 
    378   Lisp_Object translation_table_for_decode; 
    379   Lisp_Object translation_table_for_encode; 
     324  /* Character unification tables to look up, or nil.  */ 
     325  Lisp_Object character_unification_table_for_decode; 
     326  Lisp_Object character_unification_table_for_encode; 
     327 
     328  /* Carryover yielded by decoding/encoding incomplete source.  No 
     329     coding-system yields more than 7-byte of carryover.  This does 
     330     not include a text which is not processed because of short of 
     331     output buffer.  */ 
     332  char carryover[8]; 
     333 
     334  /* Actual data length in the above array.  */ 
     335  int carryover_size; 
    380336}; 
    381337 
    382 #define CODING_REQUIRE_FLUSHING_MASK    1 
    383 #define CODING_REQUIRE_DECODING_MASK    2 
    384 #define CODING_REQUIRE_ENCODING_MASK    4 
    385 #define CODING_REQUIRE_DETECTION_MASK   8 
    386  
    387 /* Return 1 if the coding system CODING requires specific code to be 
    388    attached at the tail of converted text.  */ 
    389 #define CODING_REQUIRE_FLUSHING(coding) \ 
    390   ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK) 
    391  
    392 /* Return 1 if the coding system CODING requires code conversion on 
    393    decoding.  */ 
    394 #define CODING_REQUIRE_DECODING(coding) \ 
    395   ((coding)->common_flags & CODING_REQUIRE_DECODING_MASK) 
    396  
    397 /* Return 1 if the coding system CODING requires code conversion on 
    398    encoding.  */ 
    399 #define CODING_REQUIRE_ENCODING(coding) \ 
    400   ((coding)->common_flags & CODING_REQUIRE_ENCODING_MASK) 
    401  
    402 /* Return 1 if the coding system CODING requires some kind of code 
    403    detection.  */ 
    404 #define CODING_REQUIRE_DETECTION(coding) \ 
    405   ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK) 
    406  
    407 #define CODING_MAY_REQUIRE_DECODING(coding)     \ 
    408   ((coding)->common_flags                       \ 
    409    & (CODING_REQUIRE_DETECTION_MASK | CODING_REQUIRE_DECODING_MASK)) 
     338/* Return 1 if coding system CODING never requires any code conversion.  */ 
     339#define CODING_REQUIRE_NO_CONVERSION(coding)            \ 
     340  ((coding)->type == coding_type_no_conversion          \ 
     341   || (((coding)->type == coding_type_emacs_mule        \ 
     342        || (coding)->type == coding_type_raw_text)      \ 
     343       && (coding)->eol_type == CODING_EOL_LF)) 
     344 
     345/* Return 1 if coding system CODING may not require code conversion.  */ 
     346#define CODING_MAY_REQUIRE_NO_CONVERSION(coding)        \ 
     347  ((coding)->type == coding_type_no_conversion          \ 
     348   || (((coding)->type == coding_type_emacs_mule        \ 
     349        || (coding)->type == coding_type_undecided      \ 
     350        || (coding)->type == coding_type_raw_text)      \ 
     351       && ((coding)->eol_type == CODING_EOL_LF          \ 
     352           || (coding)->eol_type == CODING_EOL_UNDECIDED))) 
    410353 
    411354/* Index for each coding category in `coding_category_table' */ 
     
    413356#define CODING_CATEGORY_IDX_SJIS        1 
    414357#define CODING_CATEGORY_IDX_ISO_7       2 
    415 #define CODING_CATEGORY_IDX_ISO_7_TIGHT 3 
    416 #define CODING_CATEGORY_IDX_ISO_8_1     4 
    417 #define CODING_CATEGORY_IDX_ISO_8_2     5 
    418 #define CODING_CATEGORY_IDX_ISO_7_ELSE  6 
    419 #define CODING_CATEGORY_IDX_ISO_8_ELSE  7 
    420 #define CODING_CATEGORY_IDX_CCL         8 
    421 #define CODING_CATEGORY_IDX_BIG5        9 
    422 #define CODING_CATEGORY_IDX_RAW_TEXT    10 
    423 #define CODING_CATEGORY_IDX_BINARY      11 
    424 #define CODING_CATEGORY_IDX_MAX         12 
     358#define CODING_CATEGORY_IDX_ISO_8_1     3 
     359#define CODING_CATEGORY_IDX_ISO_8_2     4 
     360#define CODING_CATEGORY_IDX_ISO_7_ELSE  5 
     361#define CODING_CATEGORY_IDX_ISO_8_ELSE  6 
     362#define CODING_CATEGORY_IDX_BIG5        7 
     363#define CODING_CATEGORY_IDX_RAW_TEXT    8 
     364#define CODING_CATEGORY_IDX_BINARY      9 
     365#define CODING_CATEGORY_IDX_MAX         10 
    425366 
    426367/* Definitions of flag bits returned by the function 
     
    429370#define CODING_CATEGORY_MASK_SJIS       (1 << CODING_CATEGORY_IDX_SJIS) 
    430371#define CODING_CATEGORY_MASK_ISO_7      (1 << CODING_CATEGORY_IDX_ISO_7) 
    431 #define CODING_CATEGORY_MASK_ISO_7_TIGHT (1 << CODING_CATEGORY_IDX_ISO_7_TIGHT) 
    432372#define CODING_CATEGORY_MASK_ISO_8_1    (1 << CODING_CATEGORY_IDX_ISO_8_1) 
    433373#define CODING_CATEGORY_MASK_ISO_8_2    (1 << CODING_CATEGORY_IDX_ISO_8_2) 
    434374#define CODING_CATEGORY_MASK_ISO_7_ELSE (1 << CODING_CATEGORY_IDX_ISO_7_ELSE) 
    435375#define CODING_CATEGORY_MASK_ISO_8_ELSE (1 << CODING_CATEGORY_IDX_ISO_8_ELSE) 
    436 #define CODING_CATEGORY_MASK_CCL        (1 << CODING_CATEGORY_IDX_CCL) 
    437376#define CODING_CATEGORY_MASK_BIG5       (1 << CODING_CATEGORY_IDX_BIG5) 
    438377#define CODING_CATEGORY_MASK_RAW_TEXT   (1 << CODING_CATEGORY_IDX_RAW_TEXT) 
     
    445384   | CODING_CATEGORY_MASK_SJIS          \ 
    446385   | CODING_CATEGORY_MASK_ISO_7         \ 
    447    | CODING_CATEGORY_MASK_ISO_7_TIGHT   \ 
    448386   | CODING_CATEGORY_MASK_ISO_8_1       \ 
    449387   | CODING_CATEGORY_MASK_ISO_8_2       \ 
    450388   | CODING_CATEGORY_MASK_ISO_7_ELSE    \ 
    451389   | CODING_CATEGORY_MASK_ISO_8_ELSE    \ 
    452    | CODING_CATEGORY_MASK_CCL           \ 
    453390   | CODING_CATEGORY_MASK_BIG5) 
    454  
    455 #define CODING_CATEGORY_MASK_ISO_7BIT \ 
    456   (CODING_CATEGORY_MASK_ISO_7 | CODING_CATEGORY_MASK_ISO_7_TIGHT) 
    457  
    458 #define CODING_CATEGORY_MASK_ISO_8BIT \ 
    459   (CODING_CATEGORY_MASK_ISO_8_1 | CODING_CATEGORY_MASK_ISO_8_2) 
    460  
    461 #define CODING_CATEGORY_MASK_ISO_SHIFT \ 
    462   (CODING_CATEGORY_MASK_ISO_7_ELSE | CODING_CATEGORY_MASK_ISO_8_ELSE) 
    463  
    464 #define CODING_CATEGORY_MASK_ISO        \ 
    465   (  CODING_CATEGORY_MASK_ISO_7BIT      \ 
    466    | CODING_CATEGORY_MASK_ISO_SHIFT     \ 
    467    | CODING_CATEGORY_MASK_ISO_8BIT) 
    468391 
    469392/* Macros to decode or encode a character of JISX0208 in SJIS.  S1 and 
     
    492415  } while (0) 
    493416 
    494 /* Encode the file name NAME using the specified coding system 
    495    for file names, if any.  */ 
    496 #define ENCODE_FILE(name)                                                  \ 
    497   (! NILP (Vfile_name_coding_system)                                       \ 
    498    && XFASTINT (Vfile_name_coding_system) != 0                             \ 
    499    ? code_convert_string_norecord (name, Vfile_name_coding_system, 1)      \ 
    500    : (! NILP (Vdefault_file_name_coding_system)                            \ 
    501       && XFASTINT (Vdefault_file_name_coding_system) != 0                  \ 
    502       ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ 
    503       : name)) 
    504  
    505 /* Decode the file name NAME using the specified coding system 
    506    for file names, if any.  */ 
    507 #define DECODE_FILE(name)                                                  \ 
    508   (! NILP (Vfile_name_coding_system)                                       \ 
    509    && XFASTINT (Vfile_name_coding_system) != 0                             \ 
    510    ? code_convert_string_norecord (name, Vfile_name_coding_system, 0)      \ 
    511    : (! NILP (Vdefault_file_name_coding_system)                            \ 
    512       && XFASTINT (Vdefault_file_name_coding_system) != 0                  \ 
    513       ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ 
    514       : name)) 
    515  
    516417/* Extern declarations.  */ 
    517 extern int decode_coding P_ ((struct coding_system *, unsigned char *, 
    518                               unsigned char *, int, int)); 
    519 extern int encode_coding P_ ((struct coding_system *, unsigned char *, 
    520                               unsigned char *, int, int)); 
    521 extern int code_convert_region P_ ((int, int, int, int, struct coding_system *, 
    522                                     int, int)); 
    523 extern int decoding_buffer_size P_ ((struct coding_system *, int)); 
    524 extern int encoding_buffer_size P_ ((struct coding_system *, int)); 
    525 extern void detect_coding P_ ((struct coding_system *, unsigned char *, int)); 
    526 extern void detect_eol P_ ((struct coding_system *, unsigned char *, int)); 
     418extern int decode_coding (), encode_coding (); 
     419extern int decoding_buffer_size (), encoding_buffer_size (); 
    527420extern int conversion_buffer_size; 
    528 extern char *conversion_buffer; 
    529 extern char *get_conversion_buffer P_ ((int)); 
    530 extern int setup_coding_system P_ ((Lisp_Object, struct coding_system *)); 
    531 extern void setup_raw_text_coding_system P_ ((struct coding_system *)); 
     421extern char *conversion_buffer, *get_conversion_buffer (); 
     422extern Lisp_Object Fcheck_coding_system (); 
    532423extern Lisp_Object Qcoding_system, Qeol_type, Qcoding_category_index; 
    533 extern Lisp_Object Qraw_text, Qemacs_mule; 
     424extern Lisp_Object Qemacs_mule; 
    534425extern Lisp_Object Qbuffer_file_coding_system; 
    535426extern Lisp_Object Vcoding_category_list; 
    536  
    537 extern Lisp_Object Qtranslation_table; 
    538 extern Lisp_Object Qtranslation_table_id; 
    539427 
    540428/* Mnemonic character to indicate each type of end-of-line.  */ 
     
    542430/* Mnemonic character to indicate type of end-of-line is not yet decided.  */ 
    543431extern int eol_mnemonic_undecided; 
     432 
     433/* Table of coding-systems currently assigned to each coding-category.  */ 
     434extern Lisp_Object coding_category_table[CODING_CATEGORY_IDX_MAX]; 
     435/* Table of names of symbol for each coding-category.  */ 
     436extern char *coding_category_name[CODING_CATEGORY_IDX_MAX]; 
    544437 
    545438#ifdef emacs 
     
    555448extern Lisp_Object Vlast_coding_system_used; 
    556449 
    557 /* If non-zero, process buffer inherits the coding system used to decode 
    558    the subprocess output.  */ 
    559 extern int inherit_process_coding_system; 
    560  
    561450/* Coding-system to be used for encoding terminal output.  This 
    562451   structure contains information of a coding-system specified by the 
     
    573462extern struct coding_system keyboard_coding; 
    574463 
    575 /* Default coding system to be used to write a file.  */ 
    576 extern struct coding_system default_buffer_file_coding; 
    577  
    578464/* Default coding systems used for process I/O.  */ 
    579465extern Lisp_Object Vdefault_process_coding_system; 
    580466 
    581 /* Function to call to force a user to force select a propert coding 
    582    system.  */ 
    583 extern Lisp_Object Vselect_safe_coding_system_function; 
    584  
    585 /* Coding system for file names, or nil if none.  */ 
    586 extern Lisp_Object Vfile_name_coding_system; 
    587  
    588 /* Coding system for file names used only when 
    589    Vfile_name_coding_system is nil.  */ 
    590 extern Lisp_Object Vdefault_file_name_coding_system; 
    591467#endif 
    592468