length1 = offset - temp_offset - 2 * increment;
length1 = offset - temp_offset - (increment<<1);
	private int process_end_pi() throws ParseException,EncodingException, EOFException{		int length1;		ch = getChar();		if (XMLChar.isNameStartChar(ch)) {			if ((ch == 'x' || ch == 'X')					&& (skipChar('m') || skipChar('M'))					&& (skipChar('l') && skipChar('L'))) {				//temp_offset = offset;				ch = getChar();				if (XMLChar.isSpaceChar(ch) || ch == '?')					throw new ParseException(							"Error in PI: [xX][mM][lL] not a valid PI target"									+ formatLineNumber());				//offset = temp_offset;			}			while (true) {				//ch = getChar();				if (!XMLChar.isNameChar(ch)) {					break;				}				ch = getChar();			}			length1 = offset - temp_offset - increment;			/*			 * System.out.println( "" + (char) XMLDoc[temp_offset] + " " +			 * (temp_offset) + " " + length1 + " PI Target " +			 * depth);			 */			if (encoding < FORMAT_UTF_16BE) {				if (length1 > MAX_TOKEN_LENGTH)					throw new ParseException("Token Length Error:"							+ "PI name too long (>0xfffff)"							+ formatLineNumber());				writeVTD(temp_offset, length1, TOKEN_PI_NAME, depth);			} else {				if (length1 > (MAX_TOKEN_LENGTH << 1))					throw new ParseException("Token Length Error:"							+ "PI name too long (>0xfffff)"							+ formatLineNumber());				writeVTD(temp_offset >> 1, length1 >> 1,						TOKEN_PI_NAME, depth);			}			//length1 = 0;			temp_offset = offset;			if (XMLChar.isSpaceChar(ch)) {				ch = getCharAfterS();				while (true) {					if (XMLChar.isValidChar(ch)) {						if (ch == '?')							if (skipChar('>')) {								break;							} else								throw new ParseException(										"Error in PI: invalid termination sequence"												+ formatLineNumber());					} else						throw new ParseException(								"Error in PI: Invalid char in PI val"										+ formatLineNumber());					ch = getChar();				}				length1 = offset - temp_offset - 2 * increment;				if (encoding < FORMAT_UTF_16BE) {					if (length1 > MAX_TOKEN_LENGTH)						throw new ParseException(								"Token Length Error:"										+ "PI val too long (>0xfffff)"										+ formatLineNumber());					writeVTD(temp_offset, length1, TOKEN_PI_VAL,							depth);				} else {					if (length1 > (MAX_TOKEN_LENGTH << 1))						throw new ParseException(								"Token Length Error:"										+ "PI val too long (>0xfffff)"										+ formatLineNumber());					writeVTD(temp_offset >> 1, length1 >> 1,							TOKEN_PI_VAL, depth);				}				return STATE_DOC_END;				//System.out.println(" " + temp_offset + " " +				// length1 + " PI val " + depth);			} else {				if ((ch == '?') && skipChar('>')) {					return STATE_DOC_END;				} else					throw new ParseException(							"Error in PI: invalid termination sequence"									+ formatLineNumber());			}			//parser_state = STATE_DOC_END;		} else			throw new ParseException(					"Error in PI: invalid char in PI target"							+ formatLineNumber());	}