Subversion Repositories SvarDOS

Rev

Rev 2102 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2102 Rev 2115
Line 183... Line 183...
183
  if (buff16[0] & 0x8000) {
183
  if (buff16[0] & 0x8000) {
184
    unsigned short compressedsize = buff16[1] / 2;
184
    unsigned short compressedsize = buff16[1] / 2;
185
    unsigned short i;
185
    unsigned short i;
186
    char *dst = svarlang_mem;
186
    char *dst = svarlang_mem;
187
    unsigned char rawwords = 0; /* number of uncompressible words */
187
    unsigned char rawwords = 0; /* number of uncompressible words */
-
 
188
    unsigned short *mvcompptr;
188
 
189
 
-
 
190
    /* start by loading the entire block at the end of the svarlang mem */
-
 
191
    mvcompptr = (void *)(svarlang_mem + svarlang_memsz - buff16[1]);
-
 
192
    if (FREAD(fd, mvcompptr, buff16[1]) != buff16[1]) {
-
 
193
      exitcode = -5;
-
 
194
      goto FCLOSE_AND_EXIT;
-
 
195
    }
-
 
196
 
-
 
197
    /* uncompress now */
189
    for (i = 0; i < compressedsize; i++) {
198
    for (i = 0; i < compressedsize; i++) {
190
      /* read a word token */
199
      /* get next mvcomp token */
191
      if (FREAD(fd, buff16, 2) != 2) {
-
 
192
        exitcode = -5;
200
      buff16[0] = mvcompptr[i];
193
        goto FCLOSE_AND_EXIT;
-
 
194
      }
-
 
195
 
201
 
196
      /* token format is LLLL OOOO OOOO OOOO, where:
202
      /* token format is LLLL OOOO OOOO OOOO, where:
197
       * OOOO OOOO OOOO is the back reference offset (number of bytes-1 to rewind)
203
       * OOOO OOOO OOOO is the back reference offset (number of bytes-1 to rewind)
198
       * LLLL is the number of bytes (-1) that have to be copied from the offset.
204
       * LLLL is the number of bytes (-1) that have to be copied from the offset.
199
       *
205
       *
Line 234... Line 240...
234
    goto FCLOSE_AND_EXIT;
240
    goto FCLOSE_AND_EXIT;
235
  }
241
  }
236
 
242
 
237
  /* lang block not compressed - load as is */
243
  /* lang block not compressed - load as is */
238
  if (FREAD(fd, svarlang_mem, buff16[1]) != buff16[1]) {
244
  if (FREAD(fd, svarlang_mem, buff16[1]) != buff16[1]) {
239
    exitcode = -6;
245
    exitcode = -7;
240
  }
246
  }
241
 
247
 
242
  FCLOSE_AND_EXIT:
248
  FCLOSE_AND_EXIT:
243
 
249
 
244
  FCLOSE(fd);
250
  FCLOSE(fd);