1 /* expand.c -- Byte Pair Encoding decompression */
2 /* Copyright 1996 Philip Gage */
4 /* Byte Pair Compression appeared in the September 1997
5 * issue of C/C++ Users Journal. The original source code
6 * may still be found at the web site of the magazine
9 * The decompressor has been modified by me (Thiadmer
10 * Riemersma) to accept a string as input, instead of a
15 #include "embryo_cc_sc.h"
20 strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2])
22 unsigned char stack[STACKSIZE];
26 len = 1; /* already 1 byte for '\0' */
29 /* Pop byte from stack or read byte from the input string */
32 else if ((c = *(unsigned char *)source++) == '\0')
35 /* Push pair on stack or output byte to the output string */
38 stack[top++] = pairtable[c - 128][1];
39 stack[top++] = pairtable[c - 128][0];