Changeset 1575:8fe87fc0ebc7

Show
Ignore:
Timestamp:
2000-02-29 14:30:09 (9 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Add error checking to the recode-attachment code. From "Andrew W.
Nosenko" <awn@…>.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • charset.c

    r1433 r1575  
    10561056  int c; 
    10571057  int rv = -1; 
     1058  int source_file_is_unchanged = 1; 
    10581059 
    10591060  size_t lf, lpu, lpo; 
     
    10941095        mutt_decoder_pop (dec, tmp, sizeof (tmp), &lpo); 
    10951096        if (lpo) 
    1096           fwrite (tmp, lpo, 1, tmpfp); 
     1097        { 
     1098          if (fwrite (tmp, lpo, 1, tmpfp) == EOF) 
     1099            goto bail; 
     1100        } 
    10971101      }  
    10981102      while (lpo); 
    10991103    } 
    11001104  } 
     1105  if (lf == EOF && !feof(fp)) 
     1106  { 
     1107    goto bail; 
     1108  } 
    11011109 
    11021110  mutt_decoder_push (dec, NULL, 0, NULL); 
     
    11041112  { 
    11051113    mutt_decoder_pop (dec, tmp, sizeof (tmp), &lpo); 
    1106     if (lpo) fwrite (tmp, lpo, 1, tmpfp); 
     1114    if (lpo) 
     1115    { 
     1116      if (fwrite (tmp, lpo, 1, tmpfp) == EOF) 
     1117        goto bail; 
     1118    } 
    11071119  } 
    11081120  while (lpo); 
     
    11121124  fclose (fp); fp = NULL; 
    11131125  rewind (tmpfp); 
     1126 
     1127 
     1128  source_file_is_unchanged = 0; 
    11141129 
    11151130  /* don't use safe_fopen here - we're just going 
    11161131   * to overwrite the old file. 
    11171132   */ 
    1118  
    11191133  if ((fp = fopen (fname, "w")) == NULL) 
    11201134    goto bail; 
     
    11291143bail: 
    11301144  if (rv == -1) 
    1131     mutt_error (_("Error while recoding %s. See %s for recovering your data."), 
    1132                 fname, tempfile); 
     1145  { 
     1146    if (source_file_is_unchanged) 
     1147    { 
     1148      mutt_error (_("Error while recoding %s. " 
     1149                    "Leave it unchanged."), 
     1150                  fname); 
     1151    } 
     1152    else 
     1153    { 
     1154      mutt_error (_("Error while recoding %s. " 
     1155                    "See %s for recovering your data."), 
     1156                  fname, tempfile); 
     1157    } 
     1158  } 
    11331159 
    11341160  if (fp) fclose (fp);