~zorba-coders/zorba/bug1123016

« back to all changes in this revision

Viewing changes to src/util/base64_util.cpp

  • Committer: Sorin Marian Nasoi
  • Date: 2013-04-09 11:44:43 UTC
  • mfrom: (11301.1.53 zorba)
  • Revision ID: spungi@gmail.com-20130409114443-89vz57gpyjzwoiok
Merged lp:zorba trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
 
208
208
size_type decode( char const *from, size_type from_len, std::vector<char> *to,
209
209
                  int options ) {
210
 
  size_type total_decoded = 0;
 
210
  size_type decoded = 0;
211
211
  if ( from_len ) {
212
212
    std::vector<char>::size_type const orig_size = to->size();
213
213
    to->resize( orig_size + decoded_size( from_len ) );
214
 
    total_decoded = decode( from, from_len, &(*to)[ orig_size ], options );
215
 
    to->resize( orig_size + total_decoded );
 
214
    decoded = decode( from, from_len, &(*to)[ orig_size ], options );
 
215
    to->resize( orig_size + decoded );
216
216
  }
217
 
  return total_decoded;
 
217
  return decoded;
218
218
}
219
219
 
220
220
size_type decode( istream &from, ostream &to, int options ) {
241
241
 
242
242
size_type decode( istream &from, vector<char> *to, int options ) {
243
243
  bool const ignore_ws = !!(options & dopt_ignore_ws);
244
 
  vector<char>::size_type const orig_size = to->size();
245
244
  size_type total_decoded = 0;
246
245
  while ( !from.eof() ) {
247
246
    char from_buf[ 1024 * 4 ];
253
252
      gcount = from.gcount();
254
253
    }
255
254
    if ( gcount ) {
256
 
      to->resize( to->size() + decoded_size( gcount ) );
257
 
      total_decoded +=
 
255
      vector<char>::size_type const orig_size = to->size();
 
256
      to->resize( orig_size + decoded_size( gcount ) );
 
257
      size_type const decoded =
258
258
        decode( from_buf, gcount, &(*to)[ total_decoded ], options );
 
259
      to->resize( orig_size + decoded );
 
260
      total_decoded += decoded;
259
261
    } else
260
262
      break;
261
263
  }
262
 
  to->resize( orig_size + total_decoded );
263
264
  return total_decoded;
264
265
}
265
266