[CM] Fix sdif-import

Tito Latini tito.01beta at gmail.com
Mon Jun 29 03:49:26 PDT 2015


Hello,

sdif-import fails, at least on GNU/Linux x86_64 with SDIF-3.11.4.
I have attached a patch to fix the bug. The logic to increment
bytesread follows the code of the tool `sdifextract':

  SdifFReadGeneralHeader(in);
  SdifFReadAllASCIIChunks(in);
  loop frames:
      SdifFReadFrameHeader(in);
      loop matrices:
          bytesread = SdifFReadMatrixHeader(in);
          loop rows:
              bytesread += SdifFReadOneRow(in);
          SdifFReadPadding(in, SdifFPaddingCalculate(in->Stream, bytesread));
      eof = SdifFGetSignature(in, &bytesread) == eEof;
-------------- next part --------------
diff -ur commonmusic-code-2159-trunk~/src/CmSupport.cpp commonmusic-code-2159-trunk/src/CmSupport.cpp
--- commonmusic-code-2159-trunk~/src/CmSupport.cpp	2015-06-29 12:04:03.677358890 +0200
+++ commonmusic-code-2159-trunk/src/CmSupport.cpp	2015-06-29 12:07:10.470010588 +0200
@@ -2211,7 +2211,7 @@
 
   while (!endoffile && SdifFLastError(sdiffile) == NULL)
   {
-    bytesread += SdifFReadFrameHeader(sdiffile);
+    SdifFReadFrameHeader(sdiffile);
     // optionally skip frames that dont match what we want
     if (sigmatch==eEmptySignature || SdifFCurrSignature(sdiffile) == sigmatch)
     {
@@ -2228,7 +2228,7 @@
 
       for (int m = 0; m < numarrays; m++)
       {
-        bytesread += SdifFReadMatrixHeader(sdiffile);
+        bytesread = SdifFReadMatrixHeader(sdiffile);
         SdifSignature arraysig  = SdifFCurrMatrixSignature (sdiffile);
         SdifInt4 numrows = SdifFCurrNbRow (sdiffile);
         SdifInt4 numcols = SdifFCurrNbCol (sdiffile);
@@ -2265,6 +2265,7 @@
         // add this matrix to end of frame
         s7_set_cdr(ftail, s7_cons(st->scheme, mhead, st->schemeNil));
         ftail=s7_cdr(ftail);
+        SdifFReadPadding(sdiffile, SdifFPaddingCalculate(sdiffile->Stream, bytesread));
       }
       // add this frame to end of results
       if (rhead == st->schemeNil)


More information about the Cmdist mailing list