Mercurial > octave-nkf
comparison src/ls-mat5.cc @ 12405:80666cb91c4c release-3-4-x
Remove parts of previous changset that weren't supposed to be committed
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sun, 06 Feb 2011 23:29:16 +0100 |
parents | 6001e10ce152 |
children | 824b3e0ab12a |
comparison
equal
deleted
inserted
replaced
12404:6001e10ce152 | 12405:80666cb91c4c |
---|---|
523 // wouldn't be needed. | 523 // wouldn't be needed. |
524 | 524 |
525 OCTAVE_LOCAL_BUFFER (char, inbuf, element_length); | 525 OCTAVE_LOCAL_BUFFER (char, inbuf, element_length); |
526 is.read (inbuf, element_length); | 526 is.read (inbuf, element_length); |
527 | 527 |
528 std::cerr << "len: " << element_length << "\n"; | |
529 | |
530 // We uncompress the first 8 bytes of the header to get the buffer length | 528 // We uncompress the first 8 bytes of the header to get the buffer length |
531 // This will fail with an error Z_MEM_ERROR | 529 // This will fail with an error Z_MEM_ERROR |
532 uLongf destLen = 8; | 530 uLongf destLen = 8; |
533 OCTAVE_LOCAL_BUFFER (unsigned int, tmp, 2); | 531 OCTAVE_LOCAL_BUFFER (unsigned int, tmp, 2); |
534 if (uncompress (reinterpret_cast<Bytef *> (tmp), &destLen, | 532 if (uncompress (reinterpret_cast<Bytef *> (tmp), &destLen, |
537 { | 535 { |
538 // Why should I have to initialize outbuf as I'll just overwrite!! | 536 // Why should I have to initialize outbuf as I'll just overwrite!! |
539 if (swap) | 537 if (swap) |
540 swap_bytes<4> (tmp, 2); | 538 swap_bytes<4> (tmp, 2); |
541 | 539 |
542 destLen = tmp[1] + 32; | 540 destLen = tmp[1] + 8; |
543 std::string outbuf (destLen, ' '); | 541 std::string outbuf (destLen, ' '); |
544 | 542 |
545 // Try reading the compressed file with 8 different lengthes | 543 // FIXME -- find a way to avoid casting away const here! |
546 // to account for the zero padding that are added to matlab | 544 int err = uncompress (reinterpret_cast<Bytef *> |
547 // files | 545 (const_cast<char *> (outbuf.c_str ())), |
548 for (int k = 0; k < 8; k++) | 546 &destLen, reinterpret_cast<Bytef *> (inbuf), |
547 element_length); | |
548 if (err != Z_OK) | |
549 { | 549 { |
550 // FIXME -- find a way to avoid casting away const here! | 550 std::string msg; |
551 int err = uncompress (reinterpret_cast<Bytef *> | 551 switch (err) |
552 (const_cast<char *> (outbuf.c_str ())), | |
553 &destLen, reinterpret_cast<Bytef *> (inbuf), | |
554 element_length - k); | |
555 | |
556 if (err != Z_OK) | |
557 { | 552 { |
558 std::string msg; | 553 case Z_STREAM_END: |
559 switch (err) | 554 msg = "stream end"; |
560 { | 555 break; |
561 case Z_STREAM_END: | 556 |
562 msg = "stream end"; | 557 case Z_NEED_DICT: |
563 break; | 558 msg = "need dict"; |
564 | 559 break; |
565 case Z_NEED_DICT: | 560 |
566 msg = "need dict"; | 561 case Z_ERRNO: |
567 break; | 562 msg = "errno case"; |
568 | 563 break; |
569 case Z_ERRNO: | 564 |
570 msg = "errno case"; | 565 case Z_STREAM_ERROR: |
571 break; | 566 msg = "stream error"; |
572 | 567 break; |
573 case Z_STREAM_ERROR: | 568 |
574 msg = "stream error"; | 569 case Z_DATA_ERROR: |
575 break; | 570 msg = "data error"; |
576 | 571 break; |
577 case Z_DATA_ERROR: | 572 |
578 if (k != 7) | 573 case Z_MEM_ERROR: |
579 { | 574 msg = "mem error"; |
580 std::cerr << "k = " << k << "\n"; | 575 break; |
581 continue; | 576 |
582 } | 577 case Z_BUF_ERROR: |
583 else | 578 msg = "buf error"; |
584 msg = "data error"; | 579 break; |
585 break; | 580 |
586 | 581 case Z_VERSION_ERROR: |
587 case Z_MEM_ERROR: | 582 msg = "version error"; |
588 msg = "mem error"; | |
589 break; | |
590 | |
591 case Z_BUF_ERROR: | |
592 msg = "buf error"; | |
593 break; | |
594 | |
595 case Z_VERSION_ERROR: | |
596 msg = "version error"; | |
597 break; | |
598 } | |
599 | |
600 error ("load: error uncompressing data element (%s from zlib)", | |
601 msg.c_str ()); | |
602 break; | 583 break; |
603 } | 584 } |
604 else | 585 |
605 { | 586 error ("load: error uncompressing data element (%s from zlib)", |
606 std::istringstream gz_is (outbuf); | 587 msg.c_str ()); |
607 retval = read_mat5_binary_element (gz_is, filename, | 588 break; |
589 } | |
590 else | |
591 { | |
592 std::istringstream gz_is (outbuf); | |
593 retval = read_mat5_binary_element (gz_is, filename, | |
608 swap, global, tc); | 594 swap, global, tc); |
609 break; | |
610 } | |
611 } | 595 } |
612 } | 596 } |
613 else | 597 else |
614 error ("load: error probing size of compressed data element"); | 598 error ("load: error probing size of compressed data element"); |
615 | 599 |