Exemplo n.º 1
0
  // returns the entry number or -1 on eof
  int decode(Buffer b) {
    int ptr = 0;
    DecodeAux t = decode_tree;
    int lok = b.look(t.tabn);
    // System.err.println(this+" "+t+" lok="+lok+", tabn="+t.tabn);

    if (lok >= 0) {
      ptr = t.tab[lok];
      b.adv(t.tabl[lok]);
      if (ptr <= 0) {
        return -ptr;
      }
    }
    do {
      switch (b.read1()) {
        case 0:
          ptr = t.ptr0[ptr];
          break;
        case 1:
          ptr = t.ptr1[ptr];
          break;
        case -1:
        default:
          return (-1);
      }
    } while (ptr > 0);
    return (-ptr);
  }