@@ -139,9 +139,9 @@ void writesav(const char * filePath, Rcpp::DataFrame dat, uint8_t compress)
139
139
tmp1[2 ] = 1 ;
140
140
tmp1[3 ] = 0 ;
141
141
} else if (subtyp == -1 ) {
142
- tmp1[0 ] = 0 ;
143
- tmp1[1 ] = 0 ;
144
- tmp1[2 ] = 0 ;
142
+ tmp1[0 ] = 1 ;
143
+ tmp1[1 ] = 29 ;
144
+ tmp1[2 ] = 1 ;
145
145
tmp1[3 ] = 0 ;
146
146
}
147
147
@@ -166,9 +166,9 @@ void writesav(const char * filePath, Rcpp::DataFrame dat, uint8_t compress)
166
166
tmp2[2 ] = 1 ;
167
167
tmp2[3 ] = 0 ;
168
168
} else if (subtyp == -1 ) {
169
- tmp2[0 ] = 0 ;
170
- tmp2[1 ] = 0 ;
171
- tmp2[2 ] = 0 ;
169
+ tmp2[0 ] = 1 ;
170
+ tmp2[1 ] = 29 ;
171
+ tmp2[2 ] = 1 ;
172
172
tmp2[3 ] = 0 ;
173
173
}
174
174
@@ -306,7 +306,6 @@ void writesav(const char * filePath, Rcpp::DataFrame dat, uint8_t compress)
306
306
// double val_d = 0.0;
307
307
308
308
309
- Rcpp::List buf;
310
309
std::vector<double > buf_d;
311
310
std::vector<std::string> buf_s;
312
311
std::vector<int > flush_type (8 );
@@ -365,11 +364,15 @@ void writesav(const char * filePath, Rcpp::DataFrame dat, uint8_t compress)
365
364
366
365
string val_s = as<string>(as<CharacterVector>(dat[j])[i]);
367
366
368
- val_s.resize (type, ' ' );
367
+ int strlen = type;
368
+ if (strlen == 255 ) strlen = 256 ;
369
+
370
+
371
+ val_s.resize (strlen , ' ' );
369
372
370
373
// begin writing of the string
371
374
372
- int8_t fills = type /8 ;
375
+ int8_t fills = strlen /8 ;
373
376
374
377
// Rprintf("type: %d\n", type);
375
378
// Rprintf("fills: %d\n", fills);
@@ -388,13 +391,6 @@ void writesav(const char * filePath, Rcpp::DataFrame dat, uint8_t compress)
388
391
389
392
int strt = 253 , strl = 8 ;
390
393
391
- if (pos == 248 )
392
- strl = 7 ;
393
-
394
- // if (pos == 256)
395
- // strt = 254;
396
-
397
-
398
394
buf_s.push_back (val_s.substr (pos, strl));
399
395
flush_type[iter] = 2 ;
400
396
@@ -490,10 +486,24 @@ void writesav(const char * filePath, Rcpp::DataFrame dat, uint8_t compress)
490
486
if ((i == n-1 ) & (j == kk -1 )) {
491
487
492
488
// Rcout << "--- EOF ---" << std::endl;
489
+ // Rprintf("buf_s.size() = %d\n", buf_s.size());
490
+ // Rprintf("buf_d.size() = %d\n", buf_d.size());
493
491
494
- std::memcpy (&chunk, chnk, sizeof (double ));
495
- writebin (chunk, sav, swapit);
496
- iter = 0 ;
492
+
493
+ // Rprintf("iter: %d\n", iter);
494
+
495
+ // chunk is not yet completely written.
496
+ if (iter > 0 ) {
497
+
498
+ for (int8_t itr = iter; itr < 8 ; ++itr) {
499
+ chnk[itr] = 0 ;
500
+ }
501
+
502
+ std::memcpy (&chunk, chnk, sizeof (double ));
503
+ writebin (chunk, sav, swapit);
504
+
505
+ iter = 0 ;
506
+ }
497
507
498
508
499
509
int di = 0 , ds = 0 ;
0 commit comments