Changeset 985:f6acd0400f18 for charset.h

Show
Ignore:
Timestamp:
1999-03-30 15:50:33 (10 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

This patch removes at least some of the horrible utf-8 kluges in
charset.c. The new DECODER framework is currently only used in
handler.c, and there in a horribly inefficient manner. We should
use greater blocks of data, which would be much more efficient than
what we are currently doing.

Most of the other charset-related code still uses the old
mutt_display_char() &friends interface, which is actually ok as long
as you don't try to handle multibyte character sets.

The most notable change should be the one to mutt_get_translation():
It will delay the loading and parsing of character set information
files until it's really needed, catching a huge amount of standard
cases. As a side effect, this will make "iso tagged as ascii"
"work" again, as long as both sides use the same iso character set.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • charset.h

    r835 r985  
    5454CHARSET; 
    5555 
    56 /* this one could be made a bit smaller with two levels 
    57  * of nested unions and structs.  It's not worth the effort. 
    58  */ 
     56#define DECODER_BUFFSIZE 4096 
     57 
     58struct decoder_buff 
     59{ 
     60  size_t size, used; 
     61  char buff[DECODER_BUFFSIZE]; 
     62}; 
    5963 
    6064typedef struct decoder 
    6165{ 
    62   STATE *s; 
    63   short is_utf8; 
    64   CHARSET_MAP *map; 
     66  short src_is_utf8; 
     67  short just_take_id; 
     68  short forced; 
     69   
     70  /* used for utf-8 decoding */ 
    6571  CHARSET *chs; 
    66   struct utf8_state *sfu; 
    67 } 
    68 DECODER;     
    6972 
     73  /* used for 8-bit to 8-bit recoding */ 
     74  CHARSET_MAP *chm; 
     75   
     76  /* the buffers */ 
     77  struct decoder_buff in; 
     78  struct decoder_buff out; 
     79}  
     80DECODER; 
     81 
     82DECODER *mutt_open_decoder (const char *, const char *); 
     83void mutt_decoder_push (DECODER *, void *, size_t, size_t *); 
     84void mutt_decoder_pop (DECODER *, void *, size_t, size_t *); 
     85void mutt_decoder_pop_to_state (DECODER *, STATE *); 
     86void mutt_free_decoder (DECODER **); 
    7087 
    7188CHARSET *mutt_get_charset(const char *); 
    7289CHARSET_MAP *mutt_get_translation(const char *, const char *); 
    73 DECODER *mutt_open_decoder (STATE *, BODY *, int); 
    7490int mutt_display_string(char *, CHARSET_MAP *); 
    7591int mutt_is_utf8(const char *); 
    7692int mutt_recode_file (const char *, const char *, const char *); 
    7793unsigned char mutt_display_char(unsigned char, CHARSET_MAP *); 
    78 void mutt_close_decoder (DECODER **); 
    7994void mutt_decode_utf8_string(char *, CHARSET *); 
    80 void mutt_decoder_putc (DECODER *, char); 
    8195 
    8296#endif