Changeset 835:6f4b052f193a for compose.c

Show
Ignore:
Timestamp:
1999-02-03 14:14:08 (10 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

[unstable] Produce some reasonable character set support when
postponing messages.

Additionally, this patch fixes a nasty pointer leak in
load_charset() [noted with electric fence], and a completely
mis-lead attempt to use bsearch(). Apparently, nobody ever tested
the utf8 decoder for quite some time.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • compose.c

    r827 r835  
    391391  char buff[SHORT_STRING]; 
    392392 
    393   if (b->type != TYPETEXT) 
     393  if (!mutt_is_text_type (b->type, b->subtype)) 
    394394  { 
    395395    mutt_error _("Can't change character set for non-text attachments!"); 
     
    404404  if (mutt_is_utf8(buff)) 
    405405  { 
    406     mutt_error (_("UTF-8 encoding attachments has not yet been implemented.")); 
    407     return 0; 
    408   } 
    409    
    410   if (mutt_get_charset (buff) == NULL) 
     406    if (!b->noconv) 
     407    { 
     408      mutt_error (_("UTF-8 encoding attachments has not yet been implemented.")); 
     409      return 0; 
     410    } 
     411  } 
     412  else if (mutt_get_charset (buff) == NULL) 
    411413  { 
    412414    mutt_error (_("Character set %s is unknown."), buff); 
     
    762764        break; 
    763765 
    764       case OP_COMPOSE_NORECODE: 
     766#define CURRENT idx[menu->current]->content 
     767       
     768      case OP_COMPOSE_TOGGLE_RECODE: 
     769      {       
    765770        CHECK_COUNT; 
    766         if (idx[menu->current]->content->type != TYPETEXT) 
     771        if (!mutt_is_text_type (CURRENT->type, CURRENT->subtype)) 
    767772        { 
    768           mutt_error (_("Recoding only affects text/plain attachments.")); 
     773          mutt_error (_("Recoding only affects text attachments.")); 
    769774          break; 
    770775        } 
    771         idx[menu->current]->content->noconv = !idx[menu->current]->content->noconv; 
    772         if (idx[menu->current]->content->noconv) 
     776        if (mutt_is_utf8 (mutt_get_parameter ("charset", CURRENT->parameter))) 
     777        { 
     778          mutt_error (_("We currently can't encode to utf-8.")); 
     779          break; 
     780        } 
     781        CURRENT->noconv = !CURRENT->noconv; 
     782        if (CURRENT->noconv) 
    773783          mutt_message (_("The current attachment won't be converted.")); 
    774784        else 
     
    776786        menu->redraw = REDRAW_CURRENT; 
    777787        break; 
    778        
     788      } 
     789 
     790      case OP_COMPOSE_RECODE: 
     791      { 
     792        const char *chs; 
     793        int rv; 
     794 
     795        CHECK_COUNT; 
     796        if (!mutt_is_text_type (CURRENT->type, CURRENT->subtype)) 
     797        { 
     798          mutt_error (_("Recoding only affetcs text attachments.")); 
     799          break; 
     800        } 
     801 
     802        if (!(chs = mutt_get_parameter ("charset", CURRENT->parameter))) 
     803          chs = SendCharset; 
     804 
     805        if (CURRENT->noconv) 
     806          rv = mutt_recode_file (CURRENT->filename, chs, Charset); 
     807        else 
     808          rv = mutt_recode_file (CURRENT->filename, Charset, chs); 
     809 
     810        mutt_update_encoding (CURRENT); 
     811         
     812        if (rv == 0) 
     813        { 
     814          mutt_message (_("Recoding successful.")); 
     815          CURRENT->noconv = !CURRENT->noconv; 
     816        } 
     817 
     818        menu->redraw = REDRAW_CURRENT; 
     819        break; 
     820      } 
     821#undef CURRENT 
     822 
    779823      case OP_COMPOSE_EDIT_DESCRIPTION: 
    780824        CHECK_COUNT;