private static
  int extendCdata(final char[] buf, int off, final int end) throws InvalidTokenException {
    while (off != end) {
      switch (charType(buf[off])) {
      case CT_LEAD2:
	if (end - off < 2)
	  return off;
	check2(buf, off);
	off += 2;
	break;
      case CT_RSQB:
      case CT_NONXML:
      case CT_MALFORM:
      case CT_CR:
      case CT_LF:
	return off;
      default:
	off += 1;
	break;
      }
    }
    return off;
  }