Changeset 8691 for trunk/gsdl/src/mgpp/text/TextGet.cpp
- Timestamp:
- 2004-11-29T15:04:28+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/mgpp/text/TextGet.cpp
r2928 r8691 20 20 **************************************************************************/ 21 21 22 // is important to be first, so we escape the truncation warning on VC++ 23 #include "TextGet.h" 22 24 // need this to avoid bizarre compiler problems under VC++ 6.0 23 25 #if defined (__WIN32__) && !defined (GSDL_USE_IOS_H) … … 25 27 #endif 26 28 27 #include "TextGet.h"28 29 #include "mg_files.h" 29 30 #include "netorder.h" … … 49 50 memset (ad, '\0', sizeof (*ad)); 50 51 51 for (i = 0; i <= 1; i++)52 for (i = 0; i <= 1; ++i) 52 53 { 53 54 int j; … … 77 78 78 79 pos = ad->word_data[i]; 79 for (j = 0; j < (int)ad->afh[i].num_frags; j++)80 for (j = 0; j < (int)ad->afh[i].num_frags; ++j) 80 81 { 81 82 ad->words[i][j] = pos; … … 93 94 ad->blk_end[i][num] = ad->blk_start[i][num] + 94 95 (ad->blk_end[i][num - 1] - ad->blk_start[i][num - 1]) * 2; 95 num++;96 ++num; 96 97 } 97 98 } … … 115 116 lookback = cd.cdh.lookback; 116 117 117 for (i = cfh->hd.mincodelen; i <= cfh->hd.maxcodelen; i++) {118 for (i = cfh->hd.mincodelen; i <= cfh->hd.maxcodelen; ++i) { 118 119 ptrs_reqd += (cfh->hd.lencount[i] + ((1 << lookback) - 1)) >> lookback; 119 120 mem_reqd += cfh->huff_words_size[i]; … … 135 136 values[0] = vals; 136 137 values[0][0] = next_word[0]; 137 for (i = 1; i <= cfh->hd.maxcodelen; i++)138 for (i = 1; i <= cfh->hd.maxcodelen; ++i) 138 139 { 139 140 int next_start = (values[i - 1] - vals) + … … 146 147 memset (num_set, '\0', sizeof (num_set)); 147 148 148 for (i = 0; i < cfh->hd.num_codes; i++)149 for (i = 0; i < cfh->hd.num_codes; ++i) 149 150 { 150 151 register int val, copy; … … 175 176 } 176 177 memcpy (last_word[len], word, *word + 1); 177 num_set[len]++;178 ++num_set[len]; 178 179 } 179 180 if (cfh->hd.clens) 180 delete cfh->hd.clens;181 delete []cfh->hd.clens; 181 182 cfh->hd.clens = NULL; 182 183 return values; … … 196 197 return 3; 197 198 if (hd->clens) 198 delete hd->clens;199 delete []hd->clens; 199 200 hd->clens = NULL; 200 201 if (type == chars) … … 239 240 return false; 240 241 241 for (which = 0; which < 2; which++)242 for (which = 0; which < 2; ++which) 242 243 switch (cd.cdh.dict_type) 243 244 { … … 353 354 fread (fixup, fixup_mem, sizeof (u_char), text_fast_comp_dict); 354 355 355 for (p = (u_long *) cd; (u_long) p < (u_long) end; p++)356 for (p = (u_long *) cd; (u_long) p < (u_long) end; ++p) 356 357 if (IS_FIXUP (p)) 357 358 { … … 364 365 NTOHUL(cd->cdh.dict_type); 365 366 NTOHUL(cd->cdh.novel_method); 366 for (i = 0; i < TEXT_PARAMS; i++)367 for (i = 0; i < TEXT_PARAMS; ++i) 367 368 NTOHUL(cd->cdh.params[i]); 368 369 NTOHUL(cd->cdh.num_words[0]); … … 372 373 NTOHUL(cd->cdh.lookback); 373 374 /* cfh */ 374 for (i = 0; i <= 1; i++)375 for (i = 0; i <= 1; ++i) 375 376 { 376 377 int j; … … 379 380 NTOHSI(cd->cfh[i]->hd.mincodelen); 380 381 NTOHSI(cd->cfh[i]->hd.maxcodelen); 381 for (j = 0; j < MAX_HUFFCODE_LEN + 1; j++)382 for (j = 0; j < MAX_HUFFCODE_LEN + 1; ++j) 382 383 { 383 384 NTOHSI(cd->cfh[i]->hd.lencount[j]); … … 385 386 } 386 387 NTOHUL(cd->cfh[i]->uncompressed_size); 387 for (j = 0; j < MAX_HUFFCODE_LEN + 1; j++)388 for (j = 0; j < MAX_HUFFCODE_LEN + 1; ++j) 388 389 NTOHUL(cd->cfh[i]->huff_words_size[j]); 389 390 } … … 392 393 if (cd->cdh.novel_method == MG_NOVEL_DELTA || 393 394 cd->cdh.novel_method == MG_NOVEL_HYBRID) 394 for (i = 0; i <= 1; i++)395 for (i = 0; i <= 1; ++i) 395 396 { 396 397 int j; … … 398 399 NTOHUL(cd->ad->afh[i].num_frags); 399 400 NTOHUL(cd->ad->afh[i].mem_for_frags); 400 for (j = 0; j < 33; j++)401 for (j = 0; j < 33; ++j) 401 402 { 402 403 NTOHSI(cd->ad->blk_start[i][j]); … … 406 407 NTOHSI(cd->fast_loaded); 407 408 408 delete fixup;409 delete []fixup; 409 410 410 411 // the whole fast comp dict is a bit of a hack so I don't … … 584 585 unsigned long bits = 0; 585 586 587 if (docText.capacity() < docText.size() + num_bits + 1) { 588 docText.reserve(docText.size() + num_bits + 1); 589 } 586 590 // keep decoding bits until enough bits have been decoded 587 591 while (bits < num_bits) { … … 616 620 len = buffer.huff_decode(cd.lens_huff[which]->min_code, 617 621 cd.lens_vals[which], &bits); 618 for (i = 0; i < len; i++) {622 for (i = 0; i < len; ++i) { 619 623 c = buffer.huff_decode(cd.chars_huff[which]->min_code, 620 624 cd.chars_vals[which], &bits); … … 633 637 { 634 638 idx = buffer.delta_decode (&bits); 635 idx--;639 --idx; 636 640 } 637 641 break; … … 640 644 int k; 641 645 k = buffer.gamma_decode (&bits); 642 k--;646 --k; 643 647 idx = buffer.binary_decode(ad->blk_end[which][k] - 644 648 ad->blk_start[which][k] + 1, … … 650 654 base = ad->words[which][idx]; 651 655 len = *base++; 652 for (; len; len--)656 for (; len; --len) 653 657 { 654 658 docText.push_back (*base++);
Note:
See TracChangeset
for help on using the changeset viewer.