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 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
18 #include "embryo_cc_sc.h"
23 strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2])
25 unsigned char stack[STACKSIZE];
29 len = 1; /* already 1 byte for '\0' */
32 /* Pop byte from stack or read byte from the input string */
35 else if ((c = *(unsigned char *)source++) == '\0')
38 /* Push pair on stack or output byte to the output string */
41 stack[top++] = pairtable[c - 128][1];
42 stack[top++] = pairtable[c - 128][0];