Subversion Repositories SvarDOS

Rev

Rev 2084 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2084 Rev 2102
Line 182... Line 182...
182
  /* is the lang block compressed? then uncompress it */
182
  /* is the lang block compressed? then uncompress it */
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 */
-
 
188
 
187
    for (i = 0; i < compressedsize; i++) {
189
    for (i = 0; i < compressedsize; i++) {
188
      /* read a word token */
190
      /* read a word token */
189
      if (FREAD(fd, buff16, 2) != 2) {
191
      if (FREAD(fd, buff16, 2) != 2) {
190
        exitcode = -5;
192
        exitcode = -5;
191
        goto FCLOSE_AND_EXIT;
193
        goto FCLOSE_AND_EXIT;
192
      }
194
      }
193
 
195
 
194
      /* token format is LLLL OOOO OOOO OOOO, where:
196
      /* token format is LLLL OOOO OOOO OOOO, where:
195
       * OOOO OOOO OOOO is the back reference offset (number of bytes-1 to rewind)
197
       * OOOO OOOO OOOO is the back reference offset (number of bytes-1 to rewind)
196
       * LLLL is the number of bytes (-1) that have to be copied from the offset
198
       * LLLL is the number of bytes (-1) that have to be copied from the offset.
-
 
199
       *
197
       * if the token is > 256 then it represents a literal (single) byte
200
       * However, if LLLL is zero then the token's format is different:
-
 
201
       * 0000 RRRR BBBB BBBB
-
 
202
       *
-
 
203
       * The above form occurs when uncompressible data is encountered:
-
 
204
       * BBBB BBBB is the literal value of a byte to be copied
-
 
205
       * RRRR is the number of RAW (uncompressible) WORDS that follow (possibly 0)
198
       */
206
       */
199
 
207
 
-
 
208
      /* raw word? */
-
 
209
      if (rawwords != 0) {
-
 
210
        unsigned short *dst16 = (void *)dst;
-
 
211
        *dst16 = buff16[0];
-
 
212
        dst += 2;
-
 
213
        rawwords--;
-
 
214
 
200
      /* literal byte? */
215
      /* literal byte? */
201
      if ((buff16[0] & 0xFF00) == 0) {
216
      } else if ((buff16[0] & 0xF000) == 0) {
202
        *dst = buff16[0];
217
        *dst = buff16[0] & 0xff;
203
        dst++;
218
        dst++;
-
 
219
        rawwords = buff16[0] >> 8; /* number of RAW words that are about to follow */
-
 
220
 
204
      } else { /* backreference */
221
      /* else it's a backreference */
-
 
222
      } else {
205
        char *src = dst - (buff16[0] & 0x0FFF) - 1;
223
        char *src = dst - (buff16[0] & 0x0FFF) - 1;
206
        buff16[0] >>= 12;
224
        buff16[0] >>= 12;
207
        for (;;) {
225
        for (;;) {
208
          *dst = *src;
226
          *dst = *src;
209
          dst++;
227
          dst++;