Subversion Repositories SvarDOS

Rev

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

Rev 2083 Rev 2084
Line 358... Line 358...
358
 
358
 
359
  /* read src byte by byte, len times, each time look for a match of 15,14,13..2 chars in the back buffer */
359
  /* read src byte by byte, len times, each time look for a match of 15,14,13..2 chars in the back buffer */
360
  while (len > 0) {
360
  while (len > 0) {
361
    unsigned short matchlen;
361
    unsigned short matchlen;
362
    unsigned short offset;
362
    unsigned short offset;
363
    matchlen = 15;
363
    matchlen = 16;
364
    if (len < matchlen) matchlen = len;
364
    if (len < matchlen) matchlen = len;
365
 
365
 
366
    for (; matchlen > 1; matchlen--) {
366
    for (; matchlen > 1; matchlen--) {
367
      /* start at offset - 4095 and try to match something */
367
      /* start at offset - 4096 and try to match something */
368
      offset = 4095;
368
      offset = 4096;
369
      if (offset > bytesprocessed) offset = bytesprocessed;
369
      if (offset > bytesprocessed) offset = bytesprocessed;
370
 
370
 
371
      for (; offset > matchlen; offset--) {
371
      for (; offset > matchlen; offset--) {
372
        if (memcmp(src, src - offset, matchlen) == 0) {
372
        if (memcmp(src, src - offset, matchlen) == 0) {
373
          printf("Found match of %u bytes at offset -%u: '%c%c%c...'\n", matchlen, offset, src[0], src[1], src[2]);
373
          printf("Found match of %u bytes at offset -%u: '%c%c%c...'\n", matchlen, offset, src[0], src[1], src[2]);
Line 384... Line 384...
384
    len--;
384
    len--;
385
    complen += 2;
385
    complen += 2;
386
    continue;
386
    continue;
387
 
387
 
388
    FOUND: /* found a match of matchlen bytes at -offset */
388
    FOUND: /* found a match of matchlen bytes at -offset */
389
    *dst = (matchlen << 12) | offset;
389
    *dst = ((matchlen - 1) << 12) | (offset - 1);
390
    dst++;
390
    dst++;
391
    src += matchlen;
391
    src += matchlen;
392
    bytesprocessed += matchlen;
392
    bytesprocessed += matchlen;
393
    len -= matchlen;
393
    len -= matchlen;
394
    complen += 2;
394
    complen += 2;