crblib/scontext.c
/* returns -1 when an escape is received
 */
1 when an escape is received
1 when an escape is received
int scontextDecode(scontext *sc)
{
int	sym, target;
int low, high;
target = arithGet(sc->arith,sc->total+sc->escape);
if (target >= sc->total) {
	arithDecode(sc->arith,
				sc->total, 
				sc->total+sc->escape,
				sc->total+sc->escape);
	return -1;
	}
sym = 0;
low = 0;
while( target >= sc->tree[sym] ) {
	low += sc->tree[sym];
	target -= sc->tree[sym];
	sym++;
}
high = low + sc->tree[sym];
arithDecode(sc->arith,low, high, sc->total+sc->escape);
scontextAdd(sc,sym);
return sym;
}
int scontextDecode ( scontext * sc ) { int sym , target ; int low , high ; target = arithGet ( sc -> arith , sc -> total + sc -> escape ) ; if ( target >= sc -> total ) { arithDecode ( sc -> arith , sc -> total , sc -> total + sc -> escape , sc -> total + sc -> escape ) ; return -1 ; } sym = 0 ; low = 0 ; while ( target >= sc -> tree [ sym ] ) { low += sc -> tree [ sym ] ; target -= sc -> tree [ sym ] ; sym ++ ; } high = low + sc -> tree [ sym ] ; arithDecode ( sc -> arith , low , high , sc -> total + sc -> escape ) ; scontextAdd ( sc , sym ) ; return sym ; }
returns -1 when an escape is received
returns - 1 when an escape is received
/* check if the escape symbol has been received */